You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.6 KiB
39 lines
1.6 KiB
1 week ago
|
package model
|
||
|
|
||
|
import (
|
||
|
"gofaster/internal/shared/model"
|
||
|
)
|
||
|
|
||
|
// Resource 权限资源模型
|
||
|
type Resource struct {
|
||
|
model.BaseModel
|
||
|
Name string `gorm:"uniqueIndex;size:100" json:"name"` // 资源名称,如 "用户管理"
|
||
|
Code string `gorm:"uniqueIndex;size:100" json:"code"` // 资源代码,如 "user:manage"
|
||
|
Type string `gorm:"size:50" json:"type"` // 资源类型:api, menu, button, data
|
||
|
Path string `gorm:"size:200" json:"path"` // 资源路径,如 "/api/users"
|
||
|
Method string `gorm:"size:20" json:"method"` // HTTP方法,如 "GET", "POST"
|
||
|
Description string `gorm:"size:200" json:"description"` // 资源描述
|
||
|
Module string `gorm:"size:50" json:"module"` // 所属模块,如 "auth", "workflow"
|
||
|
Status int `gorm:"default:1" json:"status"` // 状态:1-启用,0-禁用
|
||
|
Sort int `gorm:"default:0" json:"sort"` // 排序
|
||
|
ParentID *uint `gorm:"index" json:"parent_id"` // 父资源ID,用于层级结构
|
||
|
Icon string `gorm:"size:50" json:"icon"` // 图标(用于菜单)
|
||
|
IsPublic bool `gorm:"default:false" json:"is_public"` // 是否公开资源(无需权限验证)
|
||
|
}
|
||
|
|
||
|
// ResourcePermission 资源权限关联表
|
||
|
type ResourcePermission struct {
|
||
|
ResourceID uint `gorm:"primaryKey"`
|
||
|
PermissionID uint `gorm:"primaryKey"`
|
||
|
}
|
||
|
|
||
|
// TableName 指定表名
|
||
|
func (Resource) TableName() string {
|
||
|
return "resources"
|
||
|
}
|
||
|
|
||
|
// TableName 指定表名
|
||
|
func (ResourcePermission) TableName() string {
|
||
|
return "resource_permissions"
|
||
|
}
|