Add get role controller. Optimize code.

This commit is contained in:
2023-11-09 18:17:00 +08:00
parent 65ddc644fb
commit 5af0c8283e
29 changed files with 454 additions and 93 deletions

View File

@@ -6,7 +6,35 @@ insert into t_power_type (id, name)
on duplicate key update name = new_value.name;
insert into t_power (id, type_id)
values (1000000, 1) as new_value
values (1000000, 1),
(1990000, 2),
(1010000, 2),
(1020000, 2),
(1030000, 2),
(1010100, 3),
(1010200, 3),
(1010300, 3),
(1020100, 3),
(1020200, 3),
(1020300, 3),
(1020400, 3),
(1030100, 3),
(1030200, 3),
(1030300, 3),
(1030400, 3),
(1010101, 4),
(1010102, 4),
(1010201, 4),
(1010301, 4),
(1020101, 4),
(1020201, 4),
(1020301, 4),
(1020401, 4),
(1030101, 4),
(1030201, 4),
(1030301, 4),
(1030401, 4)
as new_value
on duplicate key update type_id = new_value.type_id;
insert into t_module (id, name, power_id)

View File

@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.ElementMapper">
<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>
</mapper>

View File

@@ -1,5 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.GroupMapper">
<select id="selectPage">
</select>
<resultMap id="groupMap" type="group">
<id property="id" column="group_id"/>
<result property="name" column="group_name"/>
<result property="enable" column="group_enable"/>
<result property="deleted" column="group_deleted"/>
<result property="version" column="group_version"/>
</resultMap>
</mapper>

View File

@@ -1,5 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.MenuMapper">
<resultMap id="menuMap" type="menu">
<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>
</mapper>

View File

@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.ModuleMapper">
<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

@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.OperationMapper">
<resultMap id="operationMap" type="operation">
<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

@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.PowerMapper">
<resultMap id="powerMap" type="power">
<id property="id" column="power_id"/>
<result property="typeId" column="power_type_id"/>
</resultMap>
</mapper>

View File

@@ -1,5 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.RoleMapper">
<select id="selectPage" resultMap="roleWithPowerMap">
select distinct t_role.id as role_id,
t_role.name as role_name,
t_role.enable as role_enable,
t_role.deleted as role_deleted,
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
</select>
<resultMap id="roleMap" type="role">
<id property="id" column="role_id"/>
<result property="name" column="role_name"/>
<result property="enable" column="role_enable"/>
<result property="deleted" column="role_deleted"/>
<result property="version" column="role_version"/>
</resultMap>
<resultMap id="roleWithPowerMap" type="role" extends="roleMap">
<collection property="modules" resultMap="top.fatweb.api.mapper.permission.ModuleMapper.moduleMap"/>
<collection property="menus" resultMap="top.fatweb.api.mapper.permission.MenuMapper.menuMap"/>
<collection property="elements" resultMap="top.fatweb.api.mapper.permission.ElementMapper.elementMap"/>
<collection property="operations" resultMap="top.fatweb.api.mapper.permission.OperationMapper.operationMap"/>
</resultMap>
</mapper>

View File

@@ -1,5 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.api.mapper.permission.UserInfoMapper">
<resultMap id="userInfoMap" type="userInfo">
<id property="id" column="user_info_id"/>
<result property="userId" column="user_info_user_id"/>
<result property="nickname" column="user_info_nickname"/>
<result property="avatar" column="user_info_avatar"/>
<result property="email" column="user_info_email"/>
<result property="createTime" column="user_info_create_time"/>
<result property="updateTime" column="user_info_update_time"/>
<result property="deleted" column="user_info_deleted"/>
<result property="version" column="user_info_version"/>
</resultMap>
</mapper>

View File

@@ -125,65 +125,18 @@
<result property="version" column="user_version"/>
</resultMap>
<resultMap id="userInfoMap" type="userInfo">
<id property="id" column="user_info_id"/>
<result property="userId" column="user_info_user_id"/>
<result property="nickname" column="user_info_nickname"/>
<result property="avatar" column="user_info_avatar"/>
<result property="email" column="user_info_email"/>
<result property="createTime" column="user_info_create_time"/>
<result property="updateTime" column="user_info_update_time"/>
<result property="deleted" column="user_info_deleted"/>
<result property="version" column="user_info_version"/>
</resultMap>
<resultMap id="userWithPowerInfoMap" type="user" extends="userBaseMap">
<result property="password" column="user_password"/>
<association property="userInfo" resultMap="userInfoMap"/>
<collection property="modules" ofType="module">
<id property="id" column="module_id"/>
<result property="name" column="module_name"/>
<result property="powerId" column="module_power_id"/>
</collection>
<collection property="menus" ofType="menu">
<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"/>
</collection>
<collection property="elements" ofType="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"/>
</collection>
<collection property="operations" ofType="operation">
<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"/>
</collection>
<association property="userInfo" resultMap="top.fatweb.api.mapper.permission.UserInfoMapper.userInfoMap"/>
<collection property="modules" resultMap="top.fatweb.api.mapper.permission.ModuleMapper.moduleMap"/>
<collection property="menus" resultMap="top.fatweb.api.mapper.permission.MenuMapper.menuMap"/>
<collection property="elements" resultMap="top.fatweb.api.mapper.permission.ElementMapper.elementMap"/>
<collection property="operations" resultMap="top.fatweb.api.mapper.permission.OperationMapper.operationMap"/>
</resultMap>
<resultMap id="userWithRoleInfoMap" type="user" extends="userBaseMap">
<association property="userInfo" resultMap="userInfoMap"/>
<collection property="roles" ofType="role">
<id property="id" column="role_id"/>
<result property="name" column="role_name"/>
<result property="enable" column="role_enable"/>
<result property="deleted" column="role_deleted"/>
<result property="version" column="role_version"/>
</collection>
<collection property="groups" ofType="group">
<id property="id" column="group_id"/>
<result property="name" column="group_name"/>
<result property="enable" column="group_enable"/>
<result property="deleted" column="group_deleted"/>
<result property="version" column="group_version"/>
</collection>
<association property="userInfo" resultMap="top.fatweb.api.mapper.permission.UserInfoMapper.userInfoMap"/>
<collection property="roles" resultMap="top.fatweb.api.mapper.permission.RoleMapper.roleMap"/>
<collection property="groups" resultMap="top.fatweb.api.mapper.permission.GroupMapper.groupMap"/>
</resultMap>
</mapper>