Commit d3f8d8fe authored by hujiebin's avatar hujiebin

Update gift.go

parent 7b53b832
......@@ -6,22 +6,28 @@ import (
"git.hilo.cn/hilo-common/resource/mysql"
"github.com/gin-gonic/gin"
"hilo-user/cv/user_cv"
"hilo-user/domain/model/group_m"
"hilo-user/domain/model/recommend_m"
"hilo-user/domain/model/user_m"
"hilo-user/resp"
)
type RecommendUser struct {
*user_cv.UserTiny `json:",inline"`
CurrentRoom string `json:"currentRoom"` // 当前用户所在房间(产品叫“群组”)
}
// @Tags 用户推荐
// @Summary 推荐最近送礼的50人,最近12小时赠送礼物大于100k的用户
// @Param token header string true "token"
// @Success 200 {object} []user_cv.UserTiny
// @Success 200 {object} []RecommendUser
// @Router /v1/recommend/user/gift [get]
func UserRecommendGift(c *gin.Context) (*mycontext.MyContext, error) {
myContext := mycontext.CreateMyContext(c.Keys)
model := domain.CreateModelContext(myContext)
// 获取推荐
recommendUser := recommend_m.GetPastTop50SendGiftUsers(model)
var response = make([]*user_cv.UserTiny, 0)
var response = make([]RecommendUser, 0)
if len(recommendUser) <= 0 {
resp.ResponseOk(c, response)
return myContext, nil
......@@ -34,8 +40,12 @@ func UserRecommendGift(c *gin.Context) (*mycontext.MyContext, error) {
if err != nil {
return myContext, err
}
rooms, err := group_m.RoomLivingUserIdFilter(model, userIds)
if err != nil {
return nil, err
}
for _, v := range recommendUser {
response = append(response, user_cv.UserToTiny(users[v.SendUserId]))
response = append(response, RecommendUser{user_cv.UserToTiny(users[v.SendUserId]), rooms[v.SendUserId]})
}
resp.ResponseOk(c, response)
return myContext, nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment