package controller import ( "service/api/consts" "service/api/errcode" zone_collaborator_proto "service/api/proto/zone_collaborator/proto" "service/app/mix/service" "service/bizcommon/util" "service/library/logger" "service/library/mediafiller" "github.com/gin-gonic/gin" ) func ApiCreateZoneCollaborator(ctx *gin.Context) { req := ctx.MustGet("client_req").(*zone_collaborator_proto.ApiCreateReq) ec := service.DefaultService.ApiCreateZoneCollaborator(ctx, req) if ec != errcode.ErrCodeZoneCollaboratorSrvOk { logger.Error("ApiCreateZoneCollaborator fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, nil) } func ApiUpdateZoneCollaborator(ctx *gin.Context) { req := ctx.MustGet("client_req").(*zone_collaborator_proto.ApiUpdateReq) ec := service.DefaultService.ApiUpdateZoneCollaborator(ctx, req) if ec != errcode.ErrCodeZoneCollaboratorSrvOk { logger.Error("ApiUpdateZoneCollaborator fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, nil) } func ApiDeleteZoneCollaborator(ctx *gin.Context) { req := ctx.MustGet("client_req").(*zone_collaborator_proto.ApiDeleteReq) ec := service.DefaultService.ApiDeleteZoneCollaborator(ctx, util.DerefInt64(req.Id)) if ec != errcode.ErrCodeZoneCollaboratorSrvOk { logger.Error("ApiDeleteZoneCollaborator fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } ReplyOk(ctx, nil) } func ApiGetZoneCollaboratorList(ctx *gin.Context) { req := ctx.MustGet("client_req").(*zone_collaborator_proto.ApiListReq) //设置默认页长 if req.Limit == 0 { req.Limit = consts.DefaultPageSize } list, ztpVO, ec := service.DefaultService.ApiGetZoneCollaboratorList(ctx, req) if ec != errcode.ErrCodeZoneCollaboratorSrvOk { logger.Error("ApiGetZoneCollaboratorList fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } //填充媒体切片 mediaFillableList := make([]mediafiller.MediaFillable, len(list)) for i, media := range list { mediaFillableList[i] = media.Account.Avatar } mediafiller.FillList(ctx, mediaFillableList) if ztpVO != nil && ztpVO.Account != nil && ztpVO.Account.Avatar != nil { mediafiller.FillEntity(ctx, ztpVO.Account.Avatar) } data := &zone_collaborator_proto.ApiListData{ List: list, ZoneThirdPartnerVO: ztpVO, Offset: req.Offset + len(list), } if len(list) >= req.Limit { data.More = 1 } ReplyOk(ctx, data) }