init: 初始化 AssetX 项目仓库

包含 webapp(Next.js 用户端)、webapp-back(Go 后端)、
antdesign(管理后台)、landingpage(营销落地页)、
数据库 SQL 和配置文件。
This commit is contained in:
2026-03-27 11:26:43 +00:00
commit 2ee4553b71
634 changed files with 988255 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
package common
import (
"fmt"
"net/http"
"github.com/golang-jwt/jwt/v5"
)
// HeaderTokenMock adds authorization token to request header for testing
func HeaderTokenMock(req *http.Request, u uint) {
req.Header.Set("Authorization", fmt.Sprintf("Token %v", GenToken(u)))
}
// ExtractTokenFromHeader extracts JWT token from Authorization header
// Used for testing token extraction logic
func ExtractTokenFromHeader(authHeader string) string {
if len(authHeader) > 6 && authHeader[:6] == "Token " {
return authHeader[6:]
}
return ""
}
// VerifyTokenClaims verifies a JWT token and returns claims for testing
func VerifyTokenClaims(tokenString string) (jwt.MapClaims, error) {
token, err := jwt.ParseWithClaims(tokenString, jwt.MapClaims{}, func(token *jwt.Token) (interface{}, error) {
return []byte(JWTSecret), nil
})
if err != nil {
return nil, err
}
return token.Claims.(jwt.MapClaims), nil
}