任务三
This commit is contained in:
@@ -8,14 +8,14 @@ const TableNameCasbinRule = "casbin_rule"
|
||||
|
||||
// CasbinRule mapped from table <casbin_rule>
|
||||
type CasbinRule struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
Ptype *string `gorm:"column:ptype;type:varchar(100);uniqueIndex:idx_casbin_rule,priority:1" json:"ptype"`
|
||||
V0 *string `gorm:"column:v0;type:varchar(100);uniqueIndex:idx_casbin_rule,priority:2" json:"v0"`
|
||||
V1 *string `gorm:"column:v1;type:varchar(100);uniqueIndex:idx_casbin_rule,priority:3" json:"v1"`
|
||||
V2 *string `gorm:"column:v2;type:varchar(100);uniqueIndex:idx_casbin_rule,priority:4" json:"v2"`
|
||||
V3 *string `gorm:"column:v3;type:varchar(100);uniqueIndex:idx_casbin_rule,priority:5" json:"v3"`
|
||||
V4 *string `gorm:"column:v4;type:varchar(100);uniqueIndex:idx_casbin_rule,priority:6" json:"v4"`
|
||||
V5 *string `gorm:"column:v5;type:varchar(100);uniqueIndex:idx_casbin_rule,priority:7" json:"v5"`
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
Ptype string `gorm:"column:ptype;type:varchar(100);uniqueIndex:idx_casbin_rule,priority:1" json:"ptype"`
|
||||
V0 string `gorm:"column:v0;type:varchar(100);uniqueIndex:idx_casbin_rule,priority:2" json:"v0"`
|
||||
V1 string `gorm:"column:v1;type:varchar(100);uniqueIndex:idx_casbin_rule,priority:3" json:"v1"`
|
||||
V2 string `gorm:"column:v2;type:varchar(100);uniqueIndex:idx_casbin_rule,priority:4" json:"v2"`
|
||||
V3 string `gorm:"column:v3;type:varchar(100);uniqueIndex:idx_casbin_rule,priority:5" json:"v3"`
|
||||
V4 string `gorm:"column:v4;type:varchar(100);uniqueIndex:idx_casbin_rule,priority:6" json:"v4"`
|
||||
V5 string `gorm:"column:v5;type:varchar(100);uniqueIndex:idx_casbin_rule,priority:7" json:"v5"`
|
||||
}
|
||||
|
||||
// TableName CasbinRule's table name
|
||||
|
||||
@@ -15,11 +15,11 @@ const TableNameExaAttachmentCategory = "exa_attachment_category"
|
||||
// ExaAttachmentCategory mapped from table <exa_attachment_category>
|
||||
type ExaAttachmentCategory struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_exa_attachment_category_deleted_at,priority:1" json:"deleted_at"`
|
||||
Name *string `gorm:"column:name;type:varchar(255);comment:分类名称" json:"name"` // 分类名称
|
||||
Pid *int64 `gorm:"column:pid;type:bigint(20);comment:父节点ID" json:"pid"` // 父节点ID
|
||||
Name string `gorm:"column:name;type:varchar(255);comment:分类名称" json:"name"` // 分类名称
|
||||
Pid int64 `gorm:"column:pid;type:bigint(20);comment:父节点ID" json:"pid"` // 父节点ID
|
||||
}
|
||||
|
||||
// TableName ExaAttachmentCategory's table name
|
||||
|
||||
@@ -15,13 +15,13 @@ const TableNameExaCustomer = "exa_customers"
|
||||
// ExaCustomer mapped from table <exa_customers>
|
||||
type ExaCustomer struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_exa_customers_deleted_at,priority:1" json:"deleted_at"`
|
||||
CustomerName *string `gorm:"column:customer_name;type:varchar(191);comment:客户名" json:"customer_name"` // 客户名
|
||||
CustomerPhoneData *string `gorm:"column:customer_phone_data;type:varchar(191);comment:客户手机号" json:"customer_phone_data"` // 客户手机号
|
||||
SysUserID *int64 `gorm:"column:sys_user_id;type:bigint(20) unsigned;comment:管理ID" json:"sys_user_id"` // 管理ID
|
||||
SysUserAuthorityID *int64 `gorm:"column:sys_user_authority_id;type:bigint(20) unsigned;comment:管理角色ID" json:"sys_user_authority_id"` // 管理角色ID
|
||||
CustomerName string `gorm:"column:customer_name;type:varchar(191);comment:客户名" json:"customer_name"` // 客户名
|
||||
CustomerPhoneData string `gorm:"column:customer_phone_data;type:varchar(191);comment:客户手机号" json:"customer_phone_data"` // 客户手机号
|
||||
SysUserID int64 `gorm:"column:sys_user_id;type:bigint(20) unsigned;comment:管理ID" json:"sys_user_id"` // 管理ID
|
||||
SysUserAuthorityID int64 `gorm:"column:sys_user_authority_id;type:bigint(20) unsigned;comment:管理角色ID" json:"sys_user_authority_id"` // 管理角色ID
|
||||
}
|
||||
|
||||
// TableName ExaCustomer's table name
|
||||
|
||||
@@ -15,12 +15,12 @@ const TableNameExaFileChunk = "exa_file_chunks"
|
||||
// ExaFileChunk mapped from table <exa_file_chunks>
|
||||
type ExaFileChunk struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_exa_file_chunks_deleted_at,priority:1" json:"deleted_at"`
|
||||
ExaFileID *int64 `gorm:"column:exa_file_id;type:bigint(20) unsigned" json:"exa_file_id"`
|
||||
FileChunkNumber *int64 `gorm:"column:file_chunk_number;type:bigint(20)" json:"file_chunk_number"`
|
||||
FileChunkPath *string `gorm:"column:file_chunk_path;type:varchar(191)" json:"file_chunk_path"`
|
||||
ExaFileID int64 `gorm:"column:exa_file_id;type:bigint(20) unsigned" json:"exa_file_id"`
|
||||
FileChunkNumber int64 `gorm:"column:file_chunk_number;type:bigint(20)" json:"file_chunk_number"`
|
||||
FileChunkPath string `gorm:"column:file_chunk_path;type:varchar(191)" json:"file_chunk_path"`
|
||||
}
|
||||
|
||||
// TableName ExaFileChunk's table name
|
||||
|
||||
@@ -15,14 +15,14 @@ const TableNameExaFileUploadAndDownload = "exa_file_upload_and_downloads"
|
||||
// ExaFileUploadAndDownload mapped from table <exa_file_upload_and_downloads>
|
||||
type ExaFileUploadAndDownload struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_exa_file_upload_and_downloads_deleted_at,priority:1" json:"deleted_at"`
|
||||
Name *string `gorm:"column:name;type:varchar(191);comment:文件名" json:"name"` // 文件名
|
||||
ClassID *int64 `gorm:"column:class_id;type:bigint(20);comment:分类id" json:"class_id"` // 分类id
|
||||
URL *string `gorm:"column:url;type:varchar(191);comment:文件地址" json:"url"` // 文件地址
|
||||
Tag *string `gorm:"column:tag;type:varchar(191);comment:文件标签" json:"tag"` // 文件标签
|
||||
Key *string `gorm:"column:key;type:varchar(191);comment:编号" json:"key"` // 编号
|
||||
Name string `gorm:"column:name;type:varchar(191);comment:文件名" json:"name"` // 文件名
|
||||
ClassID int64 `gorm:"column:class_id;type:bigint(20);comment:分类id" json:"class_id"` // 分类id
|
||||
URL string `gorm:"column:url;type:varchar(191);comment:文件地址" json:"url"` // 文件地址
|
||||
Tag string `gorm:"column:tag;type:varchar(191);comment:文件标签" json:"tag"` // 文件标签
|
||||
Key string `gorm:"column:key;type:varchar(191);comment:编号" json:"key"` // 编号
|
||||
}
|
||||
|
||||
// TableName ExaFileUploadAndDownload's table name
|
||||
|
||||
@@ -15,14 +15,14 @@ const TableNameExaFile = "exa_files"
|
||||
// ExaFile mapped from table <exa_files>
|
||||
type ExaFile struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_exa_files_deleted_at,priority:1" json:"deleted_at"`
|
||||
FileName *string `gorm:"column:file_name;type:varchar(191)" json:"file_name"`
|
||||
FileMd5 *string `gorm:"column:file_md5;type:varchar(191)" json:"file_md5"`
|
||||
FilePath *string `gorm:"column:file_path;type:varchar(191)" json:"file_path"`
|
||||
ChunkTotal *int64 `gorm:"column:chunk_total;type:bigint(20)" json:"chunk_total"`
|
||||
IsFinish *bool `gorm:"column:is_finish;type:tinyint(1)" json:"is_finish"`
|
||||
FileName string `gorm:"column:file_name;type:varchar(191)" json:"file_name"`
|
||||
FileMd5 string `gorm:"column:file_md5;type:varchar(191)" json:"file_md5"`
|
||||
FilePath string `gorm:"column:file_path;type:varchar(191)" json:"file_path"`
|
||||
ChunkTotal int64 `gorm:"column:chunk_total;type:bigint(20)" json:"chunk_total"`
|
||||
IsFinish bool `gorm:"column:is_finish;type:tinyint(1)" json:"is_finish"`
|
||||
}
|
||||
|
||||
// TableName ExaFile's table name
|
||||
|
||||
@@ -15,13 +15,13 @@ const TableNameGvaAnnouncementsInfo = "gva_announcements_info"
|
||||
// GvaAnnouncementsInfo mapped from table <gva_announcements_info>
|
||||
type GvaAnnouncementsInfo struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_gva_announcements_info_deleted_at,priority:1" json:"deleted_at"`
|
||||
Title *string `gorm:"column:title;type:varchar(191);comment:公告标题" json:"title"` // 公告标题
|
||||
Content *string `gorm:"column:content;type:text;comment:公告内容" json:"content"` // 公告内容
|
||||
UserID *int64 `gorm:"column:user_id;type:bigint(20);comment:发布者" json:"user_id"` // 发布者
|
||||
Attachments *string `gorm:"column:attachments;type:json;comment:相关附件" json:"attachments"` // 相关附件
|
||||
Title string `gorm:"column:title;type:varchar(191);comment:公告标题" json:"title"` // 公告标题
|
||||
Content string `gorm:"column:content;type:text;comment:公告内容" json:"content"` // 公告内容
|
||||
UserID int64 `gorm:"column:user_id;type:bigint(20);comment:发布者" json:"user_id"` // 发布者
|
||||
Attachments string `gorm:"column:attachments;type:json;comment:相关附件" json:"attachments"` // 相关附件
|
||||
}
|
||||
|
||||
// TableName GvaAnnouncementsInfo's table name
|
||||
|
||||
@@ -15,10 +15,10 @@ const TableNameJwtBlacklist = "jwt_blacklists"
|
||||
// JwtBlacklist mapped from table <jwt_blacklists>
|
||||
type JwtBlacklist struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_jwt_blacklists_deleted_at,priority:1" json:"deleted_at"`
|
||||
Jwt *string `gorm:"column:jwt;type:text;comment:jwt" json:"jwt"` // jwt
|
||||
Jwt string `gorm:"column:jwt;type:text;comment:jwt" json:"jwt"` // jwt
|
||||
}
|
||||
|
||||
// TableName JwtBlacklist's table name
|
||||
|
||||
@@ -15,13 +15,13 @@ const TableNameSysAPI = "sys_apis"
|
||||
// SysAPI mapped from table <sys_apis>
|
||||
type SysAPI struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_sys_apis_deleted_at,priority:1" json:"deleted_at"`
|
||||
Path *string `gorm:"column:path;type:varchar(191);comment:api路径" json:"path"` // api路径
|
||||
Description *string `gorm:"column:description;type:varchar(191);comment:api中文描述" json:"description"` // api中文描述
|
||||
APIGroup *string `gorm:"column:api_group;type:varchar(191);comment:api组" json:"api_group"` // api组
|
||||
Method *string `gorm:"column:method;type:varchar(191);default:POST;comment:方法" json:"method"` // 方法
|
||||
Path string `gorm:"column:path;type:varchar(191);comment:api路径" json:"path"` // api路径
|
||||
Description string `gorm:"column:description;type:varchar(191);comment:api中文描述" json:"description"` // api中文描述
|
||||
APIGroup string `gorm:"column:api_group;type:varchar(191);comment:api组" json:"api_group"` // api组
|
||||
Method string `gorm:"column:method;type:varchar(191);default:POST;comment:方法" json:"method"` // 方法
|
||||
}
|
||||
|
||||
// TableName SysAPI's table name
|
||||
|
||||
@@ -14,13 +14,13 @@ const TableNameSysAuthority = "sys_authorities"
|
||||
|
||||
// SysAuthority mapped from table <sys_authorities>
|
||||
type SysAuthority struct {
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3)" json:"deleted_at"`
|
||||
AuthorityID int64 `gorm:"column:authority_id;type:bigint(20) unsigned;primaryKey;autoIncrement:true;uniqueIndex:uni_sys_authorities_authority_id,priority:1;comment:角色ID" json:"authority_id"` // 角色ID
|
||||
AuthorityName *string `gorm:"column:authority_name;type:varchar(191);comment:角色名" json:"authority_name"` // 角色名
|
||||
ParentID *int64 `gorm:"column:parent_id;type:bigint(20) unsigned;comment:父角色ID" json:"parent_id"` // 父角色ID
|
||||
DefaultRouter *string `gorm:"column:default_router;type:varchar(191);default:dashboard;comment:默认菜单" json:"default_router"` // 默认菜单
|
||||
AuthorityName string `gorm:"column:authority_name;type:varchar(191);comment:角色名" json:"authority_name"` // 角色名
|
||||
ParentID int64 `gorm:"column:parent_id;type:bigint(20) unsigned;comment:父角色ID" json:"parent_id"` // 父角色ID
|
||||
DefaultRouter string `gorm:"column:default_router;type:varchar(191);default:dashboard;comment:默认菜单" json:"default_router"` // 默认菜单
|
||||
}
|
||||
|
||||
// TableName SysAuthority's table name
|
||||
|
||||
@@ -8,9 +8,9 @@ const TableNameSysAuthorityBtn = "sys_authority_btns"
|
||||
|
||||
// SysAuthorityBtn mapped from table <sys_authority_btns>
|
||||
type SysAuthorityBtn struct {
|
||||
AuthorityID *int64 `gorm:"column:authority_id;type:bigint(20) unsigned;comment:角色ID" json:"authority_id"` // 角色ID
|
||||
SysMenuID *int64 `gorm:"column:sys_menu_id;type:bigint(20) unsigned;comment:菜单ID" json:"sys_menu_id"` // 菜单ID
|
||||
SysBaseMenuBtnID *int64 `gorm:"column:sys_base_menu_btn_id;type:bigint(20) unsigned;comment:菜单按钮ID" json:"sys_base_menu_btn_id"` // 菜单按钮ID
|
||||
AuthorityID int64 `gorm:"column:authority_id;type:bigint(20) unsigned;comment:角色ID" json:"authority_id"` // 角色ID
|
||||
SysMenuID int64 `gorm:"column:sys_menu_id;type:bigint(20) unsigned;comment:菜单ID" json:"sys_menu_id"` // 菜单ID
|
||||
SysBaseMenuBtnID int64 `gorm:"column:sys_base_menu_btn_id;type:bigint(20) unsigned;comment:菜单按钮ID" json:"sys_base_menu_btn_id"` // 菜单按钮ID
|
||||
}
|
||||
|
||||
// TableName SysAuthorityBtn's table name
|
||||
|
||||
@@ -15,23 +15,23 @@ const TableNameSysAutoCodeHistory = "sys_auto_code_histories"
|
||||
// SysAutoCodeHistory mapped from table <sys_auto_code_histories>
|
||||
type SysAutoCodeHistory struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_sys_auto_code_histories_deleted_at,priority:1" json:"deleted_at"`
|
||||
TblName *string `gorm:"column:table_name;type:varchar(191);comment:表名" json:"table_name"` // 表名
|
||||
Package *string `gorm:"column:package;type:varchar(191);comment:模块名/插件名" json:"package"` // 模块名/插件名
|
||||
Request *string `gorm:"column:request;type:text;comment:前端传入的结构化信息" json:"request"` // 前端传入的结构化信息
|
||||
StructName *string `gorm:"column:struct_name;type:varchar(191);comment:结构体名称" json:"struct_name"` // 结构体名称
|
||||
Abbreviation *string `gorm:"column:abbreviation;type:varchar(191);comment:结构体名称缩写" json:"abbreviation"` // 结构体名称缩写
|
||||
BusinessDb *string `gorm:"column:business_db;type:varchar(191);comment:业务库" json:"business_db"` // 业务库
|
||||
Description *string `gorm:"column:description;type:varchar(191);comment:Struct中文名称" json:"description"` // Struct中文名称
|
||||
Templates *string `gorm:"column:templates;type:text;comment:模板信息" json:"templates"` // 模板信息
|
||||
Injections *string `gorm:"column:Injections;type:text;comment:注入路径" json:"Injections"` // 注入路径
|
||||
Flag *int64 `gorm:"column:flag;type:bigint(20);comment:[0:创建,1:回滚]" json:"flag"` // [0:创建,1:回滚]
|
||||
APIIds *string `gorm:"column:api_ids;type:varchar(191);comment:api表注册内容" json:"api_ids"` // api表注册内容
|
||||
MenuID *int64 `gorm:"column:menu_id;type:bigint(20) unsigned;comment:菜单ID" json:"menu_id"` // 菜单ID
|
||||
ExportTemplateID *int64 `gorm:"column:export_template_id;type:bigint(20) unsigned;comment:导出模板ID" json:"export_template_id"` // 导出模板ID
|
||||
PackageID *int64 `gorm:"column:package_id;type:bigint(20) unsigned;comment:包ID" json:"package_id"` // 包ID
|
||||
TblName string `gorm:"column:table_name;type:varchar(191);comment:表名" json:"table_name"` // 表名
|
||||
Package string `gorm:"column:package;type:varchar(191);comment:模块名/插件名" json:"package"` // 模块名/插件名
|
||||
Request string `gorm:"column:request;type:text;comment:前端传入的结构化信息" json:"request"` // 前端传入的结构化信息
|
||||
StructName string `gorm:"column:struct_name;type:varchar(191);comment:结构体名称" json:"struct_name"` // 结构体名称
|
||||
Abbreviation string `gorm:"column:abbreviation;type:varchar(191);comment:结构体名称缩写" json:"abbreviation"` // 结构体名称缩写
|
||||
BusinessDb string `gorm:"column:business_db;type:varchar(191);comment:业务库" json:"business_db"` // 业务库
|
||||
Description string `gorm:"column:description;type:varchar(191);comment:Struct中文名称" json:"description"` // Struct中文名称
|
||||
Templates string `gorm:"column:templates;type:text;comment:模板信息" json:"templates"` // 模板信息
|
||||
Injections string `gorm:"column:Injections;type:text;comment:注入路径" json:"Injections"` // 注入路径
|
||||
Flag int64 `gorm:"column:flag;type:bigint(20);comment:[0:创建,1:回滚]" json:"flag"` // [0:创建,1:回滚]
|
||||
APIIds string `gorm:"column:api_ids;type:varchar(191);comment:api表注册内容" json:"api_ids"` // api表注册内容
|
||||
MenuID int64 `gorm:"column:menu_id;type:bigint(20) unsigned;comment:菜单ID" json:"menu_id"` // 菜单ID
|
||||
ExportTemplateID int64 `gorm:"column:export_template_id;type:bigint(20) unsigned;comment:导出模板ID" json:"export_template_id"` // 导出模板ID
|
||||
PackageID int64 `gorm:"column:package_id;type:bigint(20) unsigned;comment:包ID" json:"package_id"` // 包ID
|
||||
}
|
||||
|
||||
// TableName SysAutoCodeHistory's table name
|
||||
|
||||
@@ -15,14 +15,14 @@ const TableNameSysAutoCodePackage = "sys_auto_code_packages"
|
||||
// SysAutoCodePackage mapped from table <sys_auto_code_packages>
|
||||
type SysAutoCodePackage struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_sys_auto_code_packages_deleted_at,priority:1" json:"deleted_at"`
|
||||
Desc *string `gorm:"column:desc;type:varchar(191);comment:描述" json:"desc"` // 描述
|
||||
Label *string `gorm:"column:label;type:varchar(191);comment:展示名" json:"label"` // 展示名
|
||||
Template *string `gorm:"column:template;type:varchar(191);comment:模版" json:"template"` // 模版
|
||||
PackageName *string `gorm:"column:package_name;type:varchar(191);comment:包名" json:"package_name"` // 包名
|
||||
Module *string `gorm:"column:module;type:varchar(191)" json:"module"`
|
||||
Desc string `gorm:"column:desc;type:varchar(191);comment:描述" json:"desc"` // 描述
|
||||
Label string `gorm:"column:label;type:varchar(191);comment:展示名" json:"label"` // 展示名
|
||||
Template string `gorm:"column:template;type:varchar(191);comment:模版" json:"template"` // 模版
|
||||
PackageName string `gorm:"column:package_name;type:varchar(191);comment:包名" json:"package_name"` // 包名
|
||||
Module string `gorm:"column:module;type:varchar(191)" json:"module"`
|
||||
}
|
||||
|
||||
// TableName SysAutoCodePackage's table name
|
||||
|
||||
@@ -15,12 +15,12 @@ const TableNameSysBaseMenuBtn = "sys_base_menu_btns"
|
||||
// SysBaseMenuBtn mapped from table <sys_base_menu_btns>
|
||||
type SysBaseMenuBtn struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_sys_base_menu_btns_deleted_at,priority:1" json:"deleted_at"`
|
||||
Name *string `gorm:"column:name;type:varchar(191);comment:按钮关键key" json:"name"` // 按钮关键key
|
||||
Desc *string `gorm:"column:desc;type:varchar(191)" json:"desc"`
|
||||
SysBaseMenuID *int64 `gorm:"column:sys_base_menu_id;type:bigint(20) unsigned;comment:菜单ID" json:"sys_base_menu_id"` // 菜单ID
|
||||
Name string `gorm:"column:name;type:varchar(191);comment:按钮关键key" json:"name"` // 按钮关键key
|
||||
Desc string `gorm:"column:desc;type:varchar(191)" json:"desc"`
|
||||
SysBaseMenuID int64 `gorm:"column:sys_base_menu_id;type:bigint(20) unsigned;comment:菜单ID" json:"sys_base_menu_id"` // 菜单ID
|
||||
}
|
||||
|
||||
// TableName SysBaseMenuBtn's table name
|
||||
|
||||
@@ -15,13 +15,13 @@ const TableNameSysBaseMenuParameter = "sys_base_menu_parameters"
|
||||
// SysBaseMenuParameter mapped from table <sys_base_menu_parameters>
|
||||
type SysBaseMenuParameter struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_sys_base_menu_parameters_deleted_at,priority:1" json:"deleted_at"`
|
||||
SysBaseMenuID *int64 `gorm:"column:sys_base_menu_id;type:bigint(20) unsigned" json:"sys_base_menu_id"`
|
||||
Type *string `gorm:"column:type;type:varchar(191);comment:地址栏携带参数为params还是query" json:"type"` // 地址栏携带参数为params还是query
|
||||
Key *string `gorm:"column:key;type:varchar(191);comment:地址栏携带参数的key" json:"key"` // 地址栏携带参数的key
|
||||
Value *string `gorm:"column:value;type:varchar(191);comment:地址栏携带参数的值" json:"value"` // 地址栏携带参数的值
|
||||
SysBaseMenuID int64 `gorm:"column:sys_base_menu_id;type:bigint(20) unsigned" json:"sys_base_menu_id"`
|
||||
Type string `gorm:"column:type;type:varchar(191);comment:地址栏携带参数为params还是query" json:"type"` // 地址栏携带参数为params还是query
|
||||
Key string `gorm:"column:key;type:varchar(191);comment:地址栏携带参数的key" json:"key"` // 地址栏携带参数的key
|
||||
Value string `gorm:"column:value;type:varchar(191);comment:地址栏携带参数的值" json:"value"` // 地址栏携带参数的值
|
||||
}
|
||||
|
||||
// TableName SysBaseMenuParameter's table name
|
||||
|
||||
@@ -15,23 +15,23 @@ const TableNameSysBaseMenu = "sys_base_menus"
|
||||
// SysBaseMenu mapped from table <sys_base_menus>
|
||||
type SysBaseMenu struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_sys_base_menus_deleted_at,priority:1" json:"deleted_at"`
|
||||
MenuLevel *int64 `gorm:"column:menu_level;type:bigint(20) unsigned" json:"menu_level"`
|
||||
ParentID *int64 `gorm:"column:parent_id;type:bigint(20) unsigned;comment:父菜单ID" json:"parent_id"` // 父菜单ID
|
||||
Path *string `gorm:"column:path;type:varchar(191);comment:路由path" json:"path"` // 路由path
|
||||
Name *string `gorm:"column:name;type:varchar(191);comment:路由name" json:"name"` // 路由name
|
||||
Hidden *bool `gorm:"column:hidden;type:tinyint(1);comment:是否在列表隐藏" json:"hidden"` // 是否在列表隐藏
|
||||
Component *string `gorm:"column:component;type:varchar(191);comment:对应前端文件路径" json:"component"` // 对应前端文件路径
|
||||
Sort *int64 `gorm:"column:sort;type:bigint(20);comment:排序标记" json:"sort"` // 排序标记
|
||||
ActiveName *string `gorm:"column:active_name;type:varchar(191);comment:高亮菜单" json:"active_name"` // 高亮菜单
|
||||
KeepAlive *bool `gorm:"column:keep_alive;type:tinyint(1);comment:是否缓存" json:"keep_alive"` // 是否缓存
|
||||
DefaultMenu *bool `gorm:"column:default_menu;type:tinyint(1);comment:是否是基础路由(开发中)" json:"default_menu"` // 是否是基础路由(开发中)
|
||||
Title *string `gorm:"column:title;type:varchar(191);comment:菜单名" json:"title"` // 菜单名
|
||||
Icon *string `gorm:"column:icon;type:varchar(191);comment:菜单图标" json:"icon"` // 菜单图标
|
||||
CloseTab *bool `gorm:"column:close_tab;type:tinyint(1);comment:自动关闭tab" json:"close_tab"` // 自动关闭tab
|
||||
TransitionType *string `gorm:"column:transition_type;type:varchar(191);comment:路由切换动画" json:"transition_type"` // 路由切换动画
|
||||
MenuLevel int64 `gorm:"column:menu_level;type:bigint(20) unsigned" json:"menu_level"`
|
||||
ParentID int64 `gorm:"column:parent_id;type:bigint(20) unsigned;comment:父菜单ID" json:"parent_id"` // 父菜单ID
|
||||
Path string `gorm:"column:path;type:varchar(191);comment:路由path" json:"path"` // 路由path
|
||||
Name string `gorm:"column:name;type:varchar(191);comment:路由name" json:"name"` // 路由name
|
||||
Hidden bool `gorm:"column:hidden;type:tinyint(1);comment:是否在列表隐藏" json:"hidden"` // 是否在列表隐藏
|
||||
Component string `gorm:"column:component;type:varchar(191);comment:对应前端文件路径" json:"component"` // 对应前端文件路径
|
||||
Sort int64 `gorm:"column:sort;type:bigint(20);comment:排序标记" json:"sort"` // 排序标记
|
||||
ActiveName string `gorm:"column:active_name;type:varchar(191);comment:高亮菜单" json:"active_name"` // 高亮菜单
|
||||
KeepAlive bool `gorm:"column:keep_alive;type:tinyint(1);comment:是否缓存" json:"keep_alive"` // 是否缓存
|
||||
DefaultMenu bool `gorm:"column:default_menu;type:tinyint(1);comment:是否是基础路由(开发中)" json:"default_menu"` // 是否是基础路由(开发中)
|
||||
Title string `gorm:"column:title;type:varchar(191);comment:菜单名" json:"title"` // 菜单名
|
||||
Icon string `gorm:"column:icon;type:varchar(191);comment:菜单图标" json:"icon"` // 菜单图标
|
||||
CloseTab bool `gorm:"column:close_tab;type:tinyint(1);comment:自动关闭tab" json:"close_tab"` // 自动关闭tab
|
||||
TransitionType string `gorm:"column:transition_type;type:varchar(191);comment:路由切换动画" json:"transition_type"` // 路由切换动画
|
||||
}
|
||||
|
||||
// TableName SysBaseMenu's table name
|
||||
|
||||
@@ -15,14 +15,14 @@ const TableNameSysDictionary = "sys_dictionaries"
|
||||
// SysDictionary mapped from table <sys_dictionaries>
|
||||
type SysDictionary struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_sys_dictionaries_deleted_at,priority:1" json:"deleted_at"`
|
||||
Name *string `gorm:"column:name;type:varchar(191);comment:字典名(中)" json:"name"` // 字典名(中)
|
||||
Type *string `gorm:"column:type;type:varchar(191);comment:字典名(英)" json:"type"` // 字典名(英)
|
||||
Status *bool `gorm:"column:status;type:tinyint(1);comment:状态" json:"status"` // 状态
|
||||
Desc *string `gorm:"column:desc;type:varchar(191);comment:描述" json:"desc"` // 描述
|
||||
ParentID *int64 `gorm:"column:parent_id;type:bigint(20) unsigned;comment:父级字典ID" json:"parent_id"` // 父级字典ID
|
||||
Name string `gorm:"column:name;type:varchar(191);comment:字典名(中)" json:"name"` // 字典名(中)
|
||||
Type string `gorm:"column:type;type:varchar(191);comment:字典名(英)" json:"type"` // 字典名(英)
|
||||
Status bool `gorm:"column:status;type:tinyint(1);comment:状态" json:"status"` // 状态
|
||||
Desc string `gorm:"column:desc;type:varchar(191);comment:描述" json:"desc"` // 描述
|
||||
ParentID int64 `gorm:"column:parent_id;type:bigint(20) unsigned;comment:父级字典ID" json:"parent_id"` // 父级字典ID
|
||||
}
|
||||
|
||||
// TableName SysDictionary's table name
|
||||
|
||||
@@ -15,18 +15,18 @@ const TableNameSysDictionaryDetail = "sys_dictionary_details"
|
||||
// SysDictionaryDetail mapped from table <sys_dictionary_details>
|
||||
type SysDictionaryDetail struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_sys_dictionary_details_deleted_at,priority:1" json:"deleted_at"`
|
||||
Label *string `gorm:"column:label;type:varchar(191);comment:展示值" json:"label"` // 展示值
|
||||
Value *string `gorm:"column:value;type:varchar(191);comment:字典值" json:"value"` // 字典值
|
||||
Extend *string `gorm:"column:extend;type:varchar(191);comment:扩展值" json:"extend"` // 扩展值
|
||||
Status *bool `gorm:"column:status;type:tinyint(1);comment:启用状态" json:"status"` // 启用状态
|
||||
Sort *int64 `gorm:"column:sort;type:bigint(20);comment:排序标记" json:"sort"` // 排序标记
|
||||
SysDictionaryID *int64 `gorm:"column:sys_dictionary_id;type:bigint(20) unsigned;comment:关联标记" json:"sys_dictionary_id"` // 关联标记
|
||||
ParentID *int64 `gorm:"column:parent_id;type:bigint(20) unsigned;comment:父级字典详情ID" json:"parent_id"` // 父级字典详情ID
|
||||
Level *int64 `gorm:"column:level;type:bigint(20);comment:层级深度" json:"level"` // 层级深度
|
||||
Path *string `gorm:"column:path;type:varchar(191);comment:层级路径" json:"path"` // 层级路径
|
||||
Label string `gorm:"column:label;type:varchar(191);comment:展示值" json:"label"` // 展示值
|
||||
Value string `gorm:"column:value;type:varchar(191);comment:字典值" json:"value"` // 字典值
|
||||
Extend string `gorm:"column:extend;type:varchar(191);comment:扩展值" json:"extend"` // 扩展值
|
||||
Status bool `gorm:"column:status;type:tinyint(1);comment:启用状态" json:"status"` // 启用状态
|
||||
Sort int64 `gorm:"column:sort;type:bigint(20);comment:排序标记" json:"sort"` // 排序标记
|
||||
SysDictionaryID int64 `gorm:"column:sys_dictionary_id;type:bigint(20) unsigned;comment:关联标记" json:"sys_dictionary_id"` // 关联标记
|
||||
ParentID int64 `gorm:"column:parent_id;type:bigint(20) unsigned;comment:父级字典详情ID" json:"parent_id"` // 父级字典详情ID
|
||||
Level int64 `gorm:"column:level;type:bigint(20);comment:层级深度" json:"level"` // 层级深度
|
||||
Path string `gorm:"column:path;type:varchar(191);comment:层级路径" json:"path"` // 层级路径
|
||||
}
|
||||
|
||||
// TableName SysDictionaryDetail's table name
|
||||
|
||||
@@ -15,14 +15,14 @@ const TableNameSysError = "sys_error"
|
||||
// SysError mapped from table <sys_error>
|
||||
type SysError struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_sys_error_deleted_at,priority:1" json:"deleted_at"`
|
||||
Form *string `gorm:"column:form;type:text;comment:错误来源" json:"form"` // 错误来源
|
||||
Info *string `gorm:"column:info;type:text;comment:错误内容" json:"info"` // 错误内容
|
||||
Level *string `gorm:"column:level;type:varchar(191);comment:日志等级" json:"level"` // 日志等级
|
||||
Solution *string `gorm:"column:solution;type:text;comment:解决方案" json:"solution"` // 解决方案
|
||||
Status *string `gorm:"column:status;type:varchar(20);default:未处理;comment:处理状态" json:"status"` // 处理状态
|
||||
Form string `gorm:"column:form;type:text;comment:错误来源" json:"form"` // 错误来源
|
||||
Info string `gorm:"column:info;type:text;comment:错误内容" json:"info"` // 错误内容
|
||||
Level string `gorm:"column:level;type:varchar(191);comment:日志等级" json:"level"` // 日志等级
|
||||
Solution string `gorm:"column:solution;type:text;comment:解决方案" json:"solution"` // 解决方案
|
||||
Status string `gorm:"column:status;type:varchar(20);default:未处理;comment:处理状态" json:"status"` // 处理状态
|
||||
}
|
||||
|
||||
// TableName SysError's table name
|
||||
|
||||
@@ -15,13 +15,13 @@ const TableNameSysExportTemplateCondition = "sys_export_template_condition"
|
||||
// SysExportTemplateCondition mapped from table <sys_export_template_condition>
|
||||
type SysExportTemplateCondition struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_sys_export_template_condition_deleted_at,priority:1" json:"deleted_at"`
|
||||
TemplateID *string `gorm:"column:template_id;type:varchar(191);comment:模板标识" json:"template_id"` // 模板标识
|
||||
From *string `gorm:"column:from;type:varchar(191);comment:条件取的key" json:"from"` // 条件取的key
|
||||
Column *string `gorm:"column:column;type:varchar(191);comment:作为查询条件的字段" json:"column"` // 作为查询条件的字段
|
||||
Operator *string `gorm:"column:operator;type:varchar(191);comment:操作符" json:"operator"` // 操作符
|
||||
TemplateID string `gorm:"column:template_id;type:varchar(191);comment:模板标识" json:"template_id"` // 模板标识
|
||||
From string `gorm:"column:from;type:varchar(191);comment:条件取的key" json:"from"` // 条件取的key
|
||||
Column string `gorm:"column:column;type:varchar(191);comment:作为查询条件的字段" json:"column"` // 作为查询条件的字段
|
||||
Operator string `gorm:"column:operator;type:varchar(191);comment:操作符" json:"operator"` // 操作符
|
||||
}
|
||||
|
||||
// TableName SysExportTemplateCondition's table name
|
||||
|
||||
@@ -15,13 +15,13 @@ const TableNameSysExportTemplateJoin = "sys_export_template_join"
|
||||
// SysExportTemplateJoin mapped from table <sys_export_template_join>
|
||||
type SysExportTemplateJoin struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_sys_export_template_join_deleted_at,priority:1" json:"deleted_at"`
|
||||
TemplateID *string `gorm:"column:template_id;type:varchar(191);comment:模板标识" json:"template_id"` // 模板标识
|
||||
Joins *string `gorm:"column:joins;type:varchar(191);comment:关联" json:"joins"` // 关联
|
||||
TblName *string `gorm:"column:table;type:varchar(191);comment:关联表" json:"table"` // 关联表
|
||||
On *string `gorm:"column:on;type:varchar(191);comment:关联条件" json:"on"` // 关联条件
|
||||
TemplateID string `gorm:"column:template_id;type:varchar(191);comment:模板标识" json:"template_id"` // 模板标识
|
||||
Joins string `gorm:"column:joins;type:varchar(191);comment:关联" json:"joins"` // 关联
|
||||
TblName string `gorm:"column:table;type:varchar(191);comment:关联表" json:"table"` // 关联表
|
||||
On string `gorm:"column:on;type:varchar(191);comment:关联条件" json:"on"` // 关联条件
|
||||
}
|
||||
|
||||
// TableName SysExportTemplateJoin's table name
|
||||
|
||||
@@ -15,16 +15,16 @@ const TableNameSysExportTemplate = "sys_export_templates"
|
||||
// SysExportTemplate mapped from table <sys_export_templates>
|
||||
type SysExportTemplate struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_sys_export_templates_deleted_at,priority:1" json:"deleted_at"`
|
||||
DbName *string `gorm:"column:db_name;type:varchar(191);comment:数据库名称" json:"db_name"` // 数据库名称
|
||||
Name *string `gorm:"column:name;type:varchar(191);comment:模板名称" json:"name"` // 模板名称
|
||||
TblName *string `gorm:"column:table_name;type:varchar(191);comment:表名称" json:"table_name"` // 表名称
|
||||
TemplateID *string `gorm:"column:template_id;type:varchar(191);comment:模板标识" json:"template_id"` // 模板标识
|
||||
TemplateInfo *string `gorm:"column:template_info;type:text" json:"template_info"`
|
||||
Limit *int64 `gorm:"column:limit;type:bigint(20);comment:导出限制" json:"limit"` // 导出限制
|
||||
Order *string `gorm:"column:order;type:varchar(191);comment:排序" json:"order"` // 排序
|
||||
DbName string `gorm:"column:db_name;type:varchar(191);comment:数据库名称" json:"db_name"` // 数据库名称
|
||||
Name string `gorm:"column:name;type:varchar(191);comment:模板名称" json:"name"` // 模板名称
|
||||
TblName string `gorm:"column:table_name;type:varchar(191);comment:表名称" json:"table_name"` // 表名称
|
||||
TemplateID string `gorm:"column:template_id;type:varchar(191);comment:模板标识" json:"template_id"` // 模板标识
|
||||
TemplateInfo string `gorm:"column:template_info;type:text" json:"template_info"`
|
||||
Limit int64 `gorm:"column:limit;type:bigint(20);comment:导出限制" json:"limit"` // 导出限制
|
||||
Order string `gorm:"column:order;type:varchar(191);comment:排序" json:"order"` // 排序
|
||||
}
|
||||
|
||||
// TableName SysExportTemplate's table name
|
||||
|
||||
@@ -15,11 +15,11 @@ const TableNameSysIgnoreAPI = "sys_ignore_apis"
|
||||
// SysIgnoreAPI mapped from table <sys_ignore_apis>
|
||||
type SysIgnoreAPI struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_sys_ignore_apis_deleted_at,priority:1" json:"deleted_at"`
|
||||
Path *string `gorm:"column:path;type:varchar(191);comment:api路径" json:"path"` // api路径
|
||||
Method *string `gorm:"column:method;type:varchar(191);default:POST;comment:方法" json:"method"` // 方法
|
||||
Path string `gorm:"column:path;type:varchar(191);comment:api路径" json:"path"` // api路径
|
||||
Method string `gorm:"column:method;type:varchar(191);default:POST;comment:方法" json:"method"` // 方法
|
||||
}
|
||||
|
||||
// TableName SysIgnoreAPI's table name
|
||||
|
||||
@@ -15,19 +15,19 @@ const TableNameSysOperationRecord = "sys_operation_records"
|
||||
// SysOperationRecord mapped from table <sys_operation_records>
|
||||
type SysOperationRecord struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_sys_operation_records_deleted_at,priority:1" json:"deleted_at"`
|
||||
IP *string `gorm:"column:ip;type:varchar(191);comment:请求ip" json:"ip"` // 请求ip
|
||||
Method *string `gorm:"column:method;type:varchar(191);comment:请求方法" json:"method"` // 请求方法
|
||||
Path *string `gorm:"column:path;type:varchar(191);comment:请求路径" json:"path"` // 请求路径
|
||||
Status *int64 `gorm:"column:status;type:bigint(20);comment:请求状态" json:"status"` // 请求状态
|
||||
Latency *int64 `gorm:"column:latency;type:bigint(20);comment:延迟" json:"latency"` // 延迟
|
||||
Agent *string `gorm:"column:agent;type:text;comment:代理" json:"agent"` // 代理
|
||||
ErrorMessage *string `gorm:"column:error_message;type:varchar(191);comment:错误信息" json:"error_message"` // 错误信息
|
||||
Body *string `gorm:"column:body;type:text;comment:请求Body" json:"body"` // 请求Body
|
||||
Resp *string `gorm:"column:resp;type:text;comment:响应Body" json:"resp"` // 响应Body
|
||||
UserID *int64 `gorm:"column:user_id;type:bigint(20) unsigned;comment:用户id" json:"user_id"` // 用户id
|
||||
IP string `gorm:"column:ip;type:varchar(191);comment:请求ip" json:"ip"` // 请求ip
|
||||
Method string `gorm:"column:method;type:varchar(191);comment:请求方法" json:"method"` // 请求方法
|
||||
Path string `gorm:"column:path;type:varchar(191);comment:请求路径" json:"path"` // 请求路径
|
||||
Status int64 `gorm:"column:status;type:bigint(20);comment:请求状态" json:"status"` // 请求状态
|
||||
Latency int64 `gorm:"column:latency;type:bigint(20);comment:延迟" json:"latency"` // 延迟
|
||||
Agent string `gorm:"column:agent;type:text;comment:代理" json:"agent"` // 代理
|
||||
ErrorMessage string `gorm:"column:error_message;type:varchar(191);comment:错误信息" json:"error_message"` // 错误信息
|
||||
Body string `gorm:"column:body;type:text;comment:请求Body" json:"body"` // 请求Body
|
||||
Resp string `gorm:"column:resp;type:text;comment:响应Body" json:"resp"` // 响应Body
|
||||
UserID int64 `gorm:"column:user_id;type:bigint(20) unsigned;comment:用户id" json:"user_id"` // 用户id
|
||||
}
|
||||
|
||||
// TableName SysOperationRecord's table name
|
||||
|
||||
@@ -15,13 +15,13 @@ const TableNameSysParam = "sys_params"
|
||||
// SysParam mapped from table <sys_params>
|
||||
type SysParam struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_sys_params_deleted_at,priority:1" json:"deleted_at"`
|
||||
Name *string `gorm:"column:name;type:varchar(191);comment:参数名称" json:"name"` // 参数名称
|
||||
Key *string `gorm:"column:key;type:varchar(191);comment:参数键" json:"key"` // 参数键
|
||||
Value *string `gorm:"column:value;type:varchar(191);comment:参数值" json:"value"` // 参数值
|
||||
Desc *string `gorm:"column:desc;type:varchar(191);comment:参数说明" json:"desc"` // 参数说明
|
||||
Name string `gorm:"column:name;type:varchar(191);comment:参数名称" json:"name"` // 参数名称
|
||||
Key string `gorm:"column:key;type:varchar(191);comment:参数键" json:"key"` // 参数键
|
||||
Value string `gorm:"column:value;type:varchar(191);comment:参数值" json:"value"` // 参数值
|
||||
Desc string `gorm:"column:desc;type:varchar(191);comment:参数说明" json:"desc"` // 参数说明
|
||||
}
|
||||
|
||||
// TableName SysParam's table name
|
||||
|
||||
@@ -15,19 +15,19 @@ const TableNameSysUser = "sys_users"
|
||||
// SysUser mapped from table <sys_users>
|
||||
type SysUser struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_sys_users_deleted_at,priority:1" json:"deleted_at"`
|
||||
UUID *string `gorm:"column:uuid;type:varchar(191);index:idx_sys_users_uuid,priority:1;comment:用户UUID" json:"uuid"` // 用户UUID
|
||||
Username *string `gorm:"column:username;type:varchar(191);index:idx_sys_users_username,priority:1;comment:用户登录名" json:"username"` // 用户登录名
|
||||
Password *string `gorm:"column:password;type:varchar(191);comment:用户登录密码" json:"password"` // 用户登录密码
|
||||
NickName *string `gorm:"column:nick_name;type:varchar(191);default:系统用户;comment:用户昵称" json:"nick_name"` // 用户昵称
|
||||
HeaderImg *string `gorm:"column:header_img;type:varchar(191);default:https://qmplusimg.henrongyi.top/gva_header.jpg;comment:用户头像" json:"header_img"` // 用户头像
|
||||
AuthorityID *int64 `gorm:"column:authority_id;type:bigint(20) unsigned;default:888;comment:用户角色ID" json:"authority_id"` // 用户角色ID
|
||||
Phone *string `gorm:"column:phone;type:varchar(191);comment:用户手机号" json:"phone"` // 用户手机号
|
||||
Email *string `gorm:"column:email;type:varchar(191);comment:用户邮箱" json:"email"` // 用户邮箱
|
||||
Enable *int64 `gorm:"column:enable;type:bigint(20);default:1;comment:用户是否被冻结 1正常 2冻结" json:"enable"` // 用户是否被冻结 1正常 2冻结
|
||||
OriginSetting *string `gorm:"column:origin_setting;type:text;comment:配置" json:"origin_setting"` // 配置
|
||||
UUID string `gorm:"column:uuid;type:varchar(191);index:idx_sys_users_uuid,priority:1;comment:用户UUID" json:"uuid"` // 用户UUID
|
||||
Username string `gorm:"column:username;type:varchar(191);index:idx_sys_users_username,priority:1;comment:用户登录名" json:"username"` // 用户登录名
|
||||
Password string `gorm:"column:password;type:varchar(191);comment:用户登录密码" json:"password"` // 用户登录密码
|
||||
NickName string `gorm:"column:nick_name;type:varchar(191);default:系统用户;comment:用户昵称" json:"nick_name"` // 用户昵称
|
||||
HeaderImg string `gorm:"column:header_img;type:varchar(191);default:https://qmplusimg.henrongyi.top/gva_header.jpg;comment:用户头像" json:"header_img"` // 用户头像
|
||||
AuthorityID int64 `gorm:"column:authority_id;type:bigint(20) unsigned;default:888;comment:用户角色ID" json:"authority_id"` // 用户角色ID
|
||||
Phone string `gorm:"column:phone;type:varchar(191);comment:用户手机号" json:"phone"` // 用户手机号
|
||||
Email string `gorm:"column:email;type:varchar(191);comment:用户邮箱" json:"email"` // 用户邮箱
|
||||
Enable int64 `gorm:"column:enable;type:bigint(20);default:1;comment:用户是否被冻结 1正常 2冻结" json:"enable"` // 用户是否被冻结 1正常 2冻结
|
||||
OriginSetting string `gorm:"column:origin_setting;type:text;comment:配置" json:"origin_setting"` // 配置
|
||||
Authority SysAuthority `gorm:"foreignKey:AuthorityID;references:AuthorityID" json:"authority"`
|
||||
Authorities []SysAuthority `gorm:"joinForeignKey:SysUserID;joinReferences:SysAuthorityAuthorityID;many2many:sys_user_authority" json:"authorities"`
|
||||
}
|
||||
|
||||
@@ -15,13 +15,13 @@ const TableNameSysVersion = "sys_versions"
|
||||
// SysVersion mapped from table <sys_versions>
|
||||
type SysVersion struct {
|
||||
ID int64 `gorm:"column:id;type:bigint(20) unsigned;primaryKey;autoIncrement:true" json:"id"`
|
||||
CreatedAt *time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt *time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:datetime(3)" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime(3)" json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);index:idx_sys_versions_deleted_at,priority:1" json:"deleted_at"`
|
||||
VersionName *string `gorm:"column:version_name;type:varchar(255);comment:版本名称" json:"version_name"` // 版本名称
|
||||
VersionCode *string `gorm:"column:version_code;type:varchar(100);comment:版本号" json:"version_code"` // 版本号
|
||||
Description *string `gorm:"column:description;type:varchar(500);comment:版本描述" json:"description"` // 版本描述
|
||||
VersionData *string `gorm:"column:version_data;type:text;comment:版本数据JSON" json:"version_data"` // 版本数据JSON
|
||||
VersionName string `gorm:"column:version_name;type:varchar(255);comment:版本名称" json:"version_name"` // 版本名称
|
||||
VersionCode string `gorm:"column:version_code;type:varchar(100);comment:版本号" json:"version_code"` // 版本号
|
||||
Description string `gorm:"column:description;type:varchar(500);comment:版本描述" json:"description"` // 版本描述
|
||||
VersionData string `gorm:"column:version_data;type:text;comment:版本数据JSON" json:"version_data"` // 版本数据JSON
|
||||
}
|
||||
|
||||
// TableName SysVersion's table name
|
||||
|
||||
+19
-22
@@ -41,7 +41,7 @@ func (r *apiRepo) Update(ctx context.Context, api *system.Api) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if safeString(old.Path) != api.Path || safeString(old.Method) != api.Method {
|
||||
if old.Path != api.Path || old.Method != api.Method {
|
||||
dup, ferr := query.SysAPI.WithContext(ctx).Where(
|
||||
query.SysAPI.Path.Eq(api.Path),
|
||||
query.SysAPI.Method.Eq(api.Method),
|
||||
@@ -201,18 +201,15 @@ func (r *apiRepo) GetApiGroups(ctx context.Context) ([]string, map[string]string
|
||||
var groups []string
|
||||
|
||||
for _, m := range list {
|
||||
path := safeString(m.Path)
|
||||
apiGroup := safeString(m.APIGroup)
|
||||
|
||||
if !groupMap[apiGroup] {
|
||||
groupMap[apiGroup] = true
|
||||
groups = append(groups, apiGroup)
|
||||
if !groupMap[m.APIGroup] {
|
||||
groupMap[m.APIGroup] = true
|
||||
groups = append(groups, m.APIGroup)
|
||||
}
|
||||
|
||||
if len(path) > 1 {
|
||||
parts := strings.Split(path, "/")
|
||||
if len(m.Path) > 1 {
|
||||
parts := strings.Split(m.Path, "/")
|
||||
if len(parts) > 1 {
|
||||
apiGroupMap[parts[1]] = apiGroup
|
||||
apiGroupMap[parts[1]] = m.APIGroup
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,8 +218,8 @@ func (r *apiRepo) GetApiGroups(ctx context.Context) ([]string, map[string]string
|
||||
|
||||
func (r *apiRepo) CreateIgnoreApi(ctx context.Context, path, method string) error {
|
||||
m := &model.SysIgnoreAPI{
|
||||
Path: &path,
|
||||
Method: &method,
|
||||
Path: path,
|
||||
Method: method,
|
||||
}
|
||||
return r.db.WithContext(ctx).Create(m).Error
|
||||
}
|
||||
@@ -239,8 +236,8 @@ func (r *apiRepo) FindAllIgnoreApis(ctx context.Context) ([]*system.IgnoreApi, e
|
||||
result := make([]*system.IgnoreApi, len(list))
|
||||
for i, m := range list {
|
||||
result[i] = &system.IgnoreApi{
|
||||
Path: safeString(m.Path),
|
||||
Method: safeString(m.Method),
|
||||
Path: m.Path,
|
||||
Method: m.Method,
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
@@ -250,19 +247,19 @@ func (r *apiRepo) FindAllIgnoreApis(ctx context.Context) ([]*system.IgnoreApi, e
|
||||
func toModelAPI(a *system.Api) *model.SysAPI {
|
||||
return &model.SysAPI{
|
||||
ID: int64(a.ID),
|
||||
Path: &a.Path,
|
||||
Description: &a.Description,
|
||||
APIGroup: &a.ApiGroup,
|
||||
Method: &a.Method,
|
||||
Path: a.Path,
|
||||
Description: a.Description,
|
||||
APIGroup: a.ApiGroup,
|
||||
Method: a.Method,
|
||||
}
|
||||
}
|
||||
|
||||
func toBizAPI(m *model.SysAPI) *system.Api {
|
||||
return &system.Api{
|
||||
ID: uint(m.ID),
|
||||
Path: safeString(m.Path),
|
||||
Description: safeString(m.Description),
|
||||
ApiGroup: safeString(m.APIGroup),
|
||||
Method: safeString(m.Method),
|
||||
Path: m.Path,
|
||||
Description: m.Description,
|
||||
ApiGroup: m.APIGroup,
|
||||
Method: m.Method,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,11 @@ func NewAuthorityRepo(db *gorm.DB) system.AuthorityRepo {
|
||||
func (r *authorityRepo) Create(ctx context.Context, auth *system.Authority) error {
|
||||
m := &model.SysAuthority{
|
||||
AuthorityID: int64(auth.AuthorityId),
|
||||
AuthorityName: &auth.AuthorityName,
|
||||
DefaultRouter: &auth.DefaultRouter,
|
||||
AuthorityName: auth.AuthorityName,
|
||||
DefaultRouter: auth.DefaultRouter,
|
||||
}
|
||||
if auth.ParentId != nil {
|
||||
parentId := int64(*auth.ParentId)
|
||||
m.ParentID = &parentId
|
||||
m.ParentID = int64(*auth.ParentId)
|
||||
}
|
||||
return r.db.WithContext(ctx).Create(m).Error
|
||||
}
|
||||
@@ -141,10 +140,7 @@ func (r *authorityRepo) GetParentAuthorityID(ctx context.Context, authorityId ui
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if m.ParentID == nil {
|
||||
return 0, nil
|
||||
}
|
||||
return uint(*m.ParentID), nil
|
||||
return uint(m.ParentID), nil
|
||||
}
|
||||
|
||||
func (r *authorityRepo) SetDataAuthority(ctx context.Context, authorityId uint, dataAuthorityIds []uint) error {
|
||||
@@ -216,9 +212,8 @@ func (r *authorityRepo) CopyAuthorityBtns(ctx context.Context, oldAuthorityId, n
|
||||
return nil
|
||||
}
|
||||
|
||||
newAuthorityIdInt64 := int64(newAuthorityId)
|
||||
for i := range btns {
|
||||
btns[i].AuthorityID = &newAuthorityIdInt64
|
||||
btns[i].AuthorityID = int64(newAuthorityId)
|
||||
}
|
||||
|
||||
return r.db.WithContext(ctx).Create(&btns).Error
|
||||
@@ -258,11 +253,11 @@ func (r *authorityRepo) DeleteAuthorityRelations(ctx context.Context, authorityI
|
||||
func toBizAuthority(m *model.SysAuthority) *system.Authority {
|
||||
auth := &system.Authority{
|
||||
AuthorityId: uint(m.AuthorityID),
|
||||
AuthorityName: safeString(m.AuthorityName),
|
||||
DefaultRouter: safeString(m.DefaultRouter),
|
||||
AuthorityName: m.AuthorityName,
|
||||
DefaultRouter: m.DefaultRouter,
|
||||
}
|
||||
if m.ParentID != nil {
|
||||
parentId := uint(*m.ParentID)
|
||||
if m.ParentID != 0 {
|
||||
parentId := uint(m.ParentID)
|
||||
auth.ParentId = &parentId
|
||||
}
|
||||
return auth
|
||||
|
||||
@@ -0,0 +1,472 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"kra/internal/biz/system"
|
||||
"kra/internal/data/model"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type dictionaryRepo struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
// NewDictionaryRepo 创建字典仓储
|
||||
func NewDictionaryRepo(db *gorm.DB) system.DictionaryRepo {
|
||||
return &dictionaryRepo{db: db}
|
||||
}
|
||||
|
||||
func (r *dictionaryRepo) Create(ctx context.Context, dict *system.Dictionary) error {
|
||||
m := toModelDictionary(dict)
|
||||
if err := r.db.WithContext(ctx).Create(m).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
dict.ID = uint(m.ID)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *dictionaryRepo) Update(ctx context.Context, dict *system.Dictionary) error {
|
||||
updates := map[string]interface{}{
|
||||
"name": dict.Name,
|
||||
"type": dict.Type,
|
||||
"status": dict.Status,
|
||||
"desc": dict.Desc,
|
||||
"parent_id": dict.ParentID,
|
||||
}
|
||||
return r.db.WithContext(ctx).Model(&model.SysDictionary{}).Where("id = ?", dict.ID).Updates(updates).Error
|
||||
}
|
||||
|
||||
func (r *dictionaryRepo) Delete(ctx context.Context, id uint) error {
|
||||
return r.db.WithContext(ctx).Delete(&model.SysDictionary{}, id).Error
|
||||
}
|
||||
|
||||
func (r *dictionaryRepo) FindByID(ctx context.Context, id uint) (*system.Dictionary, error) {
|
||||
var m model.SysDictionary
|
||||
if err := r.db.WithContext(ctx).First(&m, id).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return toBizDictionary(&m), nil
|
||||
}
|
||||
|
||||
func (r *dictionaryRepo) FindByType(ctx context.Context, typ string) (*system.Dictionary, error) {
|
||||
var m model.SysDictionary
|
||||
if err := r.db.WithContext(ctx).Where("type = ?", typ).First(&m).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return toBizDictionary(&m), nil
|
||||
}
|
||||
|
||||
func (r *dictionaryRepo) GetByTypeOrID(ctx context.Context, typ string, id uint, status *bool) (*system.Dictionary, error) {
|
||||
flag := true
|
||||
if status != nil {
|
||||
flag = *status
|
||||
}
|
||||
var m model.SysDictionary
|
||||
db := r.db.WithContext(ctx).Where("(type = ? OR id = ?) AND status = ?", typ, id, flag)
|
||||
if err := db.First(&m).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dict := toBizDictionary(&m)
|
||||
// 加载详情
|
||||
var details []model.SysDictionaryDetail
|
||||
r.db.WithContext(ctx).Where("sys_dictionary_id = ? AND status = ?", m.ID, true).Order("sort").Find(&details)
|
||||
// 详情在service层处理
|
||||
return dict, nil
|
||||
}
|
||||
|
||||
func (r *dictionaryRepo) List(ctx context.Context, name string) ([]*system.Dictionary, error) {
|
||||
db := r.db.WithContext(ctx).Model(&model.SysDictionary{})
|
||||
if name != "" {
|
||||
db = db.Where("name LIKE ? OR type LIKE ?", "%"+name+"%", "%"+name+"%")
|
||||
}
|
||||
// 预加载子字典
|
||||
db = db.Preload("Children")
|
||||
var list []model.SysDictionary
|
||||
if err := db.Find(&list).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := make([]*system.Dictionary, len(list))
|
||||
for i, m := range list {
|
||||
result[i] = toBizDictionary(&m)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r *dictionaryRepo) CheckCircularReference(ctx context.Context, currentID, parentID uint) error {
|
||||
if currentID == parentID {
|
||||
return errors.New("不能将字典设置为自己的父级")
|
||||
}
|
||||
var parent model.SysDictionary
|
||||
if err := r.db.WithContext(ctx).Where("id = ?", parentID).First(&parent).Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
if parent.ParentID != 0 {
|
||||
return r.CheckCircularReference(ctx, currentID, uint(parent.ParentID))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type dictionaryDetailRepo struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
// NewDictionaryDetailRepo 创建字典详情仓储
|
||||
func NewDictionaryDetailRepo(db *gorm.DB) system.DictionaryDetailRepo {
|
||||
return &dictionaryDetailRepo{db: db}
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) Create(ctx context.Context, detail *system.DictionaryDetail) error {
|
||||
m := toModelDictionaryDetail(detail)
|
||||
if err := r.db.WithContext(ctx).Create(m).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
detail.ID = uint(m.ID)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) Update(ctx context.Context, detail *system.DictionaryDetail) error {
|
||||
m := toModelDictionaryDetail(detail)
|
||||
return r.db.WithContext(ctx).Save(m).Error
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) Delete(ctx context.Context, id uint) error {
|
||||
return r.db.WithContext(ctx).Delete(&model.SysDictionaryDetail{}, id).Error
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) FindByID(ctx context.Context, id uint) (*system.DictionaryDetail, error) {
|
||||
var m model.SysDictionaryDetail
|
||||
if err := r.db.WithContext(ctx).First(&m, id).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return toBizDictionaryDetail(&m), nil
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) List(ctx context.Context, page, pageSize int, filters map[string]interface{}) ([]*system.DictionaryDetail, int64, error) {
|
||||
db := r.db.WithContext(ctx).Model(&model.SysDictionaryDetail{})
|
||||
if v, ok := filters["label"]; ok && v != "" {
|
||||
db = db.Where("label LIKE ?", "%"+v.(string)+"%")
|
||||
}
|
||||
if v, ok := filters["value"]; ok && v != "" {
|
||||
db = db.Where("value = ?", v)
|
||||
}
|
||||
if v, ok := filters["status"]; ok {
|
||||
db = db.Where("status = ?", v)
|
||||
}
|
||||
if v, ok := filters["sys_dictionary_id"]; ok && v.(uint) != 0 {
|
||||
db = db.Where("sys_dictionary_id = ?", v)
|
||||
}
|
||||
if v, ok := filters["parent_id"]; ok {
|
||||
db = db.Where("parent_id = ?", v)
|
||||
}
|
||||
if v, ok := filters["level"]; ok {
|
||||
db = db.Where("level = ?", v)
|
||||
}
|
||||
|
||||
var total int64
|
||||
if err := db.Count(&total).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
offset := (page - 1) * pageSize
|
||||
var list []model.SysDictionaryDetail
|
||||
if err := db.Offset(offset).Limit(pageSize).Order("sort").Order("id").Find(&list).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
result := make([]*system.DictionaryDetail, len(list))
|
||||
for i, m := range list {
|
||||
result[i] = toBizDictionaryDetail(&m)
|
||||
}
|
||||
return result, total, nil
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) GetListByDictionaryID(ctx context.Context, dictionaryID uint) ([]*system.DictionaryDetail, error) {
|
||||
var list []model.SysDictionaryDetail
|
||||
if err := r.db.WithContext(ctx).Where("sys_dictionary_id = ?", dictionaryID).Find(&list).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := make([]*system.DictionaryDetail, len(list))
|
||||
for i, m := range list {
|
||||
result[i] = toBizDictionaryDetail(&m)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) GetTreeList(ctx context.Context, dictionaryID uint) ([]*system.DictionaryDetail, error) {
|
||||
var list []model.SysDictionaryDetail
|
||||
if err := r.db.WithContext(ctx).Where("sys_dictionary_id = ? AND parent_id IS NULL", dictionaryID).Order("sort").Find(&list).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := make([]*system.DictionaryDetail, len(list))
|
||||
for i, m := range list {
|
||||
result[i] = toBizDictionaryDetail(&m)
|
||||
r.setDisabled(result[i])
|
||||
if err := r.loadChildren(ctx, result[i]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) loadChildren(ctx context.Context, detail *system.DictionaryDetail) error {
|
||||
var children []model.SysDictionaryDetail
|
||||
if err := r.db.WithContext(ctx).Where("parent_id = ?", detail.ID).Order("sort").Find(&children).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
for _, m := range children {
|
||||
child := toBizDictionaryDetail(&m)
|
||||
r.setDisabled(child)
|
||||
if err := r.loadChildren(ctx, child); err != nil {
|
||||
return err
|
||||
}
|
||||
detail.Children = append(detail.Children, child)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) setDisabled(detail *system.DictionaryDetail) {
|
||||
if detail.Status != nil {
|
||||
detail.Disabled = !*detail.Status
|
||||
} else {
|
||||
detail.Disabled = false
|
||||
}
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) GetByParent(ctx context.Context, dictionaryID uint, parentID *uint, includeChildren bool) ([]*system.DictionaryDetail, error) {
|
||||
db := r.db.WithContext(ctx).Model(&model.SysDictionaryDetail{}).Where("sys_dictionary_id = ?", dictionaryID)
|
||||
if parentID != nil {
|
||||
db = db.Where("parent_id = ?", *parentID)
|
||||
} else {
|
||||
db = db.Where("parent_id IS NULL")
|
||||
}
|
||||
var list []model.SysDictionaryDetail
|
||||
if err := db.Order("sort").Find(&list).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := make([]*system.DictionaryDetail, len(list))
|
||||
for i, m := range list {
|
||||
result[i] = toBizDictionaryDetail(&m)
|
||||
r.setDisabled(result[i])
|
||||
if includeChildren {
|
||||
if err := r.loadChildren(ctx, result[i]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) GetByDictionaryIDAndValue(ctx context.Context, dictionaryID uint, value string) (*system.DictionaryDetail, error) {
|
||||
var m model.SysDictionaryDetail
|
||||
if err := r.db.WithContext(ctx).Where("sys_dictionary_id = ? AND value = ?", dictionaryID, value).First(&m).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return toBizDictionaryDetail(&m), nil
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) GetByTypeAndValue(ctx context.Context, typ, value string) (*system.DictionaryDetail, error) {
|
||||
var m model.SysDictionaryDetail
|
||||
if err := r.db.WithContext(ctx).Model(&model.SysDictionaryDetail{}).
|
||||
Joins("JOIN sys_dictionaries ON sys_dictionaries.id = sys_dictionary_details.sys_dictionary_id").
|
||||
Where("sys_dictionaries.type = ? AND sys_dictionary_details.value = ?", typ, value).
|
||||
First(&m).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return toBizDictionaryDetail(&m), nil
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) GetTreeListByType(ctx context.Context, typ string) ([]*system.DictionaryDetail, error) {
|
||||
var list []model.SysDictionaryDetail
|
||||
if err := r.db.WithContext(ctx).Model(&model.SysDictionaryDetail{}).
|
||||
Joins("JOIN sys_dictionaries ON sys_dictionaries.id = sys_dictionary_details.sys_dictionary_id").
|
||||
Where("sys_dictionaries.type = ? AND sys_dictionary_details.parent_id IS NULL", typ).
|
||||
Order("sys_dictionary_details.sort").
|
||||
Find(&list).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := make([]*system.DictionaryDetail, len(list))
|
||||
for i, m := range list {
|
||||
result[i] = toBizDictionaryDetail(&m)
|
||||
r.setDisabled(result[i])
|
||||
if err := r.loadChildren(ctx, result[i]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) GetListByType(ctx context.Context, typ string) ([]*system.DictionaryDetail, error) {
|
||||
var list []model.SysDictionaryDetail
|
||||
if err := r.db.WithContext(ctx).Model(&model.SysDictionaryDetail{}).
|
||||
Joins("JOIN sys_dictionaries ON sys_dictionaries.id = sys_dictionary_details.sys_dictionary_id").
|
||||
Where("sys_dictionaries.type = ?", typ).
|
||||
Find(&list).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result := make([]*system.DictionaryDetail, len(list))
|
||||
for i, m := range list {
|
||||
result[i] = toBizDictionaryDetail(&m)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) HasChildren(ctx context.Context, id uint) (bool, error) {
|
||||
var count int64
|
||||
if err := r.db.WithContext(ctx).Model(&model.SysDictionaryDetail{}).Where("parent_id = ?", id).Count(&count).Error; err != nil {
|
||||
return false, err
|
||||
}
|
||||
return count > 0, nil
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) CheckCircularReference(ctx context.Context, id, parentID uint) bool {
|
||||
if id == parentID {
|
||||
return true
|
||||
}
|
||||
var parent model.SysDictionaryDetail
|
||||
if err := r.db.WithContext(ctx).First(&parent, parentID).Error; err != nil {
|
||||
return false
|
||||
}
|
||||
if parent.ParentID == 0 {
|
||||
return false
|
||||
}
|
||||
return r.CheckCircularReference(ctx, id, uint(parent.ParentID))
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) UpdateChildrenLevelAndPath(ctx context.Context, parentID uint) error {
|
||||
var children []model.SysDictionaryDetail
|
||||
if err := r.db.WithContext(ctx).Where("parent_id = ?", parentID).Find(&children).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
var parent model.SysDictionaryDetail
|
||||
if err := r.db.WithContext(ctx).First(&parent, parentID).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
for _, child := range children {
|
||||
child.Level = parent.Level + 1
|
||||
if parent.Path == "" {
|
||||
child.Path = strconv.Itoa(int(parent.ID))
|
||||
} else {
|
||||
child.Path = parent.Path + "," + strconv.Itoa(int(parent.ID))
|
||||
}
|
||||
if err := r.db.WithContext(ctx).Save(&child).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if err := r.UpdateChildrenLevelAndPath(ctx, uint(child.ID)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) GetPath(ctx context.Context, id uint) ([]*system.DictionaryDetail, error) {
|
||||
var m model.SysDictionaryDetail
|
||||
if err := r.db.WithContext(ctx).First(&m, id).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
detail := toBizDictionaryDetail(&m)
|
||||
path := []*system.DictionaryDetail{detail}
|
||||
if m.ParentID != 0 {
|
||||
parentPath, err := r.GetPath(ctx, uint(m.ParentID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
path = append(parentPath, path...)
|
||||
}
|
||||
return path, nil
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) DeleteByDictionaryID(ctx context.Context, dictionaryID uint) error {
|
||||
return r.db.WithContext(ctx).Where("sys_dictionary_id = ?", dictionaryID).Delete(&model.SysDictionaryDetail{}).Error
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) BatchCreate(ctx context.Context, details []*system.DictionaryDetail) error {
|
||||
models := make([]*model.SysDictionaryDetail, len(details))
|
||||
for i, d := range details {
|
||||
models[i] = toModelDictionaryDetail(d)
|
||||
}
|
||||
return r.db.WithContext(ctx).Create(&models).Error
|
||||
}
|
||||
|
||||
func (r *dictionaryDetailRepo) BatchUpdateParentID(ctx context.Context, idMap map[uint]uint) error {
|
||||
// idMap: oldID -> newID
|
||||
// 这里需要根据实际导入逻辑处理
|
||||
return nil
|
||||
}
|
||||
|
||||
// 转换函数
|
||||
func toModelDictionary(d *system.Dictionary) *model.SysDictionary {
|
||||
m := &model.SysDictionary{
|
||||
ID: int64(d.ID),
|
||||
Name: d.Name,
|
||||
Type: d.Type,
|
||||
Desc: d.Desc,
|
||||
}
|
||||
if d.Status != nil {
|
||||
m.Status = *d.Status
|
||||
}
|
||||
if d.ParentID != nil {
|
||||
m.ParentID = int64(*d.ParentID)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func toBizDictionary(m *model.SysDictionary) *system.Dictionary {
|
||||
d := &system.Dictionary{
|
||||
ID: uint(m.ID),
|
||||
Name: m.Name,
|
||||
Type: m.Type,
|
||||
Status: &m.Status,
|
||||
Desc: m.Desc,
|
||||
}
|
||||
if m.ParentID != 0 {
|
||||
pid := uint(m.ParentID)
|
||||
d.ParentID = &pid
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
func toModelDictionaryDetail(d *system.DictionaryDetail) *model.SysDictionaryDetail {
|
||||
m := &model.SysDictionaryDetail{
|
||||
ID: int64(d.ID),
|
||||
Label: d.Label,
|
||||
Value: d.Value,
|
||||
Extend: d.Extend,
|
||||
Sort: int64(d.Sort),
|
||||
SysDictionaryID: int64(d.SysDictionaryID),
|
||||
Level: int64(d.Level),
|
||||
Path: d.Path,
|
||||
}
|
||||
if d.Status != nil {
|
||||
m.Status = *d.Status
|
||||
}
|
||||
if d.ParentID != nil {
|
||||
m.ParentID = int64(*d.ParentID)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func toBizDictionaryDetail(m *model.SysDictionaryDetail) *system.DictionaryDetail {
|
||||
d := &system.DictionaryDetail{
|
||||
ID: uint(m.ID),
|
||||
Label: m.Label,
|
||||
Value: m.Value,
|
||||
Extend: m.Extend,
|
||||
Status: &m.Status,
|
||||
Sort: int(m.Sort),
|
||||
SysDictionaryID: uint(m.SysDictionaryID),
|
||||
Level: int(m.Level),
|
||||
Path: m.Path,
|
||||
}
|
||||
if m.ParentID != 0 {
|
||||
pid := uint(m.ParentID)
|
||||
d.ParentID = &pid
|
||||
}
|
||||
return d
|
||||
}
|
||||
@@ -76,10 +76,10 @@ func (r *menuRepo) CreateBaseMenu(ctx context.Context, menu *system.BaseMenu) er
|
||||
if len(menu.Parameters) > 0 {
|
||||
for _, p := range menu.Parameters {
|
||||
param := &model.SysBaseMenuParameter{
|
||||
SysBaseMenuID: ptrInt64(int64(m.ID)),
|
||||
Type: &p.Type,
|
||||
Key: &p.Key,
|
||||
Value: &p.Value,
|
||||
SysBaseMenuID: int64(m.ID),
|
||||
Type: p.Type,
|
||||
Key: p.Key,
|
||||
Value: p.Value,
|
||||
}
|
||||
if err := tx.Create(param).Error; err != nil {
|
||||
return err
|
||||
@@ -91,9 +91,9 @@ func (r *menuRepo) CreateBaseMenu(ctx context.Context, menu *system.BaseMenu) er
|
||||
if len(menu.MenuBtn) > 0 {
|
||||
for _, b := range menu.MenuBtn {
|
||||
btn := &model.SysBaseMenuBtn{
|
||||
SysBaseMenuID: ptrInt64(int64(m.ID)),
|
||||
Name: &b.Name,
|
||||
Desc: &b.Desc,
|
||||
SysBaseMenuID: int64(m.ID),
|
||||
Name: b.Name,
|
||||
Desc: b.Desc,
|
||||
}
|
||||
if err := tx.Create(btn).Error; err != nil {
|
||||
return err
|
||||
@@ -115,7 +115,7 @@ func (r *menuRepo) UpdateBaseMenu(ctx context.Context, menu *system.BaseMenu) er
|
||||
}
|
||||
|
||||
// 检查name是否重复
|
||||
if safeString(oldMenu.Name) != menu.Name {
|
||||
if oldMenu.Name != menu.Name {
|
||||
var count int64
|
||||
if err := tx.Model(&model.SysBaseMenu{}).Where("id <> ? AND name = ?", menu.ID, menu.Name).Count(&count).Error; err != nil {
|
||||
return err
|
||||
@@ -137,10 +137,10 @@ func (r *menuRepo) UpdateBaseMenu(ctx context.Context, menu *system.BaseMenu) er
|
||||
if len(menu.Parameters) > 0 {
|
||||
for _, p := range menu.Parameters {
|
||||
param := &model.SysBaseMenuParameter{
|
||||
SysBaseMenuID: ptrInt64(int64(menu.ID)),
|
||||
Type: &p.Type,
|
||||
Key: &p.Key,
|
||||
Value: &p.Value,
|
||||
SysBaseMenuID: int64(menu.ID),
|
||||
Type: p.Type,
|
||||
Key: p.Key,
|
||||
Value: p.Value,
|
||||
}
|
||||
if err := tx.Create(param).Error; err != nil {
|
||||
return err
|
||||
@@ -152,9 +152,9 @@ func (r *menuRepo) UpdateBaseMenu(ctx context.Context, menu *system.BaseMenu) er
|
||||
if len(menu.MenuBtn) > 0 {
|
||||
for _, b := range menu.MenuBtn {
|
||||
btn := &model.SysBaseMenuBtn{
|
||||
SysBaseMenuID: ptrInt64(int64(menu.ID)),
|
||||
Name: &b.Name,
|
||||
Desc: &b.Desc,
|
||||
SysBaseMenuID: int64(menu.ID),
|
||||
Name: b.Name,
|
||||
Desc: b.Desc,
|
||||
}
|
||||
if err := tx.Create(btn).Error; err != nil {
|
||||
return err
|
||||
@@ -295,9 +295,7 @@ func (r *menuRepo) FindAllBaseMenus(ctx context.Context) ([]*system.BaseMenu, er
|
||||
r.db.WithContext(ctx).Find(&allParams)
|
||||
paramMap := make(map[int64][]model.SysBaseMenuParameter)
|
||||
for _, p := range allParams {
|
||||
if p.SysBaseMenuID != nil {
|
||||
paramMap[*p.SysBaseMenuID] = append(paramMap[*p.SysBaseMenuID], p)
|
||||
}
|
||||
paramMap[p.SysBaseMenuID] = append(paramMap[p.SysBaseMenuID], p)
|
||||
}
|
||||
|
||||
// 获取所有按钮
|
||||
@@ -305,9 +303,7 @@ func (r *menuRepo) FindAllBaseMenus(ctx context.Context) ([]*system.BaseMenu, er
|
||||
r.db.WithContext(ctx).Find(&allBtns)
|
||||
btnMap := make(map[int64][]model.SysBaseMenuBtn)
|
||||
for _, b := range allBtns {
|
||||
if b.SysBaseMenuID != nil {
|
||||
btnMap[*b.SysBaseMenuID] = append(btnMap[*b.SysBaseMenuID], b)
|
||||
}
|
||||
btnMap[b.SysBaseMenuID] = append(btnMap[b.SysBaseMenuID], b)
|
||||
}
|
||||
|
||||
result := make([]*system.BaseMenu, len(menus))
|
||||
@@ -329,9 +325,7 @@ func (r *menuRepo) FindBaseMenusByIds(ctx context.Context, ids []string) ([]*sys
|
||||
r.db.WithContext(ctx).Where("sys_base_menu_id in (?)", ids).Find(&allParams)
|
||||
paramMap := make(map[int64][]model.SysBaseMenuParameter)
|
||||
for _, p := range allParams {
|
||||
if p.SysBaseMenuID != nil {
|
||||
paramMap[*p.SysBaseMenuID] = append(paramMap[*p.SysBaseMenuID], p)
|
||||
}
|
||||
paramMap[p.SysBaseMenuID] = append(paramMap[p.SysBaseMenuID], p)
|
||||
}
|
||||
|
||||
// 获取按钮
|
||||
@@ -339,9 +333,7 @@ func (r *menuRepo) FindBaseMenusByIds(ctx context.Context, ids []string) ([]*sys
|
||||
r.db.WithContext(ctx).Where("sys_base_menu_id in (?)", ids).Find(&allBtns)
|
||||
btnMap := make(map[int64][]model.SysBaseMenuBtn)
|
||||
for _, b := range allBtns {
|
||||
if b.SysBaseMenuID != nil {
|
||||
btnMap[*b.SysBaseMenuID] = append(btnMap[*b.SysBaseMenuID], b)
|
||||
}
|
||||
btnMap[b.SysBaseMenuID] = append(btnMap[b.SysBaseMenuID], b)
|
||||
}
|
||||
|
||||
result := make([]*system.BaseMenu, len(menus))
|
||||
@@ -374,9 +366,7 @@ func (r *menuRepo) FindAuthorityBtns(ctx context.Context, authorityId uint) ([]*
|
||||
// 获取按钮名称
|
||||
var btnIds []int64
|
||||
for _, b := range btns {
|
||||
if b.SysBaseMenuBtnID != nil {
|
||||
btnIds = append(btnIds, *b.SysBaseMenuBtnID)
|
||||
}
|
||||
btnIds = append(btnIds, b.SysBaseMenuBtnID)
|
||||
}
|
||||
|
||||
btnNameMap := make(map[int64]string)
|
||||
@@ -384,22 +374,17 @@ func (r *menuRepo) FindAuthorityBtns(ctx context.Context, authorityId uint) ([]*
|
||||
var menuBtns []model.SysBaseMenuBtn
|
||||
r.db.WithContext(ctx).Where("id in (?)", btnIds).Find(&menuBtns)
|
||||
for _, mb := range menuBtns {
|
||||
btnNameMap[mb.ID] = safeString(mb.Name)
|
||||
btnNameMap[mb.ID] = mb.Name
|
||||
}
|
||||
}
|
||||
|
||||
result := make([]*system.AuthorityBtn, len(btns))
|
||||
for i, b := range btns {
|
||||
result[i] = &system.AuthorityBtn{}
|
||||
if b.AuthorityID != nil {
|
||||
result[i].AuthorityId = uint(*b.AuthorityID)
|
||||
}
|
||||
if b.SysMenuID != nil {
|
||||
result[i].SysMenuID = uint(*b.SysMenuID)
|
||||
}
|
||||
if b.SysBaseMenuBtnID != nil {
|
||||
result[i].SysBaseMenuBtnID = uint(*b.SysBaseMenuBtnID)
|
||||
result[i].BtnName = btnNameMap[*b.SysBaseMenuBtnID]
|
||||
result[i] = &system.AuthorityBtn{
|
||||
AuthorityId: uint(b.AuthorityID),
|
||||
SysMenuID: uint(b.SysMenuID),
|
||||
SysBaseMenuBtnID: uint(b.SysBaseMenuBtnID),
|
||||
BtnName: btnNameMap[b.SysBaseMenuBtnID],
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
@@ -429,55 +414,40 @@ func (r *menuRepo) SetMenuAuthority(ctx context.Context, authorityId uint, menuI
|
||||
|
||||
// 转换函数
|
||||
func toModelBaseMenu(m *system.BaseMenu) *model.SysBaseMenu {
|
||||
parentId := int64(m.ParentId)
|
||||
sort := int64(m.Sort)
|
||||
|
||||
return &model.SysBaseMenu{
|
||||
ID: int64(m.ID),
|
||||
ParentID: &parentId,
|
||||
Path: &m.Path,
|
||||
Name: &m.Name,
|
||||
Hidden: &m.Hidden,
|
||||
Component: &m.Component,
|
||||
Sort: &sort,
|
||||
ActiveName: &m.ActiveName,
|
||||
KeepAlive: &m.KeepAlive,
|
||||
DefaultMenu: &m.DefaultMenu,
|
||||
Title: &m.Title,
|
||||
Icon: &m.Icon,
|
||||
CloseTab: &m.CloseTab,
|
||||
TransitionType: &m.TransitionType,
|
||||
ParentID: int64(m.ParentId),
|
||||
Path: m.Path,
|
||||
Name: m.Name,
|
||||
Hidden: m.Hidden,
|
||||
Component: m.Component,
|
||||
Sort: int64(m.Sort),
|
||||
ActiveName: m.ActiveName,
|
||||
KeepAlive: m.KeepAlive,
|
||||
DefaultMenu: m.DefaultMenu,
|
||||
Title: m.Title,
|
||||
Icon: m.Icon,
|
||||
CloseTab: m.CloseTab,
|
||||
TransitionType: m.TransitionType,
|
||||
}
|
||||
}
|
||||
|
||||
func toBizBaseMenu(m *model.SysBaseMenu, params []model.SysBaseMenuParameter, btns []model.SysBaseMenuBtn) *system.BaseMenu {
|
||||
menu := &system.BaseMenu{
|
||||
ID: uint(m.ID),
|
||||
Path: safeString(m.Path),
|
||||
Name: safeString(m.Name),
|
||||
Component: safeString(m.Component),
|
||||
ActiveName: safeString(m.ActiveName),
|
||||
Title: safeString(m.Title),
|
||||
Icon: safeString(m.Icon),
|
||||
TransitionType: safeString(m.TransitionType),
|
||||
}
|
||||
if m.ParentID != nil {
|
||||
menu.ParentId = uint(*m.ParentID)
|
||||
}
|
||||
if m.Sort != nil {
|
||||
menu.Sort = int(*m.Sort)
|
||||
}
|
||||
if m.Hidden != nil {
|
||||
menu.Hidden = *m.Hidden
|
||||
}
|
||||
if m.KeepAlive != nil {
|
||||
menu.KeepAlive = *m.KeepAlive
|
||||
}
|
||||
if m.DefaultMenu != nil {
|
||||
menu.DefaultMenu = *m.DefaultMenu
|
||||
}
|
||||
if m.CloseTab != nil {
|
||||
menu.CloseTab = *m.CloseTab
|
||||
ParentId: uint(m.ParentID),
|
||||
Path: m.Path,
|
||||
Name: m.Name,
|
||||
Hidden: m.Hidden,
|
||||
Component: m.Component,
|
||||
Sort: int(m.Sort),
|
||||
ActiveName: m.ActiveName,
|
||||
KeepAlive: m.KeepAlive,
|
||||
DefaultMenu: m.DefaultMenu,
|
||||
Title: m.Title,
|
||||
Icon: m.Icon,
|
||||
CloseTab: m.CloseTab,
|
||||
TransitionType: m.TransitionType,
|
||||
}
|
||||
|
||||
// 转换参数
|
||||
@@ -485,13 +455,11 @@ func toBizBaseMenu(m *model.SysBaseMenu, params []model.SysBaseMenuParameter, bt
|
||||
menu.Parameters = make([]*system.MenuParameter, len(params))
|
||||
for i, p := range params {
|
||||
menu.Parameters[i] = &system.MenuParameter{
|
||||
ID: uint(p.ID),
|
||||
Type: safeString(p.Type),
|
||||
Key: safeString(p.Key),
|
||||
Value: safeString(p.Value),
|
||||
}
|
||||
if p.SysBaseMenuID != nil {
|
||||
menu.Parameters[i].SysBaseMenuID = uint(*p.SysBaseMenuID)
|
||||
ID: uint(p.ID),
|
||||
SysBaseMenuID: uint(p.SysBaseMenuID),
|
||||
Type: p.Type,
|
||||
Key: p.Key,
|
||||
Value: p.Value,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -501,12 +469,10 @@ func toBizBaseMenu(m *model.SysBaseMenu, params []model.SysBaseMenuParameter, bt
|
||||
menu.MenuBtn = make([]*system.MenuBtn, len(btns))
|
||||
for i, b := range btns {
|
||||
menu.MenuBtn[i] = &system.MenuBtn{
|
||||
ID: uint(b.ID),
|
||||
Name: safeString(b.Name),
|
||||
Desc: safeString(b.Desc),
|
||||
}
|
||||
if b.SysBaseMenuID != nil {
|
||||
menu.MenuBtn[i].SysBaseMenuID = uint(*b.SysBaseMenuID)
|
||||
ID: uint(b.ID),
|
||||
SysBaseMenuID: uint(b.SysBaseMenuID),
|
||||
Name: b.Name,
|
||||
Desc: b.Desc,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"kra/internal/biz/system"
|
||||
"kra/internal/data/model"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type operationRecordRepo struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
// NewOperationRecordRepo 创建操作记录仓储
|
||||
func NewOperationRecordRepo(db *gorm.DB) system.OperationRecordRepo {
|
||||
return &operationRecordRepo{db: db}
|
||||
}
|
||||
|
||||
func (r *operationRecordRepo) Create(ctx context.Context, record *system.OperationRecord) error {
|
||||
m := toModelOperationRecord(record)
|
||||
if err := r.db.WithContext(ctx).Create(m).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
record.ID = uint(m.ID)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *operationRecordRepo) Delete(ctx context.Context, id uint) error {
|
||||
return r.db.WithContext(ctx).Delete(&model.SysOperationRecord{}, id).Error
|
||||
}
|
||||
|
||||
func (r *operationRecordRepo) DeleteByIds(ctx context.Context, ids []uint) error {
|
||||
return r.db.WithContext(ctx).Delete(&model.SysOperationRecord{}, "id in (?)", ids).Error
|
||||
}
|
||||
|
||||
func (r *operationRecordRepo) FindByID(ctx context.Context, id uint) (*system.OperationRecord, error) {
|
||||
var m model.SysOperationRecord
|
||||
if err := r.db.WithContext(ctx).Where("id = ?", id).First(&m).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return toBizOperationRecord(&m, nil), nil
|
||||
}
|
||||
|
||||
func (r *operationRecordRepo) List(ctx context.Context, page, pageSize int, filters map[string]interface{}) ([]*system.OperationRecord, int64, error) {
|
||||
db := r.db.WithContext(ctx).Model(&model.SysOperationRecord{})
|
||||
|
||||
if v, ok := filters["method"]; ok && v != "" {
|
||||
db = db.Where("method = ?", v)
|
||||
}
|
||||
if v, ok := filters["path"]; ok && v != "" {
|
||||
db = db.Where("path LIKE ?", "%"+v.(string)+"%")
|
||||
}
|
||||
if v, ok := filters["status"]; ok && v.(int) != 0 {
|
||||
db = db.Where("status = ?", v)
|
||||
}
|
||||
|
||||
var total int64
|
||||
if err := db.Count(&total).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
offset := (page - 1) * pageSize
|
||||
var list []model.SysOperationRecord
|
||||
if err := db.Order("id desc").Offset(offset).Limit(pageSize).Find(&list).Error; err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
// 预加载用户信息
|
||||
userIDs := make([]int64, 0)
|
||||
for _, m := range list {
|
||||
userIDs = append(userIDs, m.UserID)
|
||||
}
|
||||
userMap := make(map[int64]*model.SysUser)
|
||||
if len(userIDs) > 0 {
|
||||
var users []model.SysUser
|
||||
r.db.WithContext(ctx).Where("id in (?)", userIDs).Find(&users)
|
||||
for i := range users {
|
||||
userMap[users[i].ID] = &users[i]
|
||||
}
|
||||
}
|
||||
|
||||
result := make([]*system.OperationRecord, len(list))
|
||||
for i, m := range list {
|
||||
user := userMap[m.UserID]
|
||||
result[i] = toBizOperationRecord(&m, user)
|
||||
}
|
||||
return result, total, nil
|
||||
}
|
||||
|
||||
// 转换函数
|
||||
func toModelOperationRecord(r *system.OperationRecord) *model.SysOperationRecord {
|
||||
return &model.SysOperationRecord{
|
||||
ID: int64(r.ID),
|
||||
IP: r.IP,
|
||||
Method: r.Method,
|
||||
Path: r.Path,
|
||||
Status: int64(r.Status),
|
||||
Latency: r.Latency,
|
||||
Agent: r.Agent,
|
||||
ErrorMessage: r.ErrorMessage,
|
||||
Body: r.Body,
|
||||
Resp: r.Resp,
|
||||
UserID: int64(r.UserID),
|
||||
}
|
||||
}
|
||||
|
||||
func toBizOperationRecord(m *model.SysOperationRecord, user *model.SysUser) *system.OperationRecord {
|
||||
r := &system.OperationRecord{
|
||||
ID: uint(m.ID),
|
||||
IP: m.IP,
|
||||
Method: m.Method,
|
||||
Path: m.Path,
|
||||
Status: int(m.Status),
|
||||
Latency: m.Latency,
|
||||
Agent: m.Agent,
|
||||
ErrorMessage: m.ErrorMessage,
|
||||
Body: m.Body,
|
||||
Resp: m.Resp,
|
||||
UserID: uint(m.UserID),
|
||||
}
|
||||
if user != nil {
|
||||
r.User = &system.User{
|
||||
ID: uint(user.ID),
|
||||
Username: user.Username,
|
||||
NickName: user.NickName,
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -263,9 +263,7 @@ func (r *userRepo) GetAuthorityMenuRouters(ctx context.Context, authorityId uint
|
||||
|
||||
routers := make([]string, len(menus))
|
||||
for i, m := range menus {
|
||||
if m.Name != nil {
|
||||
routers[i] = *m.Name
|
||||
}
|
||||
routers[i] = m.Name
|
||||
}
|
||||
return routers, nil
|
||||
}
|
||||
@@ -275,76 +273,41 @@ func (r *userRepo) GetAuthorityDefaultRouter(ctx context.Context, authorityId ui
|
||||
if err := r.db.WithContext(ctx).Where("authority_id = ?", authorityId).First(&authority).Error; err != nil {
|
||||
return "", err
|
||||
}
|
||||
if authority.DefaultRouter != nil {
|
||||
return *authority.DefaultRouter, nil
|
||||
}
|
||||
return "", nil
|
||||
return authority.DefaultRouter, nil
|
||||
}
|
||||
|
||||
// 转换函数
|
||||
func toBizUser(u *system.User) *model.SysUser {
|
||||
uuidStr := u.UUID.String()
|
||||
username := u.Username
|
||||
password := u.Password
|
||||
nickName := u.NickName
|
||||
headerImg := u.HeaderImg
|
||||
authorityID := int64(u.AuthorityId)
|
||||
phone := u.Phone
|
||||
email := u.Email
|
||||
enable := int64(u.Enable)
|
||||
|
||||
return &model.SysUser{
|
||||
ID: int64(u.ID),
|
||||
UUID: &uuidStr,
|
||||
Username: &username,
|
||||
Password: &password,
|
||||
NickName: &nickName,
|
||||
HeaderImg: &headerImg,
|
||||
AuthorityID: &authorityID,
|
||||
Phone: &phone,
|
||||
Email: &email,
|
||||
Enable: &enable,
|
||||
UUID: u.UUID.String(),
|
||||
Username: u.Username,
|
||||
Password: u.Password,
|
||||
NickName: u.NickName,
|
||||
HeaderImg: u.HeaderImg,
|
||||
AuthorityID: int64(u.AuthorityId),
|
||||
Phone: u.Phone,
|
||||
Email: u.Email,
|
||||
Enable: int64(u.Enable),
|
||||
}
|
||||
}
|
||||
|
||||
func toModelUser(m *model.SysUser) *system.User {
|
||||
u := &system.User{ID: uint(m.ID)}
|
||||
if m.UUID != nil {
|
||||
u.UUID, _ = uuid.Parse(*m.UUID)
|
||||
}
|
||||
if m.Username != nil {
|
||||
u.Username = *m.Username
|
||||
}
|
||||
if m.Password != nil {
|
||||
u.Password = *m.Password
|
||||
}
|
||||
if m.NickName != nil {
|
||||
u.NickName = *m.NickName
|
||||
}
|
||||
if m.HeaderImg != nil {
|
||||
u.HeaderImg = *m.HeaderImg
|
||||
}
|
||||
if m.AuthorityID != nil {
|
||||
u.AuthorityId = uint(*m.AuthorityID)
|
||||
}
|
||||
if m.Phone != nil {
|
||||
u.Phone = *m.Phone
|
||||
}
|
||||
if m.Email != nil {
|
||||
u.Email = *m.Email
|
||||
}
|
||||
if m.Enable != nil {
|
||||
u.Enable = int(*m.Enable)
|
||||
}
|
||||
if m.OriginSetting != nil {
|
||||
u.OriginSetting = json.RawMessage(*m.OriginSetting)
|
||||
}
|
||||
if m.CreatedAt != nil {
|
||||
u.CreatedAt = *m.CreatedAt
|
||||
}
|
||||
if m.UpdatedAt != nil {
|
||||
u.UpdatedAt = *m.UpdatedAt
|
||||
u := &system.User{
|
||||
ID: uint(m.ID),
|
||||
Username: m.Username,
|
||||
Password: m.Password,
|
||||
NickName: m.NickName,
|
||||
HeaderImg: m.HeaderImg,
|
||||
AuthorityId: uint(m.AuthorityID),
|
||||
Phone: m.Phone,
|
||||
Email: m.Email,
|
||||
Enable: int(m.Enable),
|
||||
OriginSetting: json.RawMessage(m.OriginSetting),
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
u.UUID, _ = uuid.Parse(m.UUID)
|
||||
return u
|
||||
}
|
||||
|
||||
@@ -354,11 +317,11 @@ func toModelUserWithAuthorities(m *model.SysUser) *system.User {
|
||||
// 转换Authority
|
||||
u.Authority = &system.Authority{
|
||||
AuthorityId: uint(m.Authority.AuthorityID),
|
||||
AuthorityName: safeString(m.Authority.AuthorityName),
|
||||
DefaultRouter: safeString(m.Authority.DefaultRouter),
|
||||
AuthorityName: m.Authority.AuthorityName,
|
||||
DefaultRouter: m.Authority.DefaultRouter,
|
||||
}
|
||||
if m.Authority.ParentID != nil {
|
||||
pid := uint(*m.Authority.ParentID)
|
||||
if m.Authority.ParentID != 0 {
|
||||
pid := uint(m.Authority.ParentID)
|
||||
u.Authority.ParentId = &pid
|
||||
}
|
||||
|
||||
@@ -368,11 +331,11 @@ func toModelUserWithAuthorities(m *model.SysUser) *system.User {
|
||||
for i, a := range m.Authorities {
|
||||
u.Authorities[i] = &system.Authority{
|
||||
AuthorityId: uint(a.AuthorityID),
|
||||
AuthorityName: safeString(a.AuthorityName),
|
||||
DefaultRouter: safeString(a.DefaultRouter),
|
||||
AuthorityName: a.AuthorityName,
|
||||
DefaultRouter: a.DefaultRouter,
|
||||
}
|
||||
if a.ParentID != nil {
|
||||
pid := uint(*a.ParentID)
|
||||
if a.ParentID != 0 {
|
||||
pid := uint(a.ParentID)
|
||||
u.Authorities[i].ParentId = &pid
|
||||
}
|
||||
}
|
||||
@@ -380,10 +343,3 @@ func toModelUserWithAuthorities(m *model.SysUser) *system.User {
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func safeString(s *string) string {
|
||||
if s == nil {
|
||||
return ""
|
||||
}
|
||||
return *s
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user