service/app/mix/controller/userwxaddcheck_op.go

74 lines
1.9 KiB
Go
Raw Permalink Normal View History

2023-12-21 22:17:40 +08:00
package controller
import (
"service/api/consts"
"service/api/errcode"
userwxaddcheckproto "service/api/proto/userwxaddcheck/proto"
"service/app/mix/service"
"service/bizcommon/util"
"service/library/logger"
"github.com/gin-gonic/gin"
)
func OpCreateUserWxAddCheck(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*userwxaddcheckproto.OpCreateReq)
ec := service.DefaultService.OpCreateUserWxAddCheck(ctx, req)
if ec != errcode.ErrCodeUserWxAddCheckSrvOk {
logger.Error("OpCreateUserWxAddCheck fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrorMsg(ctx, "server error")
return
}
ReplyOk(ctx, nil)
}
func OpUpdateUserWxAddCheck(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*userwxaddcheckproto.OpUpdateReq)
ec := service.DefaultService.OpUpdateUserWxAddCheck(ctx, req)
if ec != errcode.ErrCodeUserWxAddCheckSrvOk {
logger.Error("OpUpdateUserWxAddCheck fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, nil)
}
func OpDeleteUserWxAddCheck(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*userwxaddcheckproto.OpDeleteReq)
ec := service.DefaultService.OpDeleteUserWxAddCheck(ctx, req.Id)
if ec != errcode.ErrCodeUserWxAddCheckSrvOk {
logger.Error("OpDeleteUserWxAddCheck fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
ReplyOk(ctx, nil)
}
func OpGetUserWxAddCheckList(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*userwxaddcheckproto.OpListReq)
//设置默认页长
if req.Limit == 0 {
req.Limit = consts.DefaultPageSize
}
list, ec := service.DefaultService.OpGetUserWxAddCheckList(ctx, req)
if ec != errcode.ErrCodeUserWxAddCheckSrvOk {
logger.Error("OpGetUserWxAddCheckList fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
data := &userwxaddcheckproto.OpListData{
List: list,
Offset: req.Offset + len(list),
}
if len(list) >= req.Limit {
data.More = 1
}
ReplyOk(ctx, data)
}