package controller import ( "service/api/consts" "service/api/errcode" footprintproto "service/api/proto/footprint/proto" "service/app/mix/service" "service/bizcommon/util" "service/library/logger" "github.com/gin-gonic/gin" ) func OpCreateFootPrint(ctx *gin.Context) { req := ctx.MustGet("client_req").(*footprintproto.OpCreateReq) ec := service.DefaultService.OpCreateFootPrint(ctx, req) if ec != errcode.ErrCodeFootPrintSrvOk { logger.Error("OpCreateFootPrint fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrorMsg(ctx, "server error") return } ReplyOk(ctx, nil) } func OpDeleteFootPrint(ctx *gin.Context) { req := ctx.MustGet("client_req").(*footprintproto.OpDeleteReq) ec := service.DefaultService.OpDeleteFootPrint(ctx, req) if ec != errcode.ErrCodeFootPrintSrvOk { logger.Error("OpDeleteFootPrint fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, nil) } func OpGetViewFootPrintList(ctx *gin.Context) { req := ctx.MustGet("client_req").(*footprintproto.OpListReq) //设置默认页长 if req.Limit == 0 { req.Limit = consts.DefaultPageSize } list, ec := service.DefaultService.OpGetViewFootPrintList(ctx, req) if ec != errcode.ErrCodeFootPrintSrvOk { logger.Error("OpGetViewFootPrintList fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } data := &footprintproto.OpListData{ List: list, Offset: req.Offset + len(list), } if len(list) >= req.Limit { data.More = 1 } ReplyOk(ctx, data) } func OpGetIsViewedFootPrintList(ctx *gin.Context) { req := ctx.MustGet("client_req").(*footprintproto.OpListReq) //设置默认页长 if req.Limit == 0 { req.Limit = consts.DefaultPageSize } list, ec := service.DefaultService.OpGetIsViewedFootPrintList(ctx, req) if ec != errcode.ErrCodeFootPrintSrvOk { logger.Error("OpGetIsViewedFootPrintList fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } data := &footprintproto.OpListData{ List: list, Offset: req.Offset + len(list), } if len(list) >= req.Limit { data.More = 1 } ReplyOk(ctx, data) } func OpGetFootPrintCount(ctx *gin.Context) { req := ctx.MustGet("client_req").(*footprintproto.OpCountReq) countMap, ec := service.DefaultService.OpGetFootPrintCount(ctx, req) if ec != errcode.ErrCodeFootPrintSrvOk { logger.Error("OpGetFootPrintCount fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } data := &footprintproto.OpCountData{ ViewCount: countMap[consts.View], IsViewedCount: countMap[consts.IsViewed], } ReplyOk(ctx, data) }