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