feat: 个人中心发布
This commit is contained in:
@@ -45,3 +45,29 @@ func (s *UserProfileService) ProfileDetail(userId string) (plant.UserProfile, er
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// MyStars 我的收藏
|
||||
func (s *UserProfileService) MyStars(req plantReq.StarsPageReq, userId string) (list interface{}, total int64, err error) {
|
||||
limit := req.PageSize
|
||||
offset := req.PageSize * (req.Current - 1)
|
||||
db := global.DB.Model(&plant.UserStar{}).Preload("Wiki", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Preload("ImgList", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Order("created_at desc")
|
||||
})
|
||||
}).Preload("Post", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Preload("ImgList", func(db *gorm.DB) *gorm.DB {
|
||||
return db.Order("created_at desc")
|
||||
})
|
||||
})
|
||||
var stars []*plant.UserStar
|
||||
db = db.Where("user_id = ?", userId)
|
||||
if req.Class != 0 {
|
||||
db = db.Where("type = ?", req.Class) //1.百科 //2.社交动态
|
||||
}
|
||||
err = db.Count(&total).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = db.Limit(limit).Offset(offset).Order("created_at desc").Find(&stars).Error
|
||||
return stars, total, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user