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 ApiCreateUserWxAddCheck(ctx *gin.Context) { req := ctx.MustGet("client_req").(*userwxaddcheckproto.ApiCreateReq) ec := service.DefaultService.ApiCreateUserWxAddCheck(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 ApiUpdateUserWxAddCheck(ctx *gin.Context) { req := ctx.MustGet("client_req").(*userwxaddcheckproto.ApiUpdateReq) ec := service.DefaultService.ApiUpdateUserWxAddCheck(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 ApiDeleteUserWxAddCheck(ctx *gin.Context) { req := ctx.MustGet("client_req").(*userwxaddcheckproto.ApiDeleteReq) ec := service.DefaultService.ApiDeleteUserWxAddCheck(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 ApiGetUserWxAddCheckList(ctx *gin.Context) { req := ctx.MustGet("client_req").(*userwxaddcheckproto.ApiListReq) //设置默认页长 if req.Limit == 0 { req.Limit = consts.DefaultPageSize } list, ec := service.DefaultService.ApiGetUserWxAddCheckList(ctx, req) if ec != errcode.ErrCodeUserWxAddCheckSrvOk { logger.Error("OpGetUserWxAddCheckList fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } data := &userwxaddcheckproto.ApiListData{ List: list, Offset: req.Offset + len(list), } if len(list) >= req.Limit { data.More = 1 } ReplyOk(ctx, data) }