update
This commit is contained in:
1 parent
0690285147
commit
5618cd2738
154 files changed
+5021
-3161
No files matched your search
+36
-37
@@ -2,22 +2,21 @@ package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
)
|
||||
|
||||
// User 用户模型
|
||||
type User struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
Username string `gorm:"size:64;uniqueIndex;not null" json:"username"`
|
||||
Password string `gorm:"size:255;not null" json:"-"`
|
||||
Email string `gorm:"size:128" json:"email"`
|
||||
Phone string `gorm:"size:32" json:"phone"`
|
||||
RealName string `gorm:"size:64" json:"real_name"`
|
||||
Avatar string `gorm:"size:255" json:"avatar"`
|
||||
Status int `gorm:"default:1" json:"status"` // 0:禁用 1:启用
|
||||
IsAdmin bool `gorm:"default:false" json:"is_admin"`
|
||||
AuthSource string `gorm:"size:20;default:'local'" json:"auth_source"` // local / ldap
|
||||
LastLogin *time.Time `json:"last_login"`
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
Username string `gorm:"size:64;uniqueIndex;not null" json:"username"`
|
||||
Password string `gorm:"size:255;not null" json:"-"`
|
||||
Email string `gorm:"size:128" json:"email"`
|
||||
Phone string `gorm:"size:32" json:"phone"`
|
||||
RealName string `gorm:"size:64" json:"real_name"`
|
||||
Avatar string `gorm:"size:255" json:"avatar"`
|
||||
Status int `gorm:"default:1" json:"status"` // 0:禁用 1:启用
|
||||
IsAdmin bool `gorm:"default:false" json:"is_admin"`
|
||||
AuthSource string `gorm:"size:20;default:'local'" json:"auth_source"` // local / ldap
|
||||
LastLogin *time.Time `json:"last_login"`
|
||||
// CI/CD Webhook 长期访问密钥(每用户仅一条,明文仅生成时返回一次)// Logan.Li
|
||||
ApiAccessKeyHash string `gorm:"size:255" json:"-"`
|
||||
ApiAccessKeyPrefix string `gorm:"size:32;index" json:"api_access_key_prefix,omitempty"`
|
||||
@@ -27,8 +26,8 @@ type User struct {
|
||||
ApiAccessKeyAt *time.Time `json:"api_access_key_at,omitempty"`
|
||||
ApiAccessKeyExpiresAt *time.Time `json:"api_access_key_expires_at,omitempty"`
|
||||
ApiAccessKeyLastUsedAt *time.Time `json:"api_access_key_last_used_at,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
|
||||
// 关联
|
||||
Roles []Role `gorm:"many2many:iam_user_roles;" json:"roles,omitempty"`
|
||||
@@ -41,17 +40,17 @@ func (User) TableName() string {
|
||||
|
||||
// Role 角色模型
|
||||
type Role struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
Name string `gorm:"size:64;uniqueIndex;not null" json:"name"`
|
||||
Code string `gorm:"size:64;uniqueIndex;not null" json:"code"`
|
||||
Description string `gorm:"size:255" json:"description"`
|
||||
Status int `gorm:"default:1" json:"status"`
|
||||
IsSystem bool `gorm:"default:false" json:"is_system"` // 系统默认角色,禁止删除
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
Name string `gorm:"size:64;uniqueIndex;not null" json:"name"`
|
||||
Code string `gorm:"size:64;uniqueIndex;not null" json:"code"`
|
||||
Description string `gorm:"size:255" json:"description"`
|
||||
Status int `gorm:"default:1" json:"status"`
|
||||
IsSystem bool `gorm:"default:false" json:"is_system"` // 系统默认角色,禁止删除
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
|
||||
// 关联
|
||||
Permissions []Permission `gorm:"many2many:role_permissions;" json:"permissions,omitempty"`
|
||||
Permissions []Permission `gorm:"many2many:iam_role_permissions;" json:"permissions,omitempty"`
|
||||
}
|
||||
|
||||
// TableName 表名
|
||||
@@ -61,17 +60,17 @@ func (Role) TableName() string {
|
||||
|
||||
// Permission 权限模型
|
||||
type Permission struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
Name string `gorm:"size:64;not null" json:"name"`
|
||||
Code string `gorm:"size:128;uniqueIndex;not null" json:"code"`
|
||||
Type string `gorm:"size:32" json:"type"` // menu, button, api
|
||||
Path string `gorm:"size:255" json:"path"`
|
||||
Method string `gorm:"size:32" json:"method"`
|
||||
ParentID *uint `json:"parent_id"`
|
||||
Sort int `gorm:"default:0" json:"sort"`
|
||||
Status int `gorm:"default:1" json:"status"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
Name string `gorm:"size:64;not null" json:"name"`
|
||||
Code string `gorm:"size:128;uniqueIndex;not null" json:"code"`
|
||||
Type string `gorm:"size:32" json:"type"` // menu, button, api
|
||||
Path string `gorm:"size:255" json:"path"`
|
||||
Method string `gorm:"size:32" json:"method"`
|
||||
ParentID *uint `json:"parent_id"`
|
||||
Sort int `gorm:"default:0" json:"sort"`
|
||||
Status int `gorm:"default:1" json:"status"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName 表名
|
||||
@@ -147,9 +146,9 @@ type UpdateUserRequest struct {
|
||||
|
||||
// CreateRoleRequest 创建角色请求 // Logan.Li
|
||||
type CreateRoleRequest struct {
|
||||
Name string `json:"name" binding:"required,min=1,max=64"`
|
||||
Code string `json:"code" binding:"required,min=1,max=64"`
|
||||
Description string `json:"description"`
|
||||
Name string `json:"name" binding:"required,min=1,max=64"`
|
||||
Code string `json:"code" binding:"required,min=1,max=64"`
|
||||
Description string `json:"description"`
|
||||
PermissionIDs []uint `json:"permission_ids"`
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user