feat: 小程序演示版改造 + 服务端安全加固
Build and Publish Commercial Web / build (push) Failing after 25s
Publish Mini Program Dev Version / publish (push) Successful in 1m9s
Build and Publish Server / build (push) Failing after 6m42s

- 许愿树移除付费许愿/商品选择/微信支付调用,全部走免费许愿
- 许愿发布前接入微信 msgSecCheck v2 内容安全检测(access_token 内存缓存)
- 许愿字数限制改为按字符计算(中文按 1 字计)
- 占卜页改名「民俗趣算」并弱化「算命」措辞,占卜/每日运势页加文化声明
- 生产环境 JWT_SECRET 缺失或为默认值/不足 32 位时拒绝启动

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
gouki
2026-10-18 21:25:24 +00:00
co-authored by Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent 12fa2b0d19
commit 51d1a1999f
11 changed files with 238 additions and 152 deletions
+17 -2
View File
@@ -9,6 +9,9 @@ import (
"github.com/gouki/lunar-server/internal/service"
)
// 内容安全检测服务(微信 msgSecCheck),access_token 内部缓存
var securityService = service.NewContentSecurityService()
// GetWishTrees 获取许愿树列表
func GetWishTrees(c *gin.Context) {
wishService := service.NewWishService()
@@ -79,12 +82,12 @@ func CreateWish(c *gin.Context) {
return
}
// 检查内容长度
// 检查内容长度(按字符数,中文按 1 字计)
maxLength := 20
if req.Type == "paid" {
maxLength = 100
}
if len(req.Content) > maxLength {
if len([]rune(req.Content)) > maxLength {
c.JSON(http.StatusBadRequest, gin.H{
"code": 400,
"msg": "内容长度超过限制",
@@ -92,6 +95,18 @@ func CreateWish(c *gin.Context) {
return
}
// 内容安全检测(微信 msgSecCheck):UGC 内容发布前必须过检
userService := service.NewUserService()
if user, err := userService.GetUserByID(userID.(uint)); err == nil && user != nil {
if err := securityService.CheckText(user.OpenID, req.Content); err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"code": 400,
"msg": "内容未通过安全检测:" + err.Error(),
})
return
}
}
wishService := service.NewWishService()
wish := &model.Wish{
UserID: userID.(uint),