docs: add false completion prevention rules and fix swagger gaps

Changes:
- Add FALSE_COMPLETION_PREVENTION.md documenting false completion patterns
- Add integrity check script (scripts/check-integrity.sh) for automated verification
- Fix swagger annotation gaps in 3 handlers (+10 annotations):
  - password_reset_handler.go: +4 annotations
  - totp_handler.go: +4 annotations
  - log_handler.go: +2 annotations
- Define IntegrationRedisSuite type for Redis integration tests
- Update QUALITY_STANDARD.md with swagger completeness and response format requirements
- Update PROJECT_EXPERIENCE_SUMMARY.md with new learnings on false completion

Integrity check now validates:
- Swagger annotation completeness per handler
- Response format uniformity (with OAuth whitelist)
- Test infrastructure type definitions
- Repository test coverage
This commit is contained in:
2026-04-11 23:38:43 +08:00
parent 339c740365
commit 4193b46b5f
8 changed files with 585 additions and 2 deletions

View File

@@ -55,6 +55,15 @@ func (h *PasswordResetHandler) ForgotPassword(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"code": 0, "message": "password reset email sent"})
}
// ValidateResetToken 验证密码重置 Token
// @Summary 验证密码重置 Token
// @Description 验证密码重置链接中的 Token 是否有效
// @Tags 密码重置
// @Produce json
// @Param token query string true "重置 Token"
// @Success 200 {object} Response{data=ValidateTokenResponse} "Token验证结果"
// @Failure 400 {object} Response "请求参数错误"
// @Router /api/v1/auth/password/validate [get]
func (h *PasswordResetHandler) ValidateResetToken(c *gin.Context) {
token := c.Query("token")
if token == "" {
@@ -71,6 +80,16 @@ func (h *PasswordResetHandler) ValidateResetToken(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"code": 0, "message": "success", "data": gin.H{"valid": valid}})
}
// ResetPassword 重置密码
// @Summary 重置密码
// @Description 使用 Token 重置密码
// @Tags 密码重置
// @Accept json
// @Produce json
// @Param request body ResetPasswordRequest true "重置请求"
// @Success 200 {object} Response "密码重置成功"
// @Failure 400 {object} Response "请求参数错误"
// @Router /api/v1/auth/password/reset [post]
func (h *PasswordResetHandler) ResetPassword(c *gin.Context) {
var req struct {
Token string `json:"token" binding:"required"`
@@ -95,7 +114,17 @@ type ForgotPasswordByPhoneRequest struct {
Phone string `json:"phone" binding:"required"`
}
// ForgotPasswordByPhone 发送短信验证码
// ForgotPasswordByPhone 发送短信验证码(忘记密码)
// @Summary 发送短信验证码(忘记密码)
// @Description 向绑定的手机号发送短信验证码用于重置密码
// @Tags 密码重置
// @Accept json
// @Produce json
// @Param request body ForgotPasswordByPhoneRequest true "手机号"
// @Success 200 {object} Response "验证码发送成功"
// @Failure 400 {object} Response "请求参数错误"
// @Failure 503 {object} Response "短信服务未配置"
// @Router /api/v1/auth/password/sms/forgot [post]
func (h *PasswordResetHandler) ForgotPasswordByPhone(c *gin.Context) {
if h.smsService == nil {
c.JSON(http.StatusServiceUnavailable, gin.H{"code": 503, "message": "SMS service not configured"})
@@ -142,6 +171,17 @@ type ResetPasswordByPhoneRequest struct {
}
// ResetPasswordByPhone 通过短信验证码重置密码
// @Summary 通过短信验证码重置密码
// @Description 使用短信验证码重置登录密码
// @Tags 密码重置
// @Accept json
// @Produce json
// @Param request body ResetPasswordByPhoneRequest true "重置请求"
// @Success 200 {object} Response "密码重置成功"
// @Failure 400 {object} Response "请求参数错误"
// @Failure 401 {object} Response "验证码错误"
// @Failure 503 {object} Response "短信服务未配置"
// @Router /api/v1/auth/password/sms/reset [post]
func (h *PasswordResetHandler) ResetPasswordByPhone(c *gin.Context) {
var req ResetPasswordByPhoneRequest
if err := c.ShouldBindJSON(&req); err != nil {