|
- package im
-
- import (
- "applet/app/e"
- enum "applet/app/enum/im"
- md "applet/app/md/im"
- svc "applet/app/svc/im"
- "github.com/gin-gonic/gin"
- )
-
- // GetBasic
- // @Summary Im-基础设置(获取)
- // @Tags 基础设置
- // @Description 基础设置(获取)
- // @Accept json
- // @Produce json
- // @param Authorization header string true "验证参数Bearer和token空格拼接"
- // @Success 200 {object} md.GetBasicResp "设置列表"
- // @Failure 400 {object} md.Response "具体错误"
- // @Router /api/im/getBasic [get]
- func GetBasic(c *gin.Context) {
- res := svc.SysCfgFindComm(enum.IsAllowAddFriends, enum.IsAutoAddFriends, enum.ProhibitAddGroupMembers, enum.ProhibitRemoveGroupMembers, enum.ProhibitUpdateGroupName, enum.ChatSensitiveWords)
-
- resp := md.GetBasicResp{
- IsAllowAddFriends: res[enum.IsAllowAddFriends],
- IsAutoAddFriends: res[enum.IsAutoAddFriends],
- ProhibitAddGroupMembers: res[enum.ProhibitAddGroupMembers],
- ProhibitRemoveGroupMembers: res[enum.ProhibitRemoveGroupMembers],
- ProhibitUpdateGroupName: res[enum.ProhibitUpdateGroupName],
- ChatSensitiveWords: res[enum.ProhibitUpdateGroupName],
- }
-
- e.OutSuc(c, resp, nil)
- }
-
- // SetBasic
- // @Summary Im-基础设置(更新)
- // @Tags 基础设置
- // @Description 基础设置(更新)
- // @Accept json
- // @Produce json
- // @param Authorization header string true "验证参数Bearer和token空格拼接"
- // @param req body md.SetBasicReq true "上传需要修改的信息"
- // @Success 200 {string} "success"
- // @Failure 400 {object} md.Response "具体错误"
- // @Router /api/im/setBasic [post]
- func SetBasic(c *gin.Context) {
- var req *md.SetBasicReq
- if err1 := c.ShouldBindJSON(&req); err1 != nil {
- e.OutErr(c, e.ERR_INVALID_ARGS, err1.Error())
- return
- }
- var isTure = true
- isTure = svc.SysCfgSet(enum.IsAllowAddFriends, req.IsAllowAddFriends, enum.SysCfg.String(enum.IsAllowAddFriends))
- if !isTure {
- e.OutErr(c, e.ERR_DB_ORM, "更新:"+enum.SysCfg.String(enum.IsAllowAddFriends)+",失败!")
- return
- }
- isTure = svc.SysCfgSet(enum.IsAutoAddFriends, req.IsAutoAddFriends, enum.SysCfg.String(enum.IsAutoAddFriends))
- if !isTure {
- e.OutErr(c, e.ERR_DB_ORM, "更新:"+enum.SysCfg.String(enum.IsAutoAddFriends)+",失败!")
- return
- }
- isTure = svc.SysCfgSet(enum.ProhibitAddGroupMembers, req.ProhibitAddGroupMembers, enum.SysCfg.String(enum.ProhibitAddGroupMembers))
- if !isTure {
- e.OutErr(c, e.ERR_DB_ORM, "更新:"+enum.SysCfg.String(enum.ProhibitAddGroupMembers)+",失败!")
- return
- }
- isTure = svc.SysCfgSet(enum.ProhibitRemoveGroupMembers, req.ProhibitRemoveGroupMembers, enum.SysCfg.String(enum.ProhibitRemoveGroupMembers))
- if !isTure {
- e.OutErr(c, e.ERR_DB_ORM, "更新:"+enum.SysCfg.String(enum.ProhibitAddGroupMembers)+",失败!")
- return
- }
- isTure = svc.SysCfgSet(enum.ProhibitUpdateGroupName, req.ProhibitUpdateGroupName, enum.SysCfg.String(enum.ProhibitUpdateGroupName))
- if !isTure {
- e.OutErr(c, e.ERR_DB_ORM, "更新:"+enum.SysCfg.String(enum.ProhibitUpdateGroupName)+",失败!")
- return
- }
- isTure = svc.SysCfgSet(enum.ChatSensitiveWords, req.ChatSensitiveWords, enum.SysCfg.String(enum.ChatSensitiveWords))
- if !isTure {
- e.OutErr(c, e.ERR_DB_ORM, "更新:"+enum.SysCfg.String(enum.ChatSensitiveWords)+",失败!")
- return
- }
- e.OutSuc(c, "success", nil)
- }
|