- 前端:全屏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:
@@ -9,6 +9,27 @@ import (
|
||||
"github.com/gouki/lunar-server/internal/service"
|
||||
)
|
||||
|
||||
// GetWishTrees 获取许愿树列表
|
||||
func GetWishTrees(c *gin.Context) {
|
||||
wishService := service.NewWishService()
|
||||
trees, err := wishService.GetWishTrees()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"code": 500,
|
||||
"msg": "获取许愿树列表失败",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"msg": "success",
|
||||
"data": gin.H{
|
||||
"list": trees,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// GetWishTree 获取许愿树
|
||||
func GetWishTree(c *gin.Context) {
|
||||
treeID, _ := strconv.Atoi(c.DefaultQuery("treeId", "1"))
|
||||
@@ -95,6 +116,29 @@ func CreateWish(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
// GetTreeWishes 获取指定树的许愿列表
|
||||
func GetTreeWishes(c *gin.Context) {
|
||||
treeID, _ := strconv.Atoi(c.Param("id"))
|
||||
|
||||
wishService := service.NewWishService()
|
||||
wishes, err := wishService.GetTreeWishes(uint(treeID))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"code": 500,
|
||||
"msg": "获取许愿列表失败",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": 0,
|
||||
"msg": "success",
|
||||
"data": gin.H{
|
||||
"list": wishes,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// GetWishList 获取许愿列表
|
||||
func GetWishList(c *gin.Context) {
|
||||
treeID, _ := strconv.Atoi(c.DefaultQuery("treeId", "1"))
|
||||
|
||||
Reference in New Issue
Block a user