From 5bfc22466986522a87d81d89fe293de4e71d5c69 Mon Sep 17 00:00:00 2001 From: JustSong Date: Thu, 27 Apr 2023 09:32:20 +0800 Subject: [PATCH] fix: specify type for token (close #23) --- model/redemption.go | 2 +- model/token.go | 2 +- model/user.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/model/redemption.go b/model/redemption.go index f0b80c88..0f060ae6 100644 --- a/model/redemption.go +++ b/model/redemption.go @@ -9,7 +9,7 @@ import ( type Redemption struct { Id int `json:"id"` UserId int `json:"user_id"` - Key string `json:"key" gorm:"uniqueIndex"` + Key string `json:"key" gorm:"type:char(32);uniqueIndex"` Status int `json:"status" gorm:"default:1"` Name string `json:"name" gorm:"index"` Quota int `json:"quota" gorm:"default:100"` diff --git a/model/token.go b/model/token.go index 4488288f..42bc8056 100644 --- a/model/token.go +++ b/model/token.go @@ -11,7 +11,7 @@ import ( type Token struct { Id int `json:"id"` UserId int `json:"user_id"` - Key string `json:"key" gorm:"uniqueIndex"` + Key string `json:"key" gorm:"type:char(32);uniqueIndex"` Status int `json:"status" gorm:"default:1"` Name string `json:"name" gorm:"index" ` CreatedTime int64 `json:"created_time" gorm:"bigint"` diff --git a/model/user.go b/model/user.go index 84f97960..3b5db50f 100644 --- a/model/user.go +++ b/model/user.go @@ -21,7 +21,7 @@ type User struct { WeChatId string `json:"wechat_id" gorm:"column:wechat_id;index"` VerificationCode string `json:"verification_code" gorm:"-:all"` // this field is only for Email verification, don't save it to database! Balance int `json:"balance" gorm:"type:int;default:0"` - AccessToken string `json:"access_token" gorm:"column:access_token;uniqueIndex"` // this token is for system management + AccessToken string `json:"access_token" gorm:"type:char(32);column:access_token;uniqueIndex"` // this token is for system management Quota int `json:"quota" gorm:"type:int;default:0"` }