- 前端:全屏Canvas场景,夜空/云朵/草地/大树 - 前端:丝带系统,支持陀螺仪和麦克风交互 - 前端:弹幕许愿展示 - 前端:多棵树切换(祈福树/姻缘树/事业树) - 后端:新增GET /api/wish/trees获取树列表 - 后端:新增GET /api/wish/tree/:id/wishes获取树许愿 - 后端:WishTree模型新增Type、Sort字段 - 后端:AutoMigrate自动处理表结构变更 - 后端:seedDefaultData自动初始化默认数据 - 数据库:wish_trees表新增type、sort字段
This commit is contained in:
@@ -23,6 +23,15 @@ func NewWishService() *WishService {
|
||||
}
|
||||
}
|
||||
|
||||
// GetWishTrees 获取许愿树列表
|
||||
func (s *WishService) GetWishTrees() ([]*model.WishTree, error) {
|
||||
var trees []*model.WishTree
|
||||
if err := s.db.Where("status = 1").Order("sort ASC, id ASC").Find(&trees).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return trees, nil
|
||||
}
|
||||
|
||||
// GetWishTree 获取许愿树
|
||||
func (s *WishService) GetWishTree(treeID uint) (*model.WishTree, error) {
|
||||
var tree model.WishTree
|
||||
@@ -88,6 +97,18 @@ func (s *WishService) CreateWish(wish *model.Wish) error {
|
||||
return s.db.Create(wish).Error
|
||||
}
|
||||
|
||||
// GetTreeWishes 获取指定树的许愿列表
|
||||
func (s *WishService) GetTreeWishes(treeID uint) ([]*model.Wish, error) {
|
||||
var wishes []*model.Wish
|
||||
if err := s.db.Where("tree_id = ? AND status = 1", treeID).
|
||||
Order("position DESC, created_at DESC").
|
||||
Limit(100).
|
||||
Find(&wishes).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return wishes, nil
|
||||
}
|
||||
|
||||
// GetWishList 获取许愿列表
|
||||
func (s *WishService) GetWishList(treeID uint, page, pageSize int) ([]*model.Wish, int64, error) {
|
||||
var wishes []*model.Wish
|
||||
|
||||
Reference in New Issue
Block a user