新增技术文档,详细描述了项目的技术栈、配置、鉴权与安全、数据层等内容。同时,更新小程序页面以支持收益数据的加载与刷新功能,优化用户体验。新增收益接口以返回用户的累计收益和可提现金额,并调整相关逻辑以确保数据准确性。

This commit is contained in:
乘风
2026-02-11 15:06:59 +08:00
parent dfc1fd4e2d
commit dc3cba1c39
125 changed files with 449 additions and 27206 deletions

View File

@@ -23,6 +23,7 @@ func BookAllChapters(c *gin.Context) {
}
// BookChapterByID GET /api/book/chapter/:id
// 同时兼容小程序:将 content/chapterTitle/partTitle 等放到顶层,便于 miniprogram 直接 res.content
func BookChapterByID(c *gin.Context) {
id := c.Param("id")
if id == "" {
@@ -38,7 +39,23 @@ func BookChapterByID(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"success": false, "error": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"success": true, "data": ch})
// 返回格式:顶层携带 content/chapterTitle/partTitle 等,供小程序 read 页直接使用
out := gin.H{
"success": true,
"data": ch,
"content": ch.Content,
"chapterTitle": ch.ChapterTitle,
"partTitle": ch.PartTitle,
"id": ch.ID,
"sectionTitle": ch.SectionTitle,
}
if ch.IsFree != nil {
out["isFree"] = *ch.IsFree
}
if ch.Price != nil {
out["price"] = *ch.Price
}
c.JSON(http.StatusOK, out)
}
// BookChapters GET/POST/PUT/DELETE /api/book/chapters与 app/api/book/chapters 一致,用 GORM