feat: 优化web

This commit is contained in:
2026-04-23 18:58:13 +08:00
commit 544a2f3428
160 changed files with 27327 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
package entity
import (
"time"
"gorm.io/gorm"
)
// Dept 部门 iam_dept(根部门 parent_id 为空字符串)
type Dept struct {
ID string `json:"id" gorm:"primaryKey;type:varchar(36);not null"`
TenantID string `json:"tenant_id" gorm:"size:36;not null;index:idx_dept_tenant"`
ParentID string `json:"parent_id" gorm:"size:36;default:'';index:idx_dept_parent"`
DeptName string `json:"dept_name" gorm:"size:128;not null"`
DeptPath string `json:"dept_path" gorm:"type:text"`
LeaderID *string `json:"leader_id" gorm:"size:36"`
SortOrder int `json:"sort_order" gorm:"default:0"`
Status int16 `json:"status" gorm:"default:1"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}
func (Dept) TableName() string { return "iam_dept" }
+32
View File
@@ -0,0 +1,32 @@
package entity
import (
"time"
"gorm.io/gorm"
)
// PublicOverviewPerms 动态导航中「概览页」类公开权限标识(PRD:所有用户默认可见,需在菜单中配置同名 perms)
const PublicOverviewPerms = "public:overview"
// Menu 菜单 iam_menu(全局,不按租户分表;根节点 parent_id 为空字符串)
type Menu struct {
ID string `json:"id" gorm:"primaryKey;type:varchar(36);not null"`
ParentID string `json:"parent_id" gorm:"size:36;default:'';index:idx_menu_parent"`
MenuName string `json:"menu_name" gorm:"size:128;not null"`
MenuType int16 `json:"menu_type" gorm:"not null"` // 1目录 2菜单 3按钮
Perms string `json:"perms" gorm:"size:128;uniqueIndex"`
Path string `json:"path" gorm:"size:255"`
Component string `json:"component" gorm:"size:255"`
Icon string `json:"icon" gorm:"size:64"`
SortOrder int `json:"sort_order" gorm:"default:0"`
IsVisible bool `json:"is_visible" gorm:"default:true"`
IsBuiltin bool `json:"is_builtin" gorm:"default:false"`
ExternalLink string `json:"external_link" gorm:"size:512"`
Status int16 `json:"status" gorm:"default:1"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}
func (Menu) TableName() string { return "iam_menu" }
+43
View File
@@ -0,0 +1,43 @@
package entity
import (
"time"
"gorm.io/gorm"
)
// 数据范围并集优先级(数值越大权限越大)
const (
DataScopeSelf int16 = 1
DataScopeDept int16 = 2
DataScopeDeptTree int16 = 3
DataScopeAll int16 = 4
)
// Role 角色 iam_role
type Role struct {
ID string `json:"id" gorm:"primaryKey;type:varchar(36);not null"`
TenantID string `json:"tenant_id" gorm:"size:36;not null;index:idx_role_tenant"`
RoleCode string `json:"role_code" gorm:"size:64;not null"`
RoleName string `json:"role_name" gorm:"size:128;not null"`
DataScope int16 `json:"data_scope" gorm:"default:4"` // 1本人 2本部门 3本部门及子部门 4全部
Description string `json:"description" gorm:"size:512"`
IsBuiltin bool `json:"is_builtin" gorm:"default:false"`
Status int16 `json:"status" gorm:"default:1"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}
func (Role) TableName() string { return "iam_role" }
// RoleMenu 角色菜单 iam_role_menu
type RoleMenu struct {
ID string `json:"id" gorm:"primaryKey;type:varchar(36);not null"`
RoleID string `json:"role_id" gorm:"size:36;not null;uniqueIndex:uk_role_menu"`
MenuID string `json:"menu_id" gorm:"size:36;not null;uniqueIndex:uk_role_menu"`
CreatedAt time.Time `json:"created_at"`
}
func (RoleMenu) TableName() string { return "iam_role_menu" }
+25
View File
@@ -0,0 +1,25 @@
package entity
import (
"time"
"gorm.io/gorm"
)
// PlatformTenantID 平台租户主键(与初始化数据一致;菜单维护等仅平台租户可操作)
const PlatformTenantID = "00000000-0000-0000-0000-000000000001"
// Tenant 租户 iam_tenant
type Tenant struct {
ID string `json:"id" gorm:"primaryKey;type:varchar(36);not null"`
TenantCode string `json:"tenant_code" gorm:"size:64;uniqueIndex;not null"`
TenantName string `json:"tenant_name" gorm:"size:128;not null"`
AdminUserID *string `json:"admin_user_id" gorm:"size:36"`
Status int16 `json:"status" gorm:"default:1"` // 1 正常 0 冻结 -1 删除(逻辑)
ExpireTime *time.Time `json:"expire_time"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}
func (Tenant) TableName() string { return "iam_tenant" }
+53
View File
@@ -0,0 +1,53 @@
package entity
import (
"time"
"gorm.io/gorm"
)
// User 用户 iam_user
type User struct {
ID string `json:"id" gorm:"primaryKey;type:varchar(36);not null"`
TenantID string `json:"tenant_id" gorm:"size:36;not null;index:idx_user_tenant"`
DeptID *string `json:"dept_id" gorm:"size:36;index:idx_user_dept"`
UserName string `json:"user_name" gorm:"size:64;not null"`
RealName string `json:"real_name" gorm:"size:64"`
PasswordHash string `json:"-" gorm:"size:255;not null"`
Phone string `json:"phone" gorm:"size:20"`
Email string `json:"email" gorm:"size:128"`
Avatar string `json:"avatar" gorm:"size:512"`
Gender int16 `json:"gender" gorm:"default:0"`
Status int16 `json:"status" gorm:"default:1"`
LoginAttempts int `json:"login_attempts" gorm:"default:0"`
LockedUntil *time.Time `json:"locked_until"`
LastLoginAt *time.Time `json:"last_login_at"`
LastLoginIP string `json:"last_login_ip" gorm:"size:45"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}
func (User) TableName() string { return "iam_user" }
// UserDept 用户部门关联 iam_user_dept
type UserDept struct {
ID string `json:"id" gorm:"primaryKey;type:varchar(36);not null"`
UserID string `json:"user_id" gorm:"size:36;not null;uniqueIndex:uk_user_dept"`
DeptID string `json:"dept_id" gorm:"size:36;not null;uniqueIndex:uk_user_dept"`
IsPrimary bool `json:"is_primary" gorm:"default:false"`
CreatedAt time.Time `json:"created_at"`
}
func (UserDept) TableName() string { return "iam_user_dept" }
// UserRole 用户角色 iam_user_role
type UserRole struct {
ID string `json:"id" gorm:"primaryKey;type:varchar(36);not null"`
UserID string `json:"user_id" gorm:"size:36;not null;uniqueIndex:uk_user_role"`
RoleID string `json:"role_id" gorm:"size:36;not null;uniqueIndex:uk_user_role"`
CreatedAt time.Time `json:"created_at"`
}
func (UserRole) TableName() string { return "iam_user_role" }