Modify the UUID format to uppercase

This commit is contained in:
2025-10-24 01:54:45 +08:00
parent f03d2d0b12
commit abea88da82
5 changed files with 21 additions and 19 deletions

1
.gitignore vendored
View File

@@ -3,4 +3,5 @@ networkDev
node.txt
config.json
database.db
logs
模板

View File

@@ -278,7 +278,7 @@ func AppCreateHandler(w http.ResponseWriter, r *http.Request) {
// 确保UUID和Secret被设置虽然BeforeCreate钩子应该处理这些但为了保险起见
if app.UUID == "" {
app.UUID = uuid.New().String()
app.UUID = strings.ToUpper(uuid.New().String())
}
if app.Secret == "" {
// 生成32位大写16进制随机字符

View File

@@ -1,6 +1,7 @@
package models
import (
"strings"
"time"
"github.com/google/uuid"
@@ -57,7 +58,7 @@ type API struct {
func (api *API) BeforeCreate(tx *gorm.DB) error {
if api.APIKey == "" {
// 生成唯一的API密钥
api.APIKey = "api_" + uuid.New().String()
api.APIKey = "api_" + strings.ToUpper(uuid.New().String())
}
return nil
}
@@ -69,9 +70,9 @@ func (API) TableName() string {
// 算法类型常量
const (
AlgorithmNone = 0 // 不加密
AlgorithmRC4 = 1 // RC4
AlgorithmRSA = 2 // RSA
AlgorithmNone = 0 // 不加密
AlgorithmRC4 = 1 // RC4
AlgorithmRSA = 2 // RSA
AlgorithmRSADynamic = 3 // RSA动态
)

View File

@@ -58,7 +58,7 @@ type App struct {
// BeforeCreate 在创建记录前自动生成UUID和密钥
func (app *App) BeforeCreate(tx *gorm.DB) error {
if app.UUID == "" {
app.UUID = uuid.New().String()
app.UUID = strings.ToUpper(uuid.New().String())
}
if app.Secret == "" {
// 生成32位大写16进制随机字符

Binary file not shown.