feat: support group now (close #17, close #72, close #85, close #104, close #136)

Co-authored-by: quzard <1191890118@qq.com>
This commit is contained in:
JustSong
2023-06-07 23:26:00 +08:00
parent 502515bbbd
commit 2ad22e1425
15 changed files with 235 additions and 29 deletions

View File

@@ -22,6 +22,7 @@ type User struct {
VerificationCode string `json:"verification_code" gorm:"-:all"` // this field is only for Email verification, don't save it to database!
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"`
Group string `json:"group" gorm:"type:varchar(32);default:'default'"`
}
func GetMaxUserId() int {
@@ -229,6 +230,11 @@ func GetUserEmail(id int) (email string, err error) {
return email, err
}
func GetUserGroup(id int) (group string, err error) {
err = DB.Model(&User{}).Where("id = ?", id).Select("`group`").Find(&group).Error
return group, err
}
func IncreaseUserQuota(id int, quota int) (err error) {
if quota < 0 {
return errors.New("quota 不能为负数!")