Merge branch 'feat-IRONFANS-250-Robin' into conf-250

This commit is contained in:
Robin 2024-12-10 14:44:45 +08:00
commit 1cee56614f
3 changed files with 46 additions and 2 deletions

View File

@ -10,6 +10,8 @@ type ActivityHotApiVO struct {
Title string `json:"title" bson:"title"` // 标题
Text string `json:"text" bson:"text"` // 文字内容
Hyperlinks []*dbstruct.Hyperlink `json:"hyperlinks" bson:"hyperlinks"` // 跳转链接
Gender int64 `json:"gender" bson:"gender"` // 性别
Tag []string `json:"tag" bson:"tag"` // 标签
}
func NewActivityHotApiVO() *ActivityHotApiVO {
@ -40,11 +42,23 @@ func (vo *ActivityHotApiVO) CopyAccount(account *dbstruct.Account) *ActivityHotA
if account == nil {
return vo
}
if vo.Mid == 0 {
vo.Mid = account.GetMid()
}
vo.Image = account.Avatar
vo.Title = account.GetName()
return vo
}
func (vo *ActivityHotApiVO) CopyStreamer(streamer *dbstruct.Streamer) *ActivityHotApiVO {
if streamer == nil {
return vo
}
vo.Gender = streamer.GetGender()
vo.Tag = streamer.GetTag()
return vo
}
func (vo *ActivityHotApiVO) CopyHyperlinks(getFunc func(mid int64) []*dbstruct.Hyperlink) *ActivityHotApiVO {
if getFunc == nil {
return vo

View File

@ -2405,6 +2405,12 @@ func (s *Service) utilFillActivityHotVO(ctx *gin.Context, activityHotMp map[int6
return make([]*activity_hot_proto.ActivityHotApiVO, 0), err
}
streamerMp, err := _DefaultStreamer.GetStreamerMapByMids(ctx, mids)
if err != nil {
logger.Error("GetStreamerMapByMids failed, err: %v", err)
return make([]*activity_hot_proto.ActivityHotApiVO, 0), err
}
zoneMp, err := _DefaultZone.GetZoneMapByMids(ctx, mids)
if err != nil {
logger.Error("GetZoneMapByMids failed, err: %v", err)
@ -2412,7 +2418,7 @@ func (s *Service) utilFillActivityHotVO(ctx *gin.Context, activityHotMp map[int6
}
for mid, activityHot := range activityHotMp {
vo := activity_hot_proto.NewActivityHotApiVO().CopyActivityHot(activityHot)
vo := activity_hot_proto.NewActivityHotApiVO().CopyActivityHot(activityHot).CopyStreamer(streamerMp[mid])
if activityHot.Image == nil { // 主图为空,填充头像
vo.Image = acctMp[mid].Avatar
}
@ -2484,8 +2490,15 @@ func (s *Service) utilCompleteActivityHotList(ctx *gin.Context, existedMp map[in
return make([]*activity_hot_proto.ActivityHotApiVO, 0), err
}
// 补足stremaer表信息
streamerMp, err := _DefaultStreamer.GetStreamerMapByMids(ctx, selectedMids)
if err != nil {
logger.Error("GetStreamerMapByMids failed, err: %v", err)
return make([]*activity_hot_proto.ActivityHotApiVO, 0), err
}
for mid, vo := range voMap {
vo.CopyAccount(acctMp[mid]).CopyHyperlinks(s.utilGetZoneHyperlinks)
vo.CopyAccount(acctMp[mid]).CopyStreamer(streamerMp[mid]).CopyHyperlinks(s.utilGetZoneHyperlinks)
}
return volist, nil

View File

@ -65,24 +65,34 @@ func (p *Streamer) GetAge() int64 {
return *p.Age
}
func (p *Streamer) GetGender() int64 {
if p == nil || p.Gender == nil {
return 0
}
return *p.Gender
}
func (p *Streamer) GetHeight() int64 {
if p == nil || p.Height == nil {
return 0
}
return *p.Height
}
func (p *Streamer) GetWeight() int64 {
if p == nil || p.Weight == nil {
return 0
}
return *p.Weight
}
func (p *Streamer) GetConstellation() string {
if p == nil || p.Constellation == nil {
return ""
}
return *p.Constellation
}
func (p *Streamer) GetCity() string {
if p == nil || p.City == nil {
return ""
@ -96,3 +106,10 @@ func (p *Streamer) GetWechatContact() string {
}
return *p.WechatContact
}
func (p *Streamer) GetTag() []string {
if p == nil || p.Tag == nil {
return make([]string, 0)
}
return *p.Tag
}