refactor: 错误消息脱敏 + 后端 CI

- 新增 utils.InternalMsg:内部错误详情只进服务端日志,对外统一脱敏
  消息,不再向客户端泄露 GORM/SQL 实现细节;九个 controller 的
  err.Error() 出口全部切换
- 新增 .github/workflows/ci.yml:go build/vet/test(backend,go 1.25)
This commit is contained in:
Logan.Li committed 2026-11-01 02:03:26 +08:00
1 parent 1a47dee63d
commit e0cef06234
11 files changed
+92 -49

No files matched your search

@@ -38,7 +38,7 @@ func (ctrl *AuthController) Login(c *gin.Context) {
result, err := ctrl.authService.Login(req)
if err != nil {
utils.LogAuthAction(ctrl.db, c, "login", req.Username, err.Error(), "failure")
c.JSON(http.StatusOK, gin.H{"code": 1, "message": err.Error()})
c.JSON(http.StatusOK, gin.H{"code": 1, "message": utils.InternalMsg(err)})
return
}
@@ -52,7 +52,7 @@ func (ctrl *AuthController) Me(c *gin.Context) {
userInfo, err := ctrl.authService.GetCurrentUser(userID.(uint))
if err != nil {
c.JSON(http.StatusOK, gin.H{"code": 1, "message": err.Error()})
c.JSON(http.StatusOK, gin.H{"code": 1, "message": utils.InternalMsg(err)})
return
}
@@ -73,7 +73,7 @@ func (ctrl *AuthController) ChangePassword(c *gin.Context) {
}
if err := ctrl.authService.ChangePassword(userID.(uint), req); err != nil {
c.JSON(http.StatusOK, gin.H{"code": 1, "message": err.Error()})
c.JSON(http.StatusOK, gin.H{"code": 1, "message": utils.InternalMsg(err)})
return
}