Files
huangguo_server/web/api/imgroupmemberctrl/imgroupmember.go
T
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

107 lines
3.0 KiB
Go
Executable File

package imgroupmemberctrl
import (
"encoding/json"
"91porn-server/common"
"91porn-server/common/stderr"
"91porn-server/models/l/operatorlgmod"
"91porn-server/web/service/imgroupmemberser"
"github.com/gin-gonic/gin"
)
// List doc
// @Summary 获取im群组成员列表
// @Description 获取im群组成员列表
// @Tags 后台-im群组成员
// @Accept mpfd,json
// @Produce json
// @Param q query imgroupmemberser.WebListReq false "请求参数"
// @Success 200 object imgroupmemberser.WebListRes "成功"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/web/admin/imgroupmember/list [get]
func List(ctx *gin.Context) {
var req = &imgroupmemberser.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 imgroupmemberser.WebCreateReq false "请求参数"
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/web/admin/imgroupmember/create [post]
func Create(ctx *gin.Context) {
manager, err := common.GetAdminAct(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
return
}
p := &imgroupmemberser.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 imgroupmemberser.WebUpdateReq false "请求参数"
// @Success 200 {string} json "{"msg": "操作成功"}"
// @Failure 400 {string} json "{"msg": "操作失败"}"
// @Router /api/web/admin/imgroupmember/update [post]
func Update(ctx *gin.Context) {
manager, err := common.GetAdminAct(ctx)
if err != nil {
common.ServeJSON(ctx, stderr.AdminIDErr, err.Error())
return
}
p := &imgroupmemberser.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, "")
}