package controller import ( "service/api/consts" "service/api/errcode" thumbsupproto "service/api/proto/thumbsup/proto" "service/app/mix/service" "service/bizcommon/util" "service/library/logger" "github.com/gin-gonic/gin" ) func OpCreateThumbsUp(ctx *gin.Context) { req := ctx.MustGet("client_req").(*thumbsupproto.OpCreateReq) ec := service.DefaultService.OpCreateThumbsUp(ctx, req) if ec != errcode.ErrCodeThumbsUpSrvOk { logger.Error("OpCreateThumbsUp fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrorMsg(ctx, "server error") return } ReplyOk(ctx, nil) } func OpDeleteThumbsUp(ctx *gin.Context) { req := ctx.MustGet("client_req").(*thumbsupproto.OpDeleteReq) ec := service.DefaultService.OpDeleteThumbsUp(ctx, req) if ec != errcode.ErrCodeThumbsUpSrvOk { logger.Error("OpDeleteThumbsUp fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, nil) } func OpGetThumbsUpList(ctx *gin.Context) { req := ctx.MustGet("client_req").(*thumbsupproto.OpListReq) //设置默认页长 if req.Limit == 0 { req.Limit = consts.DefaultPageSize } list, ec := service.DefaultService.OpGetThumbsUpList(ctx, req) if ec != errcode.ErrCodeThumbsUpSrvOk { logger.Error("OpGetThumbsUpList fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } data := &thumbsupproto.OpListData{ List: list, Offset: req.Offset + len(list), } if len(list) >= req.Limit { data.More = 1 } ReplyOk(ctx, data) }