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