登录功能完成

This commit is contained in:
2022-10-04 00:36:01 +08:00
parent 26278707bb
commit 968eab9b06
31 changed files with 1022 additions and 36 deletions

13
pkg/dao/entity/grant.go Normal file
View File

@@ -0,0 +1,13 @@
package entity
import (
"gorm.io/gorm"
)
// Grant Grant是授权给实例的给予实例访问权限
type Grant struct {
gorm.Model `json:"model"`
Token string `gorm:"unique;not null" json:"token,omitempty"`
TTL int `gorm:"not null;default:0" json:"ttl,omitempty"`
GrantTo uint `gorm:"not null;default:0;comment:instances(id) 授权给实例0表示无指定所有" json:"grant_to,omitempty"`
}

View File

@@ -0,0 +1,11 @@
package entity
import (
"gorm.io/gorm"
)
type Instance struct {
gorm.Model `json:"model"`
Name string `gorm:"unique;not null" json:"name,omitempty"`
UpdateURL string `gorm:"column:update_url;not null;default:'';comment:更新URL未指定使用默认" json:"update_url,omitempty"`
}

11
pkg/dao/entity/token.go Normal file
View File

@@ -0,0 +1,11 @@
package entity
import "gorm.io/gorm"
// Token Token是授权给用户的给予用户登录权限
type Token struct {
gorm.Model `json:"model"`
Token string `gorm:"unique;not null" json:"token,omitempty"`
GrantTo string `gorm:"index;not null;default:''" json:"grant_to,omitempty"`
TTL int `gorm:"not null;default:0" json:"ttl,omitempty"`
}

10
pkg/dao/entity/update.go Normal file
View File

@@ -0,0 +1,10 @@
package entity
import "gorm.io/gorm"
type Update struct {
gorm.Model `json:"model"`
HashID string `gorm:"index;not null" json:"hash_id,omitempty"`
Comment string `gorm:"not null;default:'';comment:更新内容或注释" json:"comment,omitempty"`
Changes string `gorm:"not null;comment:更改的文件列表逗号分隔引用files(hash_id)" json:"changes,omitempty"`
}

View File

@@ -3,9 +3,8 @@ package entity
import "gorm.io/gorm"
type User struct {
gorm.Model
Username string `gorm:"unique;not null"`
Password string `gorm:"not null"`
Instance string `gorm:"not null;default:''"`
Role string `gorm:"not null;default:0"`
gorm.Model `json:"model"`
Username string `gorm:"unique;not null" json:"username,omitempty"`
Password string `gorm:"not null" json:"password,omitempty"`
Roles string `gorm:"not null;default:''" json:"roles,omitempty"`
}