Documentation
¶
Index ¶
- Constants
- Variables
- type App
- func (app *App) GetSetting() *AppSetting
- func (app *App) HasModule(module string) bool
- func (app *App) IsBase() bool
- func (app *App) IsLoginable() bool
- func (app *App) ParseSetting() (*AppSetting, error)
- func (app *App) ScopeModules() []string
- func (app *App) String() string
- func (app *App) TableName() string
- type AppField
- type AppForm
- type AppOAuther
- type AppSetting
- type AppSettingJWT
- type AuthLog
- type Authorize
- type Dept
- type DeptClassify
- type DeptClosure
- type DeptRole
- type Dictionary
- type DictionaryValue
- type Entity
- type EntityField
- type EntityRule
- type Feedback
- type FeedbackClassify
- type Field
- type FieldConfig
- type FieldOption
- type FieldRule
- type FormScene
- type Job
- type JobRole
- type LoginLog
- type Menu
- type MenuClosure
- type Notice
- type NoticeClassify
- type NoticeUser
- type OAuther
- type OAutherSetting
- type Role
- type RoleClosure
- type RoleEntity
- type RoleMenu
- type User
- type UserDept
- type UserForm
- type UserOAuther
- type UserOAutherExtra
- type UserSetting
- type Userinfo
Constants ¶
const ( AppTypeBase = "base" // 基础设施:提供菜单与数据实体,不承载组织数据 AppTypeApp = "app" // 标准应用:承载角色/部门/职位等组织数据 )
const ( MenuTypeRoot = "R" // 应用根菜单 MenuTypeApi = "A" // API接口 MenuTypePage = "M" // 菜单页面 MenuTypeGroup = "G" // 菜单分组 MenuTypeBasic = "BA" // 基础API MenuTypeButton = "B" // 按钮权限 MenuTypeLink = "L" // 外部链接 )
const ( ActionCreate = "create" ActionRead = "read" ActionUpdate = "update" ActionDelete = "delete" )
Variables ¶
var AppTypes = []string{AppTypeBase, AppTypeApp}
AppTypes 全部合法的应用类型
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
Type string `json:"type" gorm:"column:type"`
Logo string `json:"logo" gorm:"column:logo"`
Keyword string `json:"keyword" gorm:"column:keyword"`
Favicon string `json:"favicon" gorm:"column:favicon"`
Name string `json:"name" gorm:"column:name"`
ShowName string `json:"showName" gorm:"column:show_name"`
Status *bool `json:"status" gorm:"column:status"`
Reason *string `json:"reason" gorm:"column:reason"`
Private *bool `json:"private" gorm:"column:private"`
Loginable *bool `json:"loginable" gorm:"column:loginable"` // 是否可作为登录入口;NULL/false = 不可登录
Description *string `json:"description" gorm:"column:description"`
Comment *string `json:"comment" gorm:"column:comment"`
Setting string `json:"setting" gorm:"column:setting"`
model.BaseModel
}
func (*App) GetSetting ¶ added in v1.2.8
func (app *App) GetSetting() *AppSetting
GetSetting 获取应用配置,解析失败时返回零值配置 注意:配置参与权限判断时应改用 ParseSetting,以便记录解析错误
func (*App) IsLoginable ¶ added in v1.2.10
IsLoginable 判断应用是否可作为登录入口
func (*App) ParseSetting ¶ added in v1.2.10
func (app *App) ParseSetting() (*AppSetting, error)
ParseSetting 获取应用配置并返回解析错误,供调用方记录日志 解析失败会导致 Modules 为空(表现为未订阅任何模块),静默忽略会造成难以定位的鉴权拒绝
func (*App) ScopeModules ¶ added in v1.2.10
ScopeModules 获取应用的模块可见范围:自身 + 已订阅的基础设施应用 用于菜单下发与接口鉴权时判断某个菜单所属模块是否在当前应用的可触达范围内
type AppField ¶
type AppField struct {
App string `json:"app" gorm:"column:app"` // 应用标识
FieldId uint32 `json:"fieldId" gorm:"column:field_id"` // 关联字段 ID
Required *bool `json:"required" gorm:"column:required"` // 是否必填
Unique *bool `json:"unique" gorm:"column:unique"` // 是否唯一
Sort uint32 `json:"sort" gorm:"column:sort"` // 排序(越小越前)
Field *Field `json:"field" gorm:"foreignKey:field_id;references:id"`
model.BaseModel
}
type AppForm ¶ added in v1.2.10
type AppForm struct {
AppKeyword string `json:"appKeyword" gorm:"column:app_keyword"` // 应用标识(关联 app.keyword)
FormId uint32 `json:"formId" gorm:"column:form_id"` // 表单 ID(关联 user_form.id)
Scene string `json:"scene" gorm:"column:scene"` // 场景标识(冗余自 user_form.scene,用于唯一约束)
model.CreateModel // Id(uint32 自增主键) + CreatedAt(int64 Unix 秒)
}
AppForm 应用-表单关联(中间表)
type AppOAuther ¶ added in v1.2.8
type AppOAuther struct {
model.CreateModel
App string `json:"app" gorm:"column:app"`
OAutherId uint32 `json:"oautherId" gorm:"column:oauther_id"`
Type string `json:"type" gorm:"column:type"`
OAuther *OAuther `json:"oauther" gorm:"foreignKey:oauther_id;references:id"`
}
func (AppOAuther) TableName ¶ added in v1.2.8
func (AppOAuther) TableName() string
type AppSetting ¶ added in v1.2.8
type AppSetting struct {
JWT AppSettingJWT `json:"jwt"`
Modules []string `json:"modules"` // 订阅的基础设施应用 keyword 列表,取值必须是 type=base 的应用
}
type AppSettingJWT ¶ added in v1.2.8
type AuthLog ¶
type AuthLog struct {
model.CreateModel
App string `json:"app" gorm:"column:app"`
DeptId uint32 `json:"deptId" gorm:"column:dept_id"`
UserId uint32 `json:"userId" gorm:"column:user_id"`
MenuId uint32 `json:"menuId" gorm:"column:menu_id"`
AppInfo *App `json:"appInfo" gorm:"foreignKey:app;references:keyword"`
User *User `json:"user" gorm:"foreignKey:user_id;references:id"`
Menu *Menu `json:"menu" gorm:"foreignKey:menu_id;references:id"`
}
type Authorize ¶ added in v1.2.8
type Authorize struct {
model.CreateModel
AppId uint32 `json:"appId" gorm:"column:app_id"`
UserId uint32 `json:"userId" gorm:"column:user_id"`
Tokens string `json:"tokens" gorm:"column:tokens"`
LoggedAt int64 `json:"loggedAt" gorm:"column:logged_at"`
ExpiredAt int64 `json:"expiredAt" gorm:"column:expired_at"`
}
type Dept ¶
type Dept struct {
Id uint32 `json:"id" gorm:"column:id;hook:dept[rud:w]"`
App string `json:"app" gorm:"column:app"`
ParentId *uint32 `json:"parentId" gorm:"column:parent_id;hook:dept[cu:c]"`
ClassifyId uint32 `json:"classifyId" gorm:"column:classify_id"`
Logo string `json:"logo" gorm:"column:logo"`
Keyword string `json:"keyword" gorm:"column:keyword"`
Name string `json:"name" gorm:"column:name"`
Status *bool `json:"status" gorm:"column:status"`
Description *string `json:"description" gorm:"column:description"`
CreatedAt int64 `json:"createdAt,omitempty" gorm:"column:created_at;"`
UpdatedAt int64 `json:"updatedAt,omitempty" gorm:"column:updated_at;"`
Classify *DeptClassify `json:"classify" gorm:"foreignKey:classify_id;references:id"`
Children []*Dept `json:"children" gorm:"-"`
}
type DeptClassify ¶
type DeptClassify struct {
App string `json:"app" gorm:"column:app"`
Keyword string `json:"keyword" gorm:"column:keyword"`
Name string `json:"name" gorm:"column:name"`
Description *string `json:"description" gorm:"column:description"`
Weight uint32 `json:"weight" gorm:"column:weight"`
model.BaseModel
}
type DeptClosure ¶
type Dictionary ¶
type DictionaryValue ¶
type DictionaryValue struct {
DictionaryId uint32 `json:"dictionaryId" gorm:"column:dictionary_id"`
ParentId *uint32 `json:"parentId" gorm:"column:parent_id"`
Label string `json:"label" gorm:"column:label"`
Value string `json:"value" gorm:"column:value"`
Status *bool `json:"status" gorm:"column:status"`
Weight *int32 `json:"weight" gorm:"column:weight"`
Type *string `json:"type" gorm:"column:type"`
Extra *string `json:"extra" gorm:"column:extra"`
Description *string `json:"description" gorm:"column:description"`
Dictionary *Dictionary `json:"dictionary" gorm:"foreignKey:dictionary_id;references:id"`
Children []*DictionaryValue `json:"children" gorm:"-"`
model.BaseModel
}
func (*DictionaryValue) AppendChildren ¶
func (m *DictionaryValue) AppendChildren(child *DictionaryValue)
AppendChildren 添加子节点
func (*DictionaryValue) ChildrenNode ¶
func (m *DictionaryValue) ChildrenNode() []*DictionaryValue
ChildrenNode 获取子节点
type Entity ¶
type Entity struct {
App string `json:"app" gorm:"column:app"`
Database string `json:"database" gorm:"column:database"`
Name string `json:"name" gorm:"column:name"`
Comment string `json:"comment" gorm:"column:comment"`
Fields []*EntityField `json:"fields" gorm:"foreignKey:entity_id;references:Id"`
model.BaseModel
}
type EntityField ¶
type EntityField struct {
EntityId uint32 `json:"entityId" gorm:"column:entity_id"`
Name string `json:"name" gorm:"column:name"`
Comment string `json:"comment" gorm:"column:comment"`
Index int `json:"index" gorm:"column:index"`
Entity Entity `gorm:"foreignKey:EntityId;references:Id"`
model.BaseModel
}
type EntityRule ¶
type EntityRule struct {
EntityId uint32 `json:"entityId" gorm:"column:entity_id"`
Name string `json:"name" gorm:"column:name"`
Status *bool `json:"status" gorm:"column:status"`
Expression string `json:"expression" gorm:"column:expression"`
Description string `json:"description" gorm:"column:description"`
Entity Entity `gorm:"foreignKey:EntityId;references:Id"`
model.BaseModel
}
type Feedback ¶
type Feedback struct {
App string `json:"app" gorm:"column:app"`
UserId uint32 `json:"userId" gorm:"column:user_id"`
ClassifyId uint32 `json:"classifyId" gorm:"column:classify_id"`
Title string `json:"title" gorm:"column:title"`
Content string `json:"content" gorm:"column:content"`
Status string `json:"status" gorm:"column:status"`
Images *string `json:"images" gorm:"column:images"`
Contact *string `json:"contact" gorm:"column:contact"`
Device string `json:"device" gorm:"column:device"`
Platform string `json:"platform" gorm:"column:platform"`
Version string `json:"version" gorm:"column:version"`
Md5 string `json:"md5" gorm:"column:md5"`
ProcessedBy *uint32 `json:"processedBy" gorm:"column:processed_by"`
ProcessedResult *string `json:"processedResult" gorm:"column:processed_result"`
AppInfo *App `json:"appInfo" gorm:"foreignKey:app;references:keyword"` // 所属应用(app 关联 app.keyword)
User *User `json:"user" gorm:"foreignKey:user_id;references:id"` // 反馈用户
Classify *FeedbackClassify `json:"classify" gorm:"foreignKey:classify_id;references:id"` // 反馈分类
ImageUrls []string `json:"imageUrls" gorm:"-"`
model.BaseModel
}
type FeedbackClassify ¶ added in v1.2.10
type Field ¶
type Field struct {
Keyword string `json:"keyword" gorm:"column:keyword"` // 字段唯一标识
Type string `json:"type" gorm:"column:type"` // 组件类型:input/textarea/number/password/radio/checkbox/select/time/date/datetime/upload
Name string `json:"name" gorm:"column:name"` // 字段标签
Config *FieldConfig `json:"config" gorm:"column:config;serializer:json"` // 组件配置
Status *bool `json:"status" gorm:"column:status"` // 是否启用:0 禁用 1 启用
Description *string `json:"description" gorm:"column:description"` // 字段说明
model.BaseModel
}
type FieldConfig ¶ added in v1.2.10
type FieldConfig struct {
Placeholder string `json:"placeholder,omitempty"` // 提示文本
DefaultValue any `json:"defaultValue,omitempty"` // 默认值(string/number/array/null)
MaxLength *uint32 `json:"maxLength,omitempty"` // input/textarea/password: 最大长度
Min *float64 `json:"min,omitempty"` // number: 最小值
Max *float64 `json:"max,omitempty"` // number: 最大值
Step *float64 `json:"step,omitempty"` // number: 步长
Options []FieldOption `json:"options,omitempty"` // radio/checkbox/select: 选项列表
Filetype string `json:"filetype,omitempty"` // upload: 文件类型(image/video/file)
Limit *uint32 `json:"limit,omitempty"` // upload: 最大文件数
Rule *FieldRule `json:"rule,omitempty"` // 校验规则
}
FieldConfig 组件配置(统一存放所有配置项)
type FieldOption ¶ added in v1.2.10
FieldOption 选项(radio/checkbox/select)
type FieldRule ¶ added in v1.2.10
type FieldRule struct {
Type string `json:"type"` // phone/email/idcard/regex/enum/range/length
Message string `json:"message,omitempty"` // 自定义错误提示
Pattern string `json:"pattern,omitempty"` // type=regex 时的正则表达式
Values []string `json:"values,omitempty"` // type=enum 时的合法值列表
Min *float64 `json:"min,omitempty"` // type=range/length 时的最小值
Max *float64 `json:"max,omitempty"` // type=range/length 时的最大值
}
FieldRule 校验规则
type FormScene ¶ added in v1.2.10
type FormScene struct {
Keyword string `json:"keyword" gorm:"column:keyword"` // 场景唯一标识(如 register / profile / activity)
Name string `json:"name" gorm:"column:name"` // 场景名称(如 "用户注册"、"个人资料")
Description *string `json:"description" gorm:"column:description"` // 场景描述
model.BaseModel
}
FormScene 表单场景枚举
type Job ¶
type Job struct {
App string `json:"app" gorm:"column:app"`
Keyword string `json:"keyword" gorm:"column:keyword"`
Name string `json:"name" gorm:"column:name"`
Description *string `json:"description" gorm:"column:description"`
Status *bool `json:"status" gorm:"column:status"`
Weight uint32 `json:"weight" gorm:"column:weight"`
model.BaseModel
}
type LoginLog ¶
type LoginLog struct {
model.CreateModel
App string `json:"app" gorm:"column:app"`
DeptId uint32 `json:"deptId" gorm:"column:dept_id"`
UserId uint32 `json:"userId" gorm:"column:user_id"`
Type string `json:"type" gorm:"column:type"`
IP string `json:"ip" gorm:"column:ip"`
Address string `json:"address" gorm:"column:address"`
Browser string `json:"browser" gorm:"column:browser"`
Device string `json:"device" gorm:"column:device"`
Code int `json:"code" gorm:"column:code"`
Description string `json:"description" gorm:"column:description"`
User *User `json:"user" gorm:"foreignKey:user_id;references:id"`
AppInfo *App `json:"appInfo" gorm:"foreignKey:app;references:keyword"`
}
type Menu ¶
type Menu struct {
App string `json:"app" gorm:"column:app"` // 应用标识
ParentId *uint32 `json:"parentId" gorm:"column:parent_id"` // 父节点ID
Title string `json:"title" gorm:"column:title"` // 菜单标题
Type string `json:"type" gorm:"column:type"` // 菜单类型
Keyword *string `json:"keyword" gorm:"column:keyword"` // 菜单标识
Icon *string `json:"icon" gorm:"column:icon"` // 菜单图标
Api *string `json:"api" gorm:"column:api"` // API接口信息
Method *string `json:"method" gorm:"column:method"` // API请求方法
Path *string `json:"path" gorm:"column:path"` // 路由路径
Permission *string `json:"permission" gorm:"column:permission"` // 权限标识
Component *string `json:"component" gorm:"column:component"` // 组件路径
Redirect *string `json:"redirect" gorm:"column:redirect"` // 重定向地址
Url *string `json:"url" gorm:"column:url"` // 站外url
Weight *int32 `json:"weight" gorm:"column:weight"` // 菜单权重
IsIframe *bool `json:"isIframe" gorm:"column:is_iframe"` // 是否外链打开
IsHidden *bool `json:"isHidden" gorm:"column:is_hidden"` // 是否隐藏菜单
IsCache *bool `json:"isCache" gorm:"column:is_cache"` // 是否缓存页面
IsHome *bool `json:"isHome" gorm:"column:is_home"` // 是否首页
IsAffix *bool `json:"isAffix" gorm:"column:is_affix"` // 是否固定在标签页
Children []*Menu `json:"children" gorm:"-"` // 子节点列表
RoleMenus []*RoleMenu `json:"roleMenus" gorm:"foreignKey:menu_id;references:id"`
model.BaseModel
}
type MenuClosure ¶
type Notice ¶ added in v1.2.10
type Notice struct {
model.BaseModel
App string `gorm:"column:app" json:"app"`
ClassifyId uint32 `gorm:"column:classify_id" json:"classifyId"`
Title string `gorm:"column:title" json:"title"` // 通知标题
Description string `gorm:"column:description" json:"description"` // 通知简介
Unit string `gorm:"column:unit" json:"unit"` // 发布单位
Content string `gorm:"column:content" json:"content"` // 通知内容
IsTop *bool `gorm:"column:is_top" json:"isTop"` // 是否置顶
Status *bool `gorm:"column:status" json:"status"` // 通知状态
AppInfo *App `gorm:"foreignKey:app;references:keyword" json:"appInfo"`
Classify *NoticeClassify `gorm:"foreignKey:classify_id;references:id" json:"classify"`
}
type NoticeClassify ¶ added in v1.2.10
type NoticeUser ¶ added in v1.2.10
type OAuther ¶ added in v1.2.8
type OAuther struct {
Logo string `json:"logo" gorm:"column:logo"` // 渠道logo
Keyword string `json:"keyword" gorm:"column:keyword"` // 渠道标识
Type string `json:"type" gorm:"column:type"` // 渠道类型
Name string `json:"name" gorm:"column:name"` // 渠道名称
Status *bool `json:"status" gorm:"column:status"` // 启用状态
Ak string `json:"ak" gorm:"column:ak"` // 渠道AK
Sk string `json:"sk" gorm:"column:sk"` // 渠道SK
Setting string `json:"extra" gorm:"column:setting"` // 渠道设置
Description *string `json:"description" gorm:"column:description"` // 描述信息
model.BaseModel
// 首页登录使用
Recommend bool `json:"recommend" gorm:"-"` // 是否推荐
RecommendText string `json:"recommendText" gorm:"-"` // 推荐文案
}
func (*OAuther) GetSetting ¶ added in v1.2.8
func (c *OAuther) GetSetting() *OAutherSetting
type OAutherSetting ¶ added in v1.2.8
type OAutherSetting struct {
Token string `json:"token"`
AesKey string `json:"aesKey"`
Callback string `json:"callback"`
Email struct {
Host string
Port int
Subject string
From string
Template string
}
}
func (OAutherSetting) ToString ¶ added in v1.2.8
func (extra OAutherSetting) ToString() string
type Role ¶
type Role struct {
App string `json:"app" gorm:"column:app"`
ParentId *uint32 `json:"parentId" gorm:"column:parent_id"`
Keyword string `json:"keyword" gorm:"column:keyword"`
Name string `json:"name" gorm:"column:name"`
Status *bool `json:"status" gorm:"column:status"`
Description *string `json:"description" gorm:"column:description"`
Children []*Role `json:"children" gorm:"-"`
RoleMenus []*RoleMenu `json:"roleMenus" gorm:"foreignKey:role_id;references:id"`
DeptRoles []*DeptRole
model.BaseModel
}
type RoleClosure ¶
type RoleEntity ¶
type RoleEntity struct {
App string `json:"app" gorm:"column:app"`
RoleId uint32 `json:"roleId" gorm:"column:role_id"`
EntityId uint32 `json:"entityId" gorm:"column:entity_id"`
Action string `json:"action" gorm:"column:action"`
Scope string `json:"scope" gorm:"column:scope"`
Depts string `json:"depts" gorm:"column:depts"`
Rules string `json:"rules" gorm:"column:rules"`
Entity *Entity `json:"entity" gorm:"foreignKey:EntityId;references:Id"`
model.BaseModel
}
type User ¶
type User struct {
Avatar *string `json:"avatar" gorm:"column:avatar"` // 用户头像
Nickname *string `json:"nickname" gorm:"column:nickname"` // 用户昵称
Signature *string `json:"signature" gorm:"column:signature"` // 用户签名
Username string `json:"username" gorm:"column:username"` // 用户账户
Password string `json:"password" gorm:"column:password"` // 用户密码
Status *bool `json:"status" gorm:"column:status"` // 用户状态
Reason *string `json:"reason" gorm:"column:reason"` // 用户原因
LoggedAt int64 `json:"loggedAt" gorm:"column:logged_at"` // 最近登录时间
Setting string `json:"setting" gorm:"-"` // 用户设置
UserDepts []*UserDept `json:"userDepts" gorm:"foreignKey:user_id;references:id"` // 用户部门
Infos []*Userinfo `json:"infos" gorm:"-"` // 用户信息
Authorize *Authorize `json:"authorize" gorm:"foreignKey:user_id;references:id"` // 用户授权
model.BaseModel
}
type UserDept ¶
type UserDept struct {
App string `json:"app" gorm:"column:app"`
UserId uint32 `json:"userId" gorm:"column:user_id"`
DeptId uint32 `json:"deptId" gorm:"column:dept_id;hook:dept[dept]"`
JobId uint32 `json:"jobId" gorm:"column:job_id"`
Main *bool `json:"main" gorm:"column:main"`
Dept *Dept `json:"dept" gorm:"foreignKey:dept_id;references:id"`
Job *Job `json:"job" gorm:"foreignKey:job_id;references:id"`
model.BaseModel
}
type UserForm ¶ added in v1.2.10
type UserForm struct {
Scene string `json:"scene" gorm:"column:scene"` // 场景标识(关联 form_scene.keyword),可重复
Name string `json:"name" gorm:"column:name"` // 表单名称
Description *string `json:"description" gorm:"column:description"` // 用途描述
Schema string `json:"schema" gorm:"column:schema;type:json"` // 设计器导出的完整 JSON(nodes 树 + config)
Version uint32 `json:"version" gorm:"column:version"` // 版本号,每次保存自增
Status *bool `json:"status" gorm:"column:status"` // false=草稿 true=已发布
model.BaseModel
}
UserForm 用户表单定义(替代原 FormSchema,以场景为中心)
type UserOAuther ¶ added in v1.2.8
type UserOAuther struct {
UserId uint32 `json:"userId" gorm:"column:user_id"`
OAutherId uint32 `json:"oautherId" gorm:"column:oauther_id"`
OID string `json:"oid" gorm:"column:oid"`
Token string `json:"token" gorm:"column:token"`
LoggedAt int64 `json:"loggedAt" gorm:"column:logged_at"`
ExpiredAt int64 `json:"expiredAt" gorm:"column:expired_at"`
Extra string `json:"extra" gorm:"column:extra"`
OAuther *OAuther `json:"oauther" gorm:"foreignKey:oauther_id;references:id"`
model.BaseModel
}
func (UserOAuther) GetExtra ¶ added in v1.2.8
func (o UserOAuther) GetExtra() *UserOAutherExtra
func (UserOAuther) TableName ¶ added in v1.2.8
func (c UserOAuther) TableName() string
type UserOAutherExtra ¶ added in v1.2.8
type UserOAutherExtra struct {
UnionID string `json:"unionId"`
}
type UserSetting ¶
type Userinfo ¶
type Userinfo struct {
UserId uint32 `json:"userId" gorm:"column:user_id"` // 用户 ID
Field string `json:"field" gorm:"column:field"` // 字段标识(对应 schema 中 node.field)
Value string `json:"value" gorm:"column:value"` // 字段值
model.BaseModel
}