mirror of
https://github.com/skyle1995/NetworkAuth.git
synced 2026-05-25 02:24:05 +08:00
Modify the UUID format to uppercase
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,4 +3,5 @@ networkDev
|
|||||||
node.txt
|
node.txt
|
||||||
config.json
|
config.json
|
||||||
database.db
|
database.db
|
||||||
|
logs
|
||||||
模板
|
模板
|
||||||
@@ -278,7 +278,7 @@ func AppCreateHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// 确保UUID和Secret被设置(虽然BeforeCreate钩子应该处理这些,但为了保险起见)
|
// 确保UUID和Secret被设置(虽然BeforeCreate钩子应该处理这些,但为了保险起见)
|
||||||
if app.UUID == "" {
|
if app.UUID == "" {
|
||||||
app.UUID = uuid.New().String()
|
app.UUID = strings.ToUpper(uuid.New().String())
|
||||||
}
|
}
|
||||||
if app.Secret == "" {
|
if app.Secret == "" {
|
||||||
// 生成32位大写16进制随机字符
|
// 生成32位大写16进制随机字符
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
@@ -57,7 +58,7 @@ type API struct {
|
|||||||
func (api *API) BeforeCreate(tx *gorm.DB) error {
|
func (api *API) BeforeCreate(tx *gorm.DB) error {
|
||||||
if api.APIKey == "" {
|
if api.APIKey == "" {
|
||||||
// 生成唯一的API密钥
|
// 生成唯一的API密钥
|
||||||
api.APIKey = "api_" + uuid.New().String()
|
api.APIKey = "api_" + strings.ToUpper(uuid.New().String())
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ type App struct {
|
|||||||
// BeforeCreate 在创建记录前自动生成UUID和密钥
|
// BeforeCreate 在创建记录前自动生成UUID和密钥
|
||||||
func (app *App) BeforeCreate(tx *gorm.DB) error {
|
func (app *App) BeforeCreate(tx *gorm.DB) error {
|
||||||
if app.UUID == "" {
|
if app.UUID == "" {
|
||||||
app.UUID = uuid.New().String()
|
app.UUID = strings.ToUpper(uuid.New().String())
|
||||||
}
|
}
|
||||||
if app.Secret == "" {
|
if app.Secret == "" {
|
||||||
// 生成32位大写16进制随机字符
|
// 生成32位大写16进制随机字符
|
||||||
|
|||||||
BIN
recharge.db
BIN
recharge.db
Binary file not shown.
Reference in New Issue
Block a user