107 lines
2.9 KiB
Go
Executable File
107 lines
2.9 KiB
Go
Executable File
package imgroupctrl
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"91porn-server/common"
|
|
"91porn-server/common/stderr"
|
|
"91porn-server/models/l/operatorlgmod"
|
|
"91porn-server/web/service/imgroupser"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// List doc
|
|
// @Summary 获取im群组列表
|
|
// @Description 获取im群组列表
|
|
// @Tags 后台-im群组
|
|
// @Accept mpfd,json
|
|
// @Produce json
|
|
// @Param q query imgroupser.WebListReq false "请求参数"
|
|
// @Success 200 object imgroupser.WebListRes "成功"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /api/web/admin/imgroup/list [get]
|
|
func List(ctx *gin.Context) {
|
|
var req = &imgroupser.WebListReq{}
|
|
if err := ctx.ShouldBind(&req); err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
|
return
|
|
}
|
|
res, err := req.GetList()
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrDbQueryError, "")
|
|
return
|
|
}
|
|
|
|
common.ServeJSON(ctx, stderr.Success, res)
|
|
}
|
|
|
|
// Create doc
|
|
// @Summary 新增im群组
|
|
// @Description 新增im群组
|
|
// @Tags 后台-im群组
|
|
// @Accept mpfd,json
|
|
// @Produce json
|
|
// @Param q body imgroupser.WebCreateReq false "请求参数"
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /api/web/admin/imgroup/create [post]
|
|
func Create(ctx *gin.Context) {
|
|
manager, err := common.GetAdminAct(ctx)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
|
return
|
|
}
|
|
|
|
p := &imgroupser.WebCreateReq{}
|
|
err = ctx.ShouldBindJSON(&p)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
|
return
|
|
}
|
|
// 创建
|
|
err = p.Create()
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
|
return
|
|
}
|
|
|
|
log, _ := json.Marshal(p)
|
|
_ = operatorlgmod.RecordOperation(manager, "im群组管理", "创建", string(log), ctx.Request.URL.RequestURI())
|
|
common.ServeJSON(ctx, stderr.Success, "")
|
|
}
|
|
|
|
// Update doc
|
|
// @Summary 更新im群组
|
|
// @Description 更新im群组
|
|
// @Tags 后台-im群组
|
|
// @Accept mpfd,json
|
|
// @Produce json
|
|
// @Param q body imgroupser.WebUpdateReq false "请求参数"
|
|
// @Success 200 {string} json "{"msg": "操作成功"}"
|
|
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
|
// @Router /api/web/admin/imgroup/update [post]
|
|
func Update(ctx *gin.Context) {
|
|
manager, err := common.GetAdminAct(ctx)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
|
|
return
|
|
}
|
|
|
|
p := &imgroupser.WebUpdateReq{}
|
|
err = ctx.ShouldBindJSON(&p)
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.ErrParamError, err.Error())
|
|
return
|
|
}
|
|
// 更新
|
|
err = p.Update()
|
|
if err != nil {
|
|
common.ServeJSON(ctx, stderr.Failure, err.Error())
|
|
return
|
|
}
|
|
|
|
log, _ := json.Marshal(p)
|
|
_ = operatorlgmod.RecordOperation(manager, "im群组管理", "更新", string(log), ctx.Request.URL.RequestURI())
|
|
common.ServeJSON(ctx, stderr.Success, "")
|
|
}
|