refactor: 自定义业务错误

This commit is contained in:
Forest
2025-12-25 20:52:47 +08:00
parent f51ad2e126
commit eeaff85e47
60 changed files with 1222 additions and 622 deletions

View File

@@ -3,9 +3,11 @@ package middleware
import (
"context"
"crypto/subtle"
"errors"
"strings"
"github.com/Wei-Shaw/sub2api/internal/model"
"github.com/Wei-Shaw/sub2api/internal/service"
"strings"
"github.com/gin-gonic/gin"
)
@@ -96,7 +98,7 @@ func validateJWTForAdmin(
// 验证 JWT token
claims, err := authService.ValidateToken(token)
if err != nil {
if err == service.ErrTokenExpired {
if errors.Is(err, service.ErrTokenExpired) {
AbortWithError(c, 401, "TOKEN_EXPIRED", "Token has expired")
return false
}