service/app/mix/controller/single_distribute_his_op.go

74 lines
2.1 KiB
Go
Raw Normal View History

2024-06-19 13:58:47 +08:00
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)
}