Complete core functions #9

Merged
FatttSnake merged 171 commits from FatttSnake into dev 2024-02-23 11:56:35 +08:00
23 changed files with 52 additions and 117 deletions
Showing only changes of commit d334a231df - Show all commits

View File

@@ -7,7 +7,6 @@ object ElementConverter {
fun elementToElementVo(element: Element) = ElementVo(
id = element.id,
name = element.name,
powerId = element.powerId,
parentId = element.parentId,
menuId = element.menuId
)

View File

@@ -8,7 +8,6 @@ object MenuConverter {
id = menu.id,
name = menu.name,
url = menu.url,
powerId = menu.powerId,
parentId = menu.parentId,
moduleId = menu.moduleId
)

View File

@@ -6,7 +6,6 @@ import top.fatweb.api.vo.permission.ModuleVo
object ModuleConverter {
fun moduleToModuleVo(module: Module) = ModuleVo(
id = module.id,
name = module.name,
powerId = module.powerId
name = module.name
)
}

View File

@@ -8,7 +8,6 @@ object OperationConverter {
id = operation.id,
name = operation.name,
code = operation.code,
powerId = operation.powerId,
elementId = operation.elementId
)
}

View File

@@ -25,12 +25,6 @@ class Element : Serializable {
@TableField("name")
var name: String? = null
/**
* 权限ID
*/
@TableField("power_id")
var powerId: Long? = null
/**
* 父ID
*/
@@ -44,6 +38,6 @@ class Element : Serializable {
var menuId: Long? = null
override fun toString(): String {
return "Element(id=$id, name=$name, powerId=$powerId, menuId=$menuId)"
return "Element(id=$id, name=$name, parentId=$parentId, menuId=$menuId)"
}
}

View File

@@ -31,12 +31,6 @@ class Menu : Serializable {
@TableField("url")
var url: String? = null
/**
* 权限ID
*/
@TableField("power_id")
var powerId: Long? = null
/**
* 父ID
*/
@@ -50,6 +44,6 @@ class Menu : Serializable {
var moduleId: Long? = null
override fun toString(): String {
return "Menu(id=$id, name=$name, url=$url, powerId=$powerId, parentId=$parentId, moduleId=$moduleId)"
return "Menu(id=$id, name=$name, url=$url, parentId=$parentId, moduleId=$moduleId)"
}
}

View File

@@ -25,14 +25,7 @@ class Module : Serializable {
@TableField("name")
var name: String? = null
/**
* 权限ID
*/
@TableField("power_id")
var powerId: Long? = null
override fun toString(): String {
return "Module(id=$id, name=$name, powerId=$powerId)"
return "Module(id=$id, name=$name)"
}
}

View File

@@ -31,12 +31,6 @@ class Operation : Serializable {
@TableField("code")
var code: String? = null
/**
* 权限ID
*/
@TableField("power_id")
var powerId: Long? = null
/**
* 页面元素ID
*/
@@ -44,6 +38,6 @@ class Operation : Serializable {
var elementId: Long? = null
override fun toString(): String {
return "Operation(id=$id, name=$name, code=$code, powerId=$powerId, elementId=$elementId)"
return "Operation(id=$id, name=$name, code=$code, elementId=$elementId)"
}
}

View File

@@ -9,9 +9,6 @@ data class ElementVo(
@Schema(description = "元素名", example = "AddButton")
val name: String?,
@Schema(description = "权限 ID")
val powerId: Long?,
@Schema(description = "父 ID")
val parentId: Long?,

View File

@@ -12,9 +12,6 @@ data class MenuVo(
@Schema(description = "URL", example = "/system")
val url: String?,
@Schema(description = "权限 ID")
val powerId: Long?,
@Schema(description = "父 ID")
val parentId: Long?,

View File

@@ -7,8 +7,5 @@ data class ModuleVo(
val id: Long?,
@Schema(description = "模块名", example = "系统")
val name: String?,
@Schema(description = "权限 ID")
val powerId: Long?
val name: String?
)

View File

@@ -12,9 +12,6 @@ data class OperationVo(
@Schema(description = "功能编码", example = "system:user:add")
val code: String?,
@Schema(description = "权限 ID")
val powerId: Long?,
@Schema(description = "页面元素 ID")
val elementId: Long?
)

View File

@@ -37,52 +37,48 @@ insert into t_power (id, type_id)
as new_value
on duplicate key update type_id = new_value.type_id;
insert into t_module (id, name, power_id)
values (1000000, '系统', id) as new_value
on duplicate key update name = new_value.name,
power_id = new_value.power_id;
insert into t_module (id, name)
values (1000000, '系统') as new_value
on duplicate key update name = new_value.name;
insert into t_menu (id, name, url, power_id, parent_id, module_id)
values (1990000, '系统管理', '/system', id, null, 1000000),
(1010000, '用户管理', '/system/user', id, 1990000, 1000000),
(1020000, '角色管理', '/system/role', id, 1990000, 1000000),
(1030000, '用户组管理', '/system/group', id, 1990000, 1000000) as new_value
insert into t_menu (id, name, url, parent_id, module_id)
values (1990000, '系统管理', '/system', null, 1000000),
(1010000, '用户管理', '/system/user', 1990000, 1000000),
(1020000, '角色管理', '/system/role', 1990000, 1000000),
(1030000, '用户组管理', '/system/group', 1990000, 1000000) as new_value
on duplicate key update name =new_value.name,
url =new_value.url,
power_id =new_value.power_id,
parent_id =new_value.parent_id;
insert into t_element(id, name, power_id, menu_id, parent_id)
values (1010100, '查询', id, 1010000, null),
(1010200, '增加', id, 1010000, 1010100),
(1010300, '修改', id, 1010000, 1010100),
(1020100, '查询', id, 1020000, null),
(1020200, '增加', id, 1020000, 1020100),
(1020300, '修改', id, 1020000, 1020100),
(1020400, '删除', id, 1020000, 1020100),
(1030100, '查询', id, 1030000, null),
(1030200, '增加', id, 1030000, 1030100),
(1030300, '修改', id, 1030000, 1030100),
(1030400, '删除', id, 1030000, 1030100) as new_value
insert into t_element(id, name, menu_id, parent_id)
values (1010100, '查询', 1010000, null),
(1010200, '增加', 1010000, 1010100),
(1010300, '修改', 1010000, 1010100),
(1020100, '查询', 1020000, null),
(1020200, '增加', 1020000, 1020100),
(1020300, '修改', 1020000, 1020100),
(1020400, '删除', 1020000, 1020100),
(1030100, '查询', 1030000, null),
(1030200, '增加', 1030000, 1030100),
(1030300, '修改', 1030000, 1030100),
(1030400, '删除', 1030000, 1030100) as new_value
on duplicate key update name = new_value.name,
power_id=new_value.power_id,
menu_id = new_value.menu_id,
parent_id = new_value.parent_id;
insert into t_operation(id, name, code, power_id, element_id)
values (1010101, '全部', 'system:user:query:all', id, 1010100),
(1010102, '单个', 'system:user:query:one', id, 1010100),
(1010201, '全部', 'system:user:add:all', id, 1010200),
(1010301, '全部', 'system:user:modify:all', id, 1010300),
(1020101, '全部', 'system:role:query:all', id, 1020100),
(1020201, '全部', 'system:role:add:all', id, 1020200),
(1020301, '全部', 'system:role:modify:all', id, 1020300),
(1020401, '全部', 'system:role:delete:all', id, 1020400),
(1030101, '全部', 'system:group:query:all', id, 1030100),
(1030201, '全部', 'system:group:add:all', id, 1030200),
(1030301, '全部', 'system:group:modify:all', id, 1030300),
(1030401, '全部', 'system:group:delete:all', id, 1030400) as new_value
insert into t_operation(id, name, code, element_id)
values (1010101, '全部', 'system:user:query:all', 1010100),
(1010102, '单个', 'system:user:query:one', 1010100),
(1010201, '全部', 'system:user:add:all', 1010200),
(1010301, '全部', 'system:user:modify:all', 1010300),
(1020101, '全部', 'system:role:query:all', 1020100),
(1020201, '全部', 'system:role:add:all', 1020200),
(1020301, '全部', 'system:role:modify:all', 1020300),
(1020401, '全部', 'system:role:delete:all', 1020400),
(1030101, '全部', 'system:group:query:all', 1030100),
(1030201, '全部', 'system:group:add:all', 1030200),
(1030301, '全部', 'system:group:modify:all', 1030300),
(1030401, '全部', 'system:group:delete:all', 1030400) as new_value
on duplicate key update name=new_value.name,
code=new_value.code,
power_id=new_value.power_id,
element_id=new_value.element_id;

View File

@@ -5,7 +5,6 @@ create table if not exists t_menu
id bigint not null primary key,
name varchar(30) not null comment ' 菜单名',
url varchar(100) null comment 'URL',
power_id bigint not null comment '权限ID',
parent_id bigint null comment '父ID',
module_id bigint not null comment '模块ID'
) comment '菜单表';

View File

@@ -4,7 +4,6 @@ create table if not exists t_element
(
id bigint not null primary key,
name varchar(100) not null comment '元素名',
power_id bigint not null comment '权限ID',
parent_id bigint null comment '父ID',
menu_id bigint not null comment '菜单ID'
) comment '页面元素表';

View File

@@ -5,6 +5,5 @@ create table if not exists t_operation
id bigint not null primary key,
name varchar(50) not null comment '功能名',
code varchar(50) null comment '功能编码',
power_id bigint not null comment '权限ID',
element_id bigint not null comment '页面元素ID'
) comment '功能表';

View File

@@ -3,6 +3,5 @@ drop table if exists t_module;
create table if not exists t_module
(
id bigint not null primary key,
name varchar(100) not null comment '模块名',
power_id bigint not null comment '权限ID'
name varchar(100) not null comment '模块名'
) comment '模块表';

View File

@@ -4,7 +4,6 @@
<resultMap id="elementMap" type="element">
<id property="id" column="element_id"/>
<result property="name" column="element_name"/>
<result property="powerId" column="element_power_id"/>
<result property="parentId" column="element_parent_id"/>
<result property="menuId" column="element_menu_id"/>
</resultMap>

View File

@@ -5,7 +5,6 @@
<id property="id" column="menu_id"/>
<result property="name" column="menu_name"/>
<result property="url" column="menu_url"/>
<result property="powerId" column="menu_power_id"/>
<result property="parentId" column="menu_parent_id"/>
<result property="moduleId" column="menu_module_id"/>
</resultMap>

View File

@@ -4,6 +4,5 @@
<resultMap id="moduleMap" type="module">
<id property="id" column="module_id"/>
<result property="name" column="module_name"/>
<result property="powerId" column="module_power_id"/>
</resultMap>
</mapper>

View File

@@ -5,7 +5,6 @@
<id property="id" column="operation_id"/>
<result property="name" column="operation_name"/>
<result property="code" column="operation_code"/>
<result property="powerId" column="operation_power_id"/>
<result property="elementId" column="operation_element_id"/>
</resultMap>
</mapper>

View File

@@ -29,30 +29,26 @@
t_role.version as role_version,
tm.id as module_id,
tm.name as module_name,
tm.power_id as module_power_id,
tmn.id as menu_id,
tmn.name as menu_name,
tmn.url as menu_url,
tmn.power_id as menu_power_id,
tmn.parent_id as menu_parent_id,
tmn.module_id as menu_module_id,
te.id as element_id,
te.name as element_name,
te.power_id as element_power_id,
te.parent_id as element_parent_id,
te.menu_id as element_menu_id,
t.id as operation_id,
t.name as operation_name,
t.code as operation_code,
t.power_id as operation_power_id,
t.element_id as operation_element_id
from (select * from t_role where deleted = 0) as t_role
left join (select * from t_power_role where deleted = 0) as tpr on t_role.id = tpr.role_id
left join t_power tp on tp.id = tpr.power_id
left join t_module tm on tp.id = tm.power_id
left join t_menu tmn on tp.id = tmn.power_id
left join t_element te on tp.id = te.power_id
left join t_operation t on tp.id = t.power_id
left join t_module tm on tp.id = tm.id
left join t_menu tmn on tp.id = tmn.id
left join t_element te on tp.id = te.id
left join t_operation t on tp.id = t.id
<where>
<foreach collection="roleIds" item="item" index="index" open="and t_role.id in (" separator="," close=")"
nullable="true">
@@ -71,30 +67,26 @@
t_role.version as role_version,
tm.id as module_id,
tm.name as module_name,
tm.power_id as module_power_id,
tmn.id as menu_id,
tmn.name as menu_name,
tmn.url as menu_url,
tmn.power_id as menu_power_id,
tmn.parent_id as menu_parent_id,
tmn.module_id as menu_module_id,
te.id as element_id,
te.name as element_name,
te.power_id as element_power_id,
te.parent_id as element_parent_id,
te.menu_id as element_menu_id,
t.id as operation_id,
t.name as operation_name,
t.code as operation_code,
t.power_id as operation_power_id,
t.element_id as operation_element_id
from (select * from t_role where deleted = 0) as t_role
left join (select * from t_power_role where deleted = 0) as tpr on t_role.id = tpr.role_id
left join t_power tp on tp.id = tpr.power_id
left join t_module tm on tp.id = tm.power_id
left join t_menu tmn on tp.id = tmn.power_id
left join t_element te on tp.id = te.power_id
left join t_operation t on tp.id = t.power_id
left join t_module tm on tp.id = tm.id
left join t_menu tmn on tp.id = tmn.id
left join t_element te on tp.id = te.id
left join t_operation t on tp.id = t.id
where t_role.id = #{id}
</select>

View File

@@ -28,21 +28,17 @@
tui.version as user_info_version,
tmo.id as module_id,
tmo.name as module_name,
tmo.power_id as module_power_id,
tm.id as menu_id,
tm.name as menu_name,
tm.url as menu_url,
tm.power_id as menu_power_id,
tm.parent_id as menu_parent_id,
te.id as element_id,
te.name as element_name,
te.power_id as element_power_id,
te.parent_id as element_parent_id,
te.menu_id as element_menu_id,
t.id as operation_id,
t.name as operation_name,
t.code as operation_code,
t.power_id as operation_power_id,
t.element_id as operation_element_id
from t_user
left join (select * from t_user_info where deleted = 0) as tui on t_user.id = tui.user_id
@@ -54,10 +50,10 @@
on tr.id = trg.role_id or tr.id = tur.role_id
left join (select * from t_power_role where deleted = 0) as tpr on tr.id = tpr.role_id
left join t_power as tp on tp.id = tpr.power_id
left join t_module as tmo on tp.id = tmo.power_id
left join t_menu as tm on tp.id = tm.power_id
left join t_element as te on tp.id = te.power_id
left join t_operation as t on tp.id = t.power_id
left join t_module as tmo on tp.id = tmo.id
left join t_menu as tm on tp.id = tm.id
left join t_element as te on tp.id = te.id
left join t_operation as t on tp.id = t.id
where t_user.deleted = 0
and t_user.username = #{username};
</select>