From 7b385f395d3ccae13c785a2a4f3bdf772aed1ae9 Mon Sep 17 00:00:00 2001 From: Leufolium Date: Tue, 7 May 2024 16:59:10 +0800 Subject: [PATCH] by Robin at 20240507; set is_hided for zone third partner --- .../proto/zone_third_partner_op.go | 17 ++++++- .../proto/zone_third_partner_vo_op.go | 11 +++++ app/mix/controller/init.go | 5 +++ app/mix/controller/zone_third_partner_op.go | 18 ++++++++ app/mix/dao/mongo.go | 15 +++++++ app/mix/service/logic/zone_third_partner.go | 9 ++++ app/mix/service/service.go | 44 ++++++++++++++++++- 7 files changed, 117 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 3ac35472..1fd1e763 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,10 +54,25 @@ type OpListReq struct { } type OpListData struct { - ZoneThirdPartner *dbstruct.ZoneThirdPartner `json:"zone_third_partner"` + ZoneThirdPartner *ZoneThirdPartnerOpVO `json:"zone_third_partner"` } type OpListResp struct { base.BaseResponse Data *OpListData `json:"data"` } + +// op 更新 +type OpSetIsHidedReq struct { + base.BaseRequest + Zid *int64 `json:"zid"` + IsHided *int64 `json:"is_hided"` +} + +type OpSetIsHidedData struct { +} + +type OpSetIsHidedResp struct { + base.BaseResponse + Data *OpSetIsHidedData `json:"data"` +} 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 d8e69e82..a6afaa6d 100644 --- a/app/mix/controller/init.go +++ b/app/mix/controller/init.go @@ -515,6 +515,11 @@ 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()) + apiZoneThirdPartnerGroup.POST("set_is_hided", middleware.JSONParamValidator(zone_third_partner_proto.OpSetIsHidedReq{}), middleware.JwtAuthenticator(), OpSetIsHidedZoneThirdPartner) + opZoneThirdPartnerGroup.POST("list", middleware.JSONParamValidator(zone_third_partner_proto.ApiListReq{}), 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/controller/zone_third_partner_op.go b/app/mix/controller/zone_third_partner_op.go index 01fb8f3c..ffdb6c13 100644 --- a/app/mix/controller/zone_third_partner_op.go +++ b/app/mix/controller/zone_third_partner_op.go @@ -6,6 +6,7 @@ import ( "service/app/mix/service" "service/bizcommon/util" "service/library/logger" + "service/library/mediafiller" "github.com/gin-gonic/gin" ) @@ -56,8 +57,25 @@ func OpGetZoneThirdPartnerList(ctx *gin.Context) { return } + //填充媒体切片 + if zoneThirdPartner != nil && zoneThirdPartner.Account != nil && zoneThirdPartner.Account.Avatar != nil { + mediafiller.FillEntity(ctx, zoneThirdPartner.Account.Avatar) + } + data := &zone_third_partnerproto.OpListData{ ZoneThirdPartner: zoneThirdPartner, } ReplyOk(ctx, data) } + +func OpSetIsHidedZoneThirdPartner(ctx *gin.Context) { + req := ctx.MustGet("client_req").(*zone_third_partnerproto.OpSetIsHidedReq) + ec := service.DefaultService.OpSetIsHidedZoneThirdPartner(ctx, req) + if ec != errcode.ErrCodeZoneThirdPartnerSrvOk { + logger.Error("OpSetIsHidedZoneThirdPartner fail, req: %v, ec: %v", util.ToJson(req), ec) + ReplyErrCodeMsg(ctx, ec) + return + } + + ReplyOk(ctx, nil) +} diff --git a/app/mix/dao/mongo.go b/app/mix/dao/mongo.go index 607dae7c..c16183f5 100644 --- a/app/mix/dao/mongo.go +++ b/app/mix/dao/mongo.go @@ -4795,6 +4795,21 @@ func (m *Mongo) GetZoneThirdPartnerById(ctx *gin.Context, id int64) (*dbstruct.Z return &one, err } +func (m *Mongo) SetIsHidedForZoneThirdPartner(ctx *gin.Context, req *zone_third_partner_proto.OpSetIsHidedReq) error { + col := m.getColZoneThirdPartner() + up := qmgo.M{ + "$set": qmgo.M{ + "is_hided": util.DerefInt64(req.IsHided), + "ut": time.Now().Unix(), + }, + } + filter := qmgo.M{ + "zid": util.DerefInt64(req.Zid), + } + err := col.UpdateOne(ctx, filter, up) + return err +} + func (m *Mongo) CreateZoneThirdPartnerHis(ctx *gin.Context, zone_third_partner *dbstruct.ZoneThirdPartner) error { col := m.getColZoneThirdPartnerHis() _, err := col.InsertOne(ctx, zone_third_partner) diff --git a/app/mix/service/logic/zone_third_partner.go b/app/mix/service/logic/zone_third_partner.go index 1e425364..64072f13 100644 --- a/app/mix/service/logic/zone_third_partner.go +++ b/app/mix/service/logic/zone_third_partner.go @@ -137,3 +137,12 @@ func (p *ZoneThirdPartner) GetZoneThirdPartnerMapByZids(ctx *gin.Context, zids [ return mp, nil } + +func (p *ZoneThirdPartner) OpSetIsHided(ctx *gin.Context, req *zone_third_partner_proto.OpSetIsHidedReq) error { + err := p.store.SetIsHidedForZoneThirdPartner(ctx, req) + if err != nil { + logger.Error("SetIsHidedZoneThirdPartner fail, err: %v", err) + return err + } + return nil +} diff --git a/app/mix/service/service.go b/app/mix/service/service.go index 6d974ba4..68ec43b2 100644 --- a/app/mix/service/service.go +++ b/app/mix/service/service.go @@ -3803,7 +3803,7 @@ func (s *Service) OpDeleteZoneThirdPartner(ctx *gin.Context, id int64) (ec errco 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 { @@ -3811,6 +3811,48 @@ 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 +} + +func (s *Service) OpSetIsHidedZoneThirdPartner(ctx *gin.Context, req *zone_third_partner_proto.OpSetIsHidedReq) (ec errcode.ErrCode) { + ec = errcode.ErrCodeZoneThirdPartnerSrvOk + err := _DefaultZoneThirdPartner.OpSetIsHided(ctx, req) + if err == qmgo.ErrNoSuchDocuments { + ec = errcode.ErrCodeZoneThirdPartnerNotExist + err = nil + return + } + if err != nil { + logger.Error("OpSetIsHided fail, req: %v, err: %v", util.ToJson(req), err) + ec = errcode.ErrCodeZoneThirdPartnerSrvFail + return + } return }