登录与授权等

This commit is contained in:
2024-01-07 15:13:35 +08:00
parent 968eab9b06
commit ec548f4256
22 changed files with 248 additions and 53 deletions

View File

@@ -2,12 +2,13 @@ package entity
import (
"gorm.io/gorm"
"time"
)
// 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"`
Token string `gorm:"unique;not null" json:"token"`
ExpireAt time.Time `gorm:"index" json:"expire_at"`
GrantTo string `gorm:"not null;default:'';comment:instances(name)授权给实例,表示无指定(所有)" json:"grant_to"`
}

View File

@@ -6,6 +6,6 @@ import (
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"`
Name string `gorm:"unique;not null" json:"name"`
UpdateURL string `gorm:"column:update_url;not null;default:'';comment:更新URL未指定使用默认" json:"update_url"`
}

View File

@@ -0,0 +1,7 @@
package entity
type Metadata struct {
ID uint `json:"id"`
Key string `gorm:"unique;not null" json:"key"`
Value string `gorm:"not null;default:''" json:"value"`
}

View File

@@ -5,7 +5,7 @@ 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"`
Token string `gorm:"unique;not null" json:"token"`
GrantTo string `gorm:"index;not null;default:''" json:"grant_to"`
TTL int `gorm:"not null;default:0" json:"ttl"`
}

View File

@@ -4,7 +4,7 @@ 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"`
HashID string `gorm:"index;not null" json:"hash_id"`
Comment string `gorm:"not null;default:'';comment:更新内容或注释" json:"comment"`
Changes string `gorm:"not null;comment:更改的文件列表逗号分隔引用files(hash_id)" json:"changes"`
}

View File

@@ -4,7 +4,7 @@ import "gorm.io/gorm"
type User struct {
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"`
Username string `gorm:"unique;not null" json:"username"`
Password string `gorm:"not null" json:"password"`
Roles string `gorm:"not null;default:''" json:"roles"`
}