Merge pull request 'by Robin at 20241111' (#795) from feat-IRONFANS-238-Robin into main

Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/795
This commit is contained in:
chenhao 2024-11-13 17:49:10 +08:00
commit da1f53f171
11 changed files with 203 additions and 0 deletions

View File

@ -77,6 +77,7 @@ var ErrCodeMsgMap = map[ErrCode]string{
ErrCodeMomentNotAStreamer: "当前账号无发帖权限",
// ErrCodeMomentBlockedFromCreatingMoment: "功能封禁中,截止时间:%s",
// ErrCodeMomentBlockedFromCreatingMomentPermanently: "该功能已被永久封禁",
ErrCodeMomentNotHisOwn: "该动态非您创建",
ErrCodeFootPrintSrvFail: "足迹服务错误",
ErrCodeFootPrintNotExist: "足迹不存在",
@ -198,6 +199,7 @@ var ErrCodeMsgMap = map[ErrCode]string{
ErrCodePaidZoneMomentCreateTimesReachedUpperbound: "付费动态不能多于免费动态",
ErrCodeZoneMomentImagesNotEnoughForEncryption: "预览图片数不得大于等于上传图片数",
ErrCodeZoneMomentStatusNotPublic: "私密圈动态状态不为公开!",
ErrCodeZoneMomentNotHisOwn: "该空间动态非您创建",
ErrCodeZoneMomentThumbsUpSrvFail: "私密圈点赞服务错误",
ErrCodeZoneMomentThumbsUpNotExist: "私密圈点赞不存在",
@ -355,6 +357,7 @@ const (
ErrCodeMomentNotAStreamer ErrCode = -8003 // 普通用户禁止发帖
// ErrCodeMomentBlockedFromCreatingMoment ErrCode = -8003 // 动态创建已被封禁
// ErrCodeMomentBlockedFromCreatingMomentPermanently ErrCode = -8004 // 动态创建已被永久封禁
ErrCodeMomentNotHisOwn ErrCode = -8005 // 动态非主播创建
// FootPrint: 9xxx
ErrCodeFootPrintSrvOk ErrCode = ErrCodeOk
@ -527,6 +530,7 @@ const (
ErrCodePaidZoneMomentCreateTimesReachedUpperbound ErrCode = -34003 // 私密圈付费动态创建次数已达上限
ErrCodeZoneMomentImagesNotEnoughForEncryption ErrCode = -34004 // 私密圈图片贴图片数量少于可预览图片数
ErrCodeZoneMomentStatusNotPublic ErrCode = -34005 // 私密圈动态非公开状态
ErrCodeZoneMomentNotHisOwn ErrCode = -34006 // 私密圈动态非主播创建
// ZoneMomentThumbsUp: 35xxx
ErrCodeZoneMomentThumbsUpSrvOk ErrCode = ErrCodeOk

View File

@ -156,3 +156,18 @@ type ApiRecommListResp struct {
base.BaseResponse
Data *ApiRecommListData `json:"data"`
}
// op 列表-创建者使用ids查询
type ApiListByIdsFromCreaterReq struct {
base.BaseRequest
Ids []int64 `json:"ids"` // ids
}
type ApiListByIdsFromCreaterData struct {
List []*ApiMomentVO `json:"list"`
}
type ApiListByIdsFromCreaterResp struct {
base.BaseResponse
Data *ApiListByIdsFromCreaterData `json:"data"`
}

View File

@ -62,3 +62,11 @@ func (p *ApiThumbsUpReq) ProvideNotNullValue() (params []*validator.JsonParam) {
return
}
func (p *ApiListByIdsFromCreaterReq) ProvideNotNullValue() (params []*validator.JsonParam) {
params = make([]*validator.JsonParam, 0)
params = append(params, validator.NewInt64SliceParam("请确认待查询动态的ids", p.Ids))
return
}

View File

@ -81,3 +81,11 @@ func (p *ApiHeadReq) ProvideNotNullValue() (params []*validator.JsonParam) {
return
}
func (p *ApiListByIdsFromCreaterReq) ProvideNotNullValue() (params []*validator.JsonParam) {
params = make([]*validator.JsonParam, 0)
params = append(params, validator.NewInt64SliceParam("请确认待查询空间动态的ids", p.Ids))
return
}

View File

@ -163,3 +163,18 @@ type ApiListStatisticsByCreaterMidResp struct {
base.BaseResponse
Data *ApiListStatisticsByCreaterMidData `json:"data"`
}
// op 列表-创建者使用ids查询
type ApiListByIdsFromCreaterReq struct {
base.BaseRequest
Ids []int64 `json:"ids"` // ids
}
type ApiListByIdsFromCreaterData struct {
List []*ApiZoneMomentVO `json:"list"`
}
type ApiListByIdsFromCreaterResp struct {
base.BaseResponse
Data *ApiListByIdsFromCreaterData `json:"data"`
}

View File

@ -128,6 +128,7 @@ func Init(r *gin.Engine) {
apiMomentGroup.POST("list_by_ids", middleware.JSONParamValidator(momentproto.ApiListByIdsReq{}), middleware.JwtAuthenticator(), ApiGetMomentListByIds)
apiMomentGroup.POST("recomm_list", middleware.JSONParamValidator(momentproto.ApiRecommListReq{}), middleware.JwtAuthenticator(), ApiGetMomentRecommList)
apiMomentGroup.POST("is_moment_image_encrypt_enabled", middleware.JSONParamValidator(base.BaseRequest{}), OpGetIsMomentImageEncryptEnabled)
apiMomentGroup.POST("list_by_ids_from_creater", middleware.JSONParamValidator(momentproto.ApiListByIdsFromCreaterReq{}), middleware.JwtAuthenticator(), ApiGetMomentListByIdsFromCreater)
// 足迹
// apiFootPrintGroup := r.Group("/api/footprint", PrepareToC())
@ -266,6 +267,7 @@ func Init(r *gin.Engine) {
apiZoneMomentGroup.POST("thumbs_up", middleware.JSONParamValidator(zonemomentproto.ApiZoneMomentThumbsUpReq{}), middleware.JwtAuthenticator(), ApiZoneMomentThumbsUpMoment)
apiZoneMomentGroup.POST("head", middleware.JSONParamValidator(zonemomentproto.ApiHeadReq{}), middleware.JwtAuthenticator(), ApiHeadZoneMoment)
apiZoneMomentGroup.POST("list_statistics_by_creater_mid", middleware.JSONParamValidator(zonemomentproto.ApiListStatisticsByCreaterMidReq{}), middleware.JwtAuthenticator(), ApiGetZoneMomentStatisticsByCreaterMid)
apiZoneMomentGroup.POST("list_by_ids_from_creater", middleware.JSONParamValidator(zonemomentproto.ApiListByIdsFromCreaterReq{}), middleware.JwtAuthenticator(), ApiGetZoneMomentListByIdsFromCreater)
// 空间对话
apiZoneSessionGroup := r.Group("/api/zone_session", PrepareToC())

View File

@ -215,3 +215,27 @@ func ApiGetMomentRecommList(ctx *gin.Context) {
}
ReplyOk(ctx, data)
}
func ApiGetMomentListByIdsFromCreater(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*momentproto.ApiListByIdsFromCreaterReq)
list, ec := service.DefaultService.ApiGetMomentListByIdsFromCreater(ctx, req)
if ec != errcode.ErrCodeMomentSrvOk {
logger.Error("ApiGetMomentListByIdsFromCreater 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.MediaComp
}
mediafiller.FillList(ctx, mediaFillableList)
data := &momentproto.ApiListByIdsFromCreaterData{
List: list,
}
ReplyOk(ctx, data)
}

View File

@ -204,3 +204,31 @@ func ApiGetZoneMomentStatisticsByCreaterMid(ctx *gin.Context) {
ReplyOk(ctx, data)
}
func ApiGetZoneMomentListByIdsFromCreater(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*zonemomentproto.ApiListByIdsFromCreaterReq)
list, ec := service.DefaultService.ApiGetZoneMomentListByIdsFromCreater(ctx, req)
if ec != errcode.ErrCodeZoneMomentSrvOk {
logger.Error("ApiGetZoneMomentListByIdsFromCreater fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
objectMediaNum := 5 // 单个空间贴服务总共5个媒体类
mediaFillableList := make([]mediafiller.MediaFillable, len(list)*objectMediaNum)
for i, vo := range list {
mediaFillableList[objectMediaNum*i+0] = vo.ZoneMoment.MediaComp
mediaFillableList[objectMediaNum*i+1] = vo.StreamerExt.Cover
mediaFillableList[objectMediaNum*i+2] = vo.StreamerExt.Shorts
mediaFillableList[objectMediaNum*i+3] = vo.StreamerExt.Album
mediaFillableList[objectMediaNum*i+4] = vo.StreamerExt.Avatar
}
mediafiller.FillList(ctx, mediaFillableList)
service.DefaultService.UtilEncryptVideosForZoneMomentVOs(ctx, list)
data := &zonemomentproto.ApiListByIdsFromCreaterData{
List: list,
}
ReplyOk(ctx, data)
}

View File

@ -2446,6 +2446,46 @@ func (s *Service) ApiGetMomentListByIds(ctx *gin.Context, req *momentproto.ApiLi
return
}
func (s *Service) ApiGetMomentListByIdsFromCreater(ctx *gin.Context, req *momentproto.ApiListByIdsFromCreaterReq) (volist []*momentproto.ApiMomentVO, ec errcode.ErrCode) {
ec = errcode.ErrCodeMomentSrvOk
// 1.根据ids查询得到这一轮的动态基底
list, err := _DefaultMoment.GetByIds(ctx, req.Ids)
if err != nil {
logger.Error("ApiGetMomentListByIds fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneMomentSrvFail
return
}
// 2.通过mid获取主播信息map
ignoreMap := make(map[string]bool)
ignoreMap["zones"] = true
streamerExtMap, err := s.utilGetStreamerExtMapByMids(ctx, []int64{req.GetBaseRequest().Mid}, consts.InterfaceType_Api, ignoreMap)
if err != nil {
logger.Error("utilGetStreamerExtMapByMids fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeStreamerSrvFail
return
}
streamerExt := streamerExtMap[req.GetBaseRequest().Mid]
volist = make([]*momentproto.ApiMomentVO, 0)
// 3.填充所有信息
for _, moment := range list {
if moment.GetMid() != req.GetBaseRequest().Mid {
volist, ec = make([]*momentproto.ApiMomentVO, 0), errcode.ErrCodeMomentNotHisOwn
return
}
vo := &momentproto.ApiMomentVO{
Moment: moment,
}
// 主播信息
vo.CopyStreamerExt(streamerExt)
volist = append(volist, vo)
}
return
}
func (s *Service) ApiThumbsUpMoment(ctx *gin.Context, req *momentproto.ApiThumbsUpReq) (ec errcode.ErrCode) {
ec = errcode.ErrCodeMomentSrvOk
@ -3491,6 +3531,47 @@ func (s *Service) ApiGetZoneMomentStatisticsByCreaterMid(ctx *gin.Context, req *
return
}
func (s *Service) ApiGetZoneMomentListByIdsFromCreater(ctx *gin.Context, req *zonemomentproto.ApiListByIdsFromCreaterReq) (volist []*zonemomentproto.ApiZoneMomentVO, ec errcode.ErrCode) {
ec = errcode.ErrCodeZoneMomentSrvOk
// 1.根据ids查询得到这一轮的动态基底
list, err := _DefaultZoneMoment.GetByIds(ctx, req.Ids)
if err != nil {
logger.Error("ApiGetZoneMomentListByIds fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneMomentSrvFail
return
}
// 2.通过mid获取主播信息map
ignoreMap := make(map[string]bool)
ignoreMap["zones"] = true
streamerExtMap, err := s.utilGetStreamerExtMapByMids(ctx, []int64{req.GetBaseRequest().Mid}, consts.InterfaceType_Api, ignoreMap)
if err != nil {
logger.Error("utilGetStreamerExtMapByMids fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeStreamerSrvFail
return
}
streamerExt := streamerExtMap[req.GetBaseRequest().Mid]
volist = make([]*zonemomentproto.ApiZoneMomentVO, 0)
// 3.填充所有信息
for _, zonemoment := range list {
if zonemoment.GetMid() != req.GetBaseRequest().Mid {
volist, ec = make([]*zonemomentproto.ApiZoneMomentVO, 0), errcode.ErrCodeZoneMomentNotHisOwn
return
}
vo := &zonemomentproto.ApiZoneMomentVO{
ZoneMoment: zonemoment,
}
vo.IsZoneMomentUnlocked = consts.IsZoneMomentUnlocked_Yes
// 主播信息
vo.CopyStreamerExt(streamerExt)
volist = append(volist, vo)
}
return
}
func (s *Service) ApiZoneMomentThumbsUpMoment(ctx *gin.Context, req *zonemomentproto.ApiZoneMomentThumbsUpReq) (ec errcode.ErrCode) {
ec = errcode.ErrCodeZoneMomentSrvOk

View File

@ -177,3 +177,12 @@ func (p *Moment) GetMomentStatInfoList(ctx *gin.Context, st, et int64) ([]*dbstr
return list, nil
}
func (p *Moment) GetByIds(ctx *gin.Context, ids []int64) ([]*dbstruct.Moment, error) {
list, err := p.store.GetMomentListByIds(ctx, ids)
if err != nil {
logger.Error("GetMomentListByIds fail, err: %v", err)
return make([]*dbstruct.Moment, 0), err
}
return list, nil
}

View File

@ -198,3 +198,12 @@ func (p *ZoneMoment) GetZoneMomentStatInfoList(ctx *gin.Context, st, et int64) (
return list, nil
}
func (p *ZoneMoment) GetByIds(ctx *gin.Context, ids []int64) ([]*dbstruct.ZoneMoment, error) {
list, err := p.store.GetZoneMomentByIds(ctx, ids)
if err != nil {
logger.Error("GetZoneMomentListByIds fail, err: %v", err)
return make([]*dbstruct.ZoneMoment, 0), err
}
return list, nil
}