蛋蛋星球 后台端
 
 
 
 

86 lines
3.3 KiB

  1. package im
  2. import (
  3. "applet/app/e"
  4. enum "applet/app/enum/im"
  5. md "applet/app/md/im"
  6. svc "applet/app/svc/im"
  7. "github.com/gin-gonic/gin"
  8. )
  9. // GetBasic
  10. // @Summary Im-基础设置(获取)
  11. // @Tags 基础设置
  12. // @Description 基础设置(获取)
  13. // @Accept json
  14. // @Produce json
  15. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  16. // @Success 200 {object} md.GetBasicResp "设置列表"
  17. // @Failure 400 {object} md.Response "具体错误"
  18. // @Router /api/im/getBasic [get]
  19. func GetBasic(c *gin.Context) {
  20. res := svc.SysCfgFindComm(enum.IsAllowAddFriends, enum.IsAutoAddFriends, enum.ProhibitAddGroupMembers, enum.ProhibitRemoveGroupMembers, enum.ProhibitUpdateGroupName, enum.ChatSensitiveWords)
  21. resp := md.GetBasicResp{
  22. IsAllowAddFriends: res[enum.IsAllowAddFriends],
  23. IsAutoAddFriends: res[enum.IsAutoAddFriends],
  24. ProhibitAddGroupMembers: res[enum.ProhibitAddGroupMembers],
  25. ProhibitRemoveGroupMembers: res[enum.ProhibitRemoveGroupMembers],
  26. ProhibitUpdateGroupName: res[enum.ProhibitUpdateGroupName],
  27. ChatSensitiveWords: res[enum.ChatSensitiveWords],
  28. }
  29. e.OutSuc(c, resp, nil)
  30. }
  31. // SetBasic
  32. // @Summary Im-基础设置(更新)
  33. // @Tags 基础设置
  34. // @Description 基础设置(更新)
  35. // @Accept json
  36. // @Produce json
  37. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  38. // @param req body md.SetBasicReq true "上传需要修改的信息"
  39. // @Success 200 {string} "success"
  40. // @Failure 400 {object} md.Response "具体错误"
  41. // @Router /api/im/setBasic [post]
  42. func SetBasic(c *gin.Context) {
  43. var req *md.SetBasicReq
  44. if err1 := c.ShouldBindJSON(&req); err1 != nil {
  45. e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
  46. return
  47. }
  48. var isTure = true
  49. isTure = svc.SysCfgSet(enum.IsAllowAddFriends, req.IsAllowAddFriends, enum.SysCfg.String(enum.IsAllowAddFriends))
  50. if !isTure {
  51. e.OutErr(c, e.ERR_DB_ORM, "更新:"+enum.SysCfg.String(enum.IsAllowAddFriends)+",失败!")
  52. return
  53. }
  54. isTure = svc.SysCfgSet(enum.IsAutoAddFriends, req.IsAutoAddFriends, enum.SysCfg.String(enum.IsAutoAddFriends))
  55. if !isTure {
  56. e.OutErr(c, e.ERR_DB_ORM, "更新:"+enum.SysCfg.String(enum.IsAutoAddFriends)+",失败!")
  57. return
  58. }
  59. isTure = svc.SysCfgSet(enum.ProhibitAddGroupMembers, req.ProhibitAddGroupMembers, enum.SysCfg.String(enum.ProhibitAddGroupMembers))
  60. if !isTure {
  61. e.OutErr(c, e.ERR_DB_ORM, "更新:"+enum.SysCfg.String(enum.ProhibitAddGroupMembers)+",失败!")
  62. return
  63. }
  64. isTure = svc.SysCfgSet(enum.ProhibitRemoveGroupMembers, req.ProhibitRemoveGroupMembers, enum.SysCfg.String(enum.ProhibitRemoveGroupMembers))
  65. if !isTure {
  66. e.OutErr(c, e.ERR_DB_ORM, "更新:"+enum.SysCfg.String(enum.ProhibitAddGroupMembers)+",失败!")
  67. return
  68. }
  69. isTure = svc.SysCfgSet(enum.ProhibitUpdateGroupName, req.ProhibitUpdateGroupName, enum.SysCfg.String(enum.ProhibitUpdateGroupName))
  70. if !isTure {
  71. e.OutErr(c, e.ERR_DB_ORM, "更新:"+enum.SysCfg.String(enum.ProhibitUpdateGroupName)+",失败!")
  72. return
  73. }
  74. isTure = svc.SysCfgSet(enum.ChatSensitiveWords, req.ChatSensitiveWords, enum.SysCfg.String(enum.ChatSensitiveWords))
  75. if !isTure {
  76. e.OutErr(c, e.ERR_DB_ORM, "更新:"+enum.SysCfg.String(enum.ChatSensitiveWords)+",失败!")
  77. return
  78. }
  79. e.OutSuc(c, "success", nil)
  80. }