From 169a34247f9e2d48ac3dd630497285d3a8853bcc Mon Sep 17 00:00:00 2001 From: Leufolium Date: Tue, 21 May 2024 18:26:30 +0800 Subject: [PATCH] by Robin at 20240521 --- .../proto/zone_third_partner_op.go | 2 +- .../proto/zone_third_partner_vo_op.go | 11 ++++++++ app/mix/controller/init.go | 7 +++++ app/mix/service/service.go | 28 ++++++++++++++++++- 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 api/proto/zone_third_partner/proto/zone_third_partner_vo_op.go diff --git a/api/proto/zone_third_partner/proto/zone_third_partner_op.go b/api/proto/zone_third_partner/proto/zone_third_partner_op.go index dec0c20b..736e6020 100644 --- a/api/proto/zone_third_partner/proto/zone_third_partner_op.go +++ b/api/proto/zone_third_partner/proto/zone_third_partner_op.go @@ -54,7 +54,7 @@ type OpListReq struct { } type OpListData struct { - ZoneThirdPartner *dbstruct.ZoneThirdPartner `json:"zone_third_partner"` + ZoneThirdPartner *ZoneThirdPartnerOpVO `json:"zone_third_partner"` } type OpListResp struct { diff --git a/api/proto/zone_third_partner/proto/zone_third_partner_vo_op.go b/api/proto/zone_third_partner/proto/zone_third_partner_vo_op.go new file mode 100644 index 00000000..15fdfc91 --- /dev/null +++ b/api/proto/zone_third_partner/proto/zone_third_partner_vo_op.go @@ -0,0 +1,11 @@ +package proto + +import ( + accountproto "service/api/proto/account/proto" + "service/dbstruct" +) + +type ZoneThirdPartnerOpVO struct { + *dbstruct.ZoneThirdPartner + Account *accountproto.OpListOthersVO `json:"third_partner_account"` +} diff --git a/app/mix/controller/init.go b/app/mix/controller/init.go index 280caffa..8064b4e6 100644 --- a/app/mix/controller/init.go +++ b/app/mix/controller/init.go @@ -513,6 +513,13 @@ func Init(r *gin.Engine) { opZoneMomentGroup.POST("head", middleware.JSONParamValidator(zonemomentproto.OpHeadReq{}), middleware.JwtAuthenticator(), OpHeadZoneMoment) opZoneMomentGroup.POST("set_private", middleware.JSONParamValidator(zonemomentproto.OpSetPrivateReq{}), middleware.JwtAuthenticator(), OpSetPrivateZoneMoment) + // 空间代运营表 + opZoneThirdPartnerGroup := r.Group("/op/zone_third_partner", PrepareOp()) + opZoneThirdPartnerGroup.POST("create", middleware.JSONParamValidator(zone_third_partner_proto.OpCreateReq{}), middleware.JwtAuthenticator(), OpCreateZoneThirdPartner) + opZoneThirdPartnerGroup.POST("update", middleware.JSONParamValidator(zone_third_partner_proto.OpUpdateReq{}), middleware.JwtAuthenticator(), OpUpdateZoneThirdPartner) + opZoneThirdPartnerGroup.POST("delete", middleware.JSONParamValidator(zone_third_partner_proto.OpDeleteReq{}), middleware.JwtAuthenticator(), OpDeleteZoneThirdPartner) + opZoneThirdPartnerGroup.POST("list", middleware.JSONParamValidator(zone_third_partner_proto.OpListReq{}), middleware.JwtAuthenticator(), OpGetZoneThirdPartnerList) + // 视频审核callback extVideoModerationGroup := r.Group("/ext/video_moderation") extVideoModerationGroup.POST("callback", middleware.FORMParamValidator(video_moderation_proto.ExtVideoModerationReq{}), VideoModerationCallback) diff --git a/app/mix/service/service.go b/app/mix/service/service.go index bcbd0826..44fed35c 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -3835,7 +3835,7 @@ func (s *Service) OpDeleteZoneThirdPartner(ctx *gin.Context, zid int64) (ec errc return } -func (s *Service) OpGetZoneThirdPartnerList(ctx *gin.Context, req *zone_third_partner_proto.OpListReq) (zoneThirdPartner *dbstruct.ZoneThirdPartner, ec errcode.ErrCode) { +func (s *Service) OpGetZoneThirdPartnerList(ctx *gin.Context, req *zone_third_partner_proto.OpListReq) (vo *zone_third_partner_proto.ZoneThirdPartnerOpVO, ec errcode.ErrCode) { ec = errcode.ErrCodeZoneThirdPartnerSrvOk zoneThirdPartner, err := _DefaultZoneThirdPartner.OpList(ctx, req) if err != nil { @@ -3843,6 +3843,32 @@ func (s *Service) OpGetZoneThirdPartnerList(ctx *gin.Context, req *zone_third_pa ec = errcode.ErrCodeZoneThirdPartnerSrvFail return } + if zoneThirdPartner == nil { + vo = nil + return + } + + acct, err := _DefaultAccount.OpListByMid(ctx, &accountproto.OpListByMidReq{ + Mid: zoneThirdPartner.ThirdPartnerMid, + }) + if err != nil { + logger.Error("_DefaultAccount OpListByMid fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeAccountSrvFail + return + } + if acct == nil { + logger.Error("No account entity was found, req: %v", util.ToJson(req)) + ec = errcode.ErrCodeAccountNotExist + return + } + acctVO := &accountproto.OpListOthersVO{} + acctVO.CopyAccount(acct) + + vo = &zone_third_partner_proto.ZoneThirdPartnerOpVO{ + ZoneThirdPartner: zoneThirdPartner, + Account: acctVO, + } + return }