Merge pull request 'conflict-feat-IRONFANS-70' (#282) from conflict-feat-IRONFANS-70 into feat-IRONFANS-70

Reviewed-on: http://121.41.31.146:3000/wishpal_ironfan/service/pulls/282
This commit is contained in:
chenhao 2024-04-12 06:43:19 +08:00
commit f841745818
10 changed files with 193 additions and 1 deletions

View File

@ -174,6 +174,21 @@ type ApiListOthersByMidsResp struct {
Data *ApiListOthersByMidsData `json:"data"`
}
// api 列表-查询他人
type ApiListOthersByUserIdReq struct {
base.BaseRequest
UserId *int64 `json:"mid"` //单个查询
}
type ApiListOthersByUserIdData struct {
Account *ApiListOthersVO `json:"account"`
}
type ApiListOthersByUserIdResp struct {
base.BaseResponse
Data *ApiListOthersByUserIdResp `json:"data"`
}
// api 经验增长
type ApiExpIncReq struct {
base.BaseRequest

View File

@ -42,7 +42,9 @@ type ApiListExtVO struct {
WechatContact *string `json:"wechat_contact"`
WechatCoinPrice *int64 `json:"wechat_coin_price"`
Zones []*dbstruct.Zone `json:"zones" bson:"zones"`
Zones []*dbstruct.Zone `json:"zones" bson:"zones"`
IsActiveWithinAWeek *int64 `json:"is_active_within_a_week"` // 7日内空间是否活跃
TimeElapsedSinceTheLastZonesUpdate *int64 `json:"time_elapsed_since_the_last_zones_update"` // 空间最后活跃时间距离现在时间跨度
}
func (vo *ApiListExtVO) GetMid() int64 {
@ -116,3 +118,11 @@ func (vo *ApiListExtVO) CopyZones(zones []*dbstruct.Zone) {
vo.Zones = zones
}
}
func (vo *ApiListExtVO) SetIsActiveWithinAWeek(is_active_within_a_week int64) {
vo.IsActiveWithinAWeek = goproto.Int64(is_active_within_a_week)
}
func (vo *ApiListExtVO) SetDaysElapsedSinceTheLastZonesUpdate(days_elapsed_since_the_last_zones_update int64) {
vo.TimeElapsedSinceTheLastZonesUpdate = goproto.Int64(days_elapsed_since_the_last_zones_update)
}

View File

@ -15,6 +15,8 @@ type StreamerExtVO interface {
CopyPlatforms(platforms *[]*streamerlinkproto.StreamerLinkVO)
CopyUserVas(userVas *dbstruct.UserVasInfo)
CopyZones(zones []*dbstruct.Zone)
SetIsActiveWithinAWeek(is_active_within_a_week int64)
SetDaysElapsedSinceTheLastZonesUpdate(days_elapsed_since_the_last_zones_update int64)
}
// 查询VO类
@ -122,3 +124,11 @@ func (vo *OpListExtVO) CopyUserVas(userVas *dbstruct.UserVasInfo) {
func (vo *OpListExtVO) CopyZones(zones []*dbstruct.Zone) {
}
func (vo *OpListExtVO) SetIsActiveWithinAWeek(is_active_within_a_week int64) {
}
func (vo *OpListExtVO) SetDaysElapsedSinceTheLastZonesUpdate(days_elapsed_since_the_last_zones_update int64) {
}

View File

@ -141,6 +141,25 @@ type OpListByMidResp struct {
Data *OpListByMidData `json:"data"`
}
// op 列表
type ApiListByUserIdFromOutsideReq struct {
base.BaseRequest
UserId int64 `json:"user_id"`
Offset int `json:"offset"`
Limit int `json:"limit"`
}
type ApiListByUserIdFromOutsideData struct {
List []*ApiZoneVO `json:"list"`
Offset int `json:"offset"`
More int `json:"more"`
}
type ApiListByUserIdFromOutsideResp struct {
base.BaseResponse
Data *ApiListByUserIdFromOutsideData `json:"data"`
}
// 空间收银台
type ZoneGetCashierReq struct {
Zid int64 `json:"zid"` // 空间id

View File

@ -14,6 +14,7 @@ type ApiZoneMomentVO struct {
IsSuperfanshipUnlocked int64 `json:"is_superfanship_unlocked"`
IsZoneMomentUnlocked int64 `json:"is_zone_moment_unlocked"`
Expenditure int64 `json:"expenditure"`
IronfanshipPrice int64 `json:"ironfanship_price"`
BuyerCnt int64 `json:"buyer_cnt"` // 动态购买人数
}

View File

@ -220,6 +220,26 @@ func ApiGetAccountListForOthersByMids(ctx *gin.Context) {
ReplyOk(ctx, data)
}
func ApiGetAccountListForOthersByUserId(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*accountproto.ApiListOthersByUserIdReq)
account, ec := service.DefaultService.ApiGetAccountListForOthersByUserId(ctx, req)
if ec != errcode.ErrCodeAccountSrvOk {
logger.Error("ApiGetAccountListOthersByUserId fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
//填充媒体
mediafiller.FillEntity(ctx, account.Avatar)
data := &accountproto.ApiListOthersByUserIdData{
Account: account,
}
ReplyOk(ctx, data)
}
func ApiAccountExpInc(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*accountproto.ApiExpIncReq)
result, ec := service.DefaultService.ApiAccountExpInc(ctx, req)

View File

@ -85,6 +85,7 @@ func Init(r *gin.Engine) {
//apiAccountGroup.POST("list_by_user_id", middleware.JSONParamValidator(accountproto.ApiListByUserIdReq{}), middleware.JwtAuthenticator(), ApiGetAccountListByUserId)
apiAccountGroup.POST("list_others_by_mid", middleware.JSONParamValidator(accountproto.ApiListOthersByMidReq{}), middleware.JwtAuthenticator(), ApiGetAccountListForOthersByMid)
apiAccountGroup.POST("list_others_by_mids", middleware.JSONParamValidator(accountproto.ApiListOthersByMidsReq{}), middleware.JwtAuthenticator(), ApiGetAccountListForOthersByMids)
apiAccountGroup.POST("list_others_by_user_id", middleware.JSONParamValidator(accountproto.ApiListOthersByUserIdReq{}), middleware.JwtAuthenticator(), ApiGetAccountListForOthersByUserId)
apiAccountGroup.POST("exp_inc", middleware.JSONParamValidator(accountproto.ApiExpIncReq{}), middleware.JwtAuthenticator(), ApiAccountExpInc)
apiAccountGroup.POST("cancel", middleware.JSONParamValidator(accountproto.ApiCancelReq{}), middleware.JwtAuthenticator(), ApiCancelAccount)
apiAccountGroup.POST("abort_cancellation", middleware.JSONParamValidator(accountproto.ApiAbortCancellationReq{}), middleware.JwtAuthenticator(), ApiAbortAccountCancellation)
@ -216,6 +217,7 @@ func Init(r *gin.Engine) {
apiZoneGroup.POST("list", middleware.JSONParamValidator(zoneproto.ApiListReq{}), middleware.JwtAuthenticator(), ApiGetZoneList)
apiZoneGroup.POST("list_by_mid", middleware.JSONParamValidator(zoneproto.ApiListByMidReq{}), middleware.JwtAuthenticator(), ApiGetZoneListByMid)
apiZoneGroup.POST("list_by_visitor_mid", middleware.JSONParamValidator(zoneproto.ApiListByVisitorMidReq{}), middleware.JwtAuthenticator(), ApiGetZoneListByVisitorMid)
apiZoneGroup.POST("list_by_user_id_from_outside", middleware.JSONParamValidator(zoneproto.ApiListByUserIdFromOutsideReq{}), ApiGetZoneListByUserIdFromOutside)
// 私密圈动态
apiZoneMomentGroup := r.Group("/api/zone_moment", PrepareToC())

View File

@ -142,3 +142,38 @@ func ApiGetZoneListByMid(ctx *gin.Context) {
}
ReplyOk(ctx, data)
}
func ApiGetZoneListByUserIdFromOutside(ctx *gin.Context) {
req := ctx.MustGet("client_req").(*zoneproto.ApiListByUserIdFromOutsideReq)
//设置默认页长
if req.Limit == 0 {
req.Limit = consts.DefaultPageSize
}
list, ec := service.DefaultService.ApiGetZoneListByUserIdFromOutside(ctx, req)
if ec != errcode.ErrCodeZoneSrvOk {
logger.Error("ApiGetZoneListByUserIdFromOutside 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.Previews
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)
data := &zoneproto.ApiListByMidData{
List: list,
Offset: req.Offset + len(list),
}
if len(list) >= req.Limit {
data.More = 1
}
ReplyOk(ctx, data)
}

View File

@ -517,6 +517,22 @@ func (s *Service) ApiGetAccountListForOthersByMids(ctx *gin.Context, req *accoun
return
}
func (s *Service) ApiGetAccountListForOthersByUserId(ctx *gin.Context, req *accountproto.ApiListOthersByUserIdReq) (vo *accountproto.ApiListOthersVO, ec errcode.ErrCode) {
ec = errcode.ErrCodeAccountSrvOk
account, err := _DefaultAccount.OpListByUserId(ctx, &accountproto.OpListByUserIdReq{
UserId: req.UserId,
})
if err != nil {
logger.Error("OpListByUserId fail, err: %v", err)
ec = errcode.ErrCodeAccountSrvFail
return
}
vo = &accountproto.ApiListOthersVO{}
vo.CopyAccount(account)
return
}
func (s *Service) ApiAccountExpInc(ctx *gin.Context, req *accountproto.ApiExpIncReq) (result *accountproto.ApiExpIncData, ec errcode.ErrCode) {
ec = errcode.ErrCodeAccountSrvOk
@ -2206,6 +2222,56 @@ func (s *Service) ApiGetZoneListByVisitorMid(ctx *gin.Context, req *zoneproto.Ap
return
}
func (s *Service) ApiGetZoneListByUserIdFromOutside(ctx *gin.Context, req *zoneproto.ApiListByUserIdFromOutsideReq) (volist []*zoneproto.ApiZoneVO, ec errcode.ErrCode) {
ec = errcode.ErrCodeZoneSrvOk
volist = make([]*zoneproto.ApiZoneVO, 0)
account, err := _DefaultAccount.OpListByUserId(ctx, &accountproto.OpListByUserIdReq{
UserId: goproto.Int64(req.UserId),
})
if err != nil {
logger.Error("_DefaultAccount OpListByUserId fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeAccountSrvFail
return
}
if account == nil {
return
}
list, err := _DefaultZone.OpListByMid(ctx, &zoneproto.OpListByMidReq{
BaseRequest: req.BaseRequest,
Uid: account.Mid,
Offset: req.Offset,
Limit: req.Limit,
})
if err != nil {
logger.Error("OpListGetZoneList fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeZoneSrvFail
return
}
mid := util.DerefInt64(account.Mid)
streamerExtMap, err := s.utilGetStreamerExtMapByMids(ctx, []int64{mid}, consts.InterfaceType_Api)
if err != nil {
logger.Error("utilGetStreamerExtMapByMids fail, req: %v, err: %v", util.ToJson(req), err)
ec = errcode.ErrCodeStreamerSrvFail
return
}
streamerExt := streamerExtMap[mid].(*streamerproto.ApiListExtVO)
// 填充必要信息
for _, zone := range list {
vo := &zoneproto.ApiZoneVO{
Zone: zone,
StreamerExt: streamerExt,
}
volist = append(volist, vo)
}
return
}
// ZoneMoment
func (s *Service) ApiCreateZoneMoment(ctx *gin.Context, req *zonemomentproto.ApiCreateReq) (ec errcode.ErrCode, acctPunEndTime string) {
ec = errcode.ErrCodeZoneMomentSrvOk

View File

@ -761,6 +761,19 @@ func (s *Service) utilGetStreamerExtMapByMids(ctx *gin.Context, mids []int64, op
streamerExt.CopyPlatforms(&streamerlinkvolist)
streamerExt.CopyUserVas(userVas)
streamerExt.CopyZones(zonesMap[mid])
// 计算空间更新时间距离现在时间跨度
nowTime := time.Now()
for _, zone := range zonesMap[mid] {
lastZoneMomentCreateDay := util.GetDayStartTimeStamp(time.Unix(util.DerefInt64(zone.LastZoneMomentCt), 0))
today := util.GetDayStartTimeStamp(nowTime)
daysElapsedSinceTheLastZonesUpdate := (today - lastZoneMomentCreateDay) / int64(86400) // 24 * 60 * 60 = 86400秒
streamerExt.SetDaysElapsedSinceTheLastZonesUpdate(daysElapsedSinceTheLastZonesUpdate)
if daysElapsedSinceTheLastZonesUpdate <= 7 {
streamerExt.SetIsActiveWithinAWeek(consts.ZoneIsActiveWithinAWeek_Yes)
} else {
streamerExt.SetIsActiveWithinAWeek(consts.ZoneIsActiveWithinAWeek_No)
}
}
streamerExtMap[mid] = streamerExt
}
@ -1426,6 +1439,7 @@ func (s *Service) utilGetApiMomentVOListByIds(ctx *gin.Context, visitorMid int64
func (s *Service) utilFillZonesWithApiVOInfo(ctx *gin.Context, list []*dbstruct.Zone, visitorMid int64) (volist []*zoneproto.ApiZoneVO, err error) {
// 1.获取mids并填充空间基底
volist = make([]*zoneproto.ApiZoneVO, 0)
mids := make([]int64, 0)
midSet := make(map[int64]*dbstruct.Zone)
for _, zone := range list {