refactor: 系统功能重构

This commit is contained in:
hxr
2024-06-24 08:15:46 +08:00
parent 5a6ae48bcd
commit 7d1fcfbef4
71 changed files with 900 additions and 1048 deletions

View File

@@ -0,0 +1,24 @@
<?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="com.youlai.system.mapper.SysDictItemMapper">
<!-- 根据字典编码获取字典列表 -->
<select id="listDictItemsByDictId" resultType="com.youlai.system.model.vo.DictPageVO$DictItem">
SELECT
id,
`name`,
value,
sort,
status
FROM
sys_dict_item
<where>
dict_id = #{dictId}
</where>
ORDER BY
sort ASC
</select>
</mapper>

View File

@@ -4,4 +4,32 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.youlai.system.mapper.SysDictMapper">
<!-- 字典映射 -->
<resultMap id="DictMap" type="com.youlai.system.model.vo.DictPageVO">
<collection property="dictItems"
column="{dictId=id}"
select="com.youlai.system.mapper.SysDictItemMapper.listDictItemsByDictId">
</collection>
</resultMap>
<!-- 字典分页列表 -->
<select id="getDictPage" resultMap="DictMap">
SELECT
t1.id,
t1.name,
t1.code,
t1.status
FROM
sys_dict t1
<where>
t1.is_deleted = 0
<if test='queryParams.keywords!=null and queryParams.keywords.trim() neq ""'>
AND (
t1.name LIKE CONCAT('%',#{queryParams.keywords},'%')
OR t1.code LIKE CONCAT('%',#{queryParams.keywords},'%')
)
</if>
</where>
ORDER BY
t1.create_time DESC
</select>
</mapper>

View File

@@ -1,22 +0,0 @@
<?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="com.youlai.system.mapper.SysDictTypeMapper">
<resultMap id="BaseResultMap" type="com.youlai.system.model.entity.SysDictType">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="code" column="code" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="TINYINT"/>
<result property="remark" column="remark" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,name,code,
status,remark,create_time,
update_time
</sql>
</mapper>

View File

@@ -9,7 +9,8 @@
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="parentId" column="parent_id" jdbcType="BIGINT"/>
<result property="path" column="path" jdbcType="VARCHAR"/>
<result property="routeName" column="route_name" jdbcType="VARCHAR"/>
<result property="routePath" column="route_path" jdbcType="VARCHAR"/>
<result property="component" column="component" jdbcType="VARCHAR"/>
<result property="redirect" column="redirect" jdbcType="VARCHAR"/>
<result property="icon" column="icon" jdbcType="VARCHAR"/>
@@ -30,7 +31,8 @@
t1.id,
t1.name,
t1.parent_id,
t1.path,
t1.route_name,
t1.route_path,
t1.component,
t1.icon,
t1.sort,
@@ -47,30 +49,9 @@
LEFT JOIN sys_role t3 ON t2.role_id = t3.id
WHERE
t1.type != '${@com.youlai.system.common.enums.MenuTypeEnum@BUTTON.getValue()}'
ORDER BY t1.sort asc
ORDER BY
t1.sort
</select>
<!-- 获取角色拥有的权限集合 -->
<select id="listRolePerms" resultType="java.lang.String">
SELECT
DISTINCT t1.perm
FROM
sys_menu t1
INNER JOIN sys_role_menu t2 ON t1.id = t2.menu_id
INNER JOIN sys_role t3 ON t3.id = t2.role_id
WHERE
t1.type = '${@com.youlai.system.common.enums.MenuTypeEnum@BUTTON.getValue()}'
AND t1.perm IS NOT NULL
<choose>
<when test="roles!=null and roles.size()>0">
AND t3.CODE IN
<foreach collection="roles" item="role" separator="," open="(" close=")">
#{role}
</foreach>
</when>
<otherwise>
AND t1.id = -1
</otherwise>
</choose>
</select>
</mapper>

View File

@@ -15,7 +15,7 @@
rm.role_id = #{roleId}
</select>
<!-- 权限和拥有权限的角色集合的Map -->
<!-- 权限和拥有权限的角色的映射 -->
<resultMap id="PremRolesMap" type="com.youlai.system.model.bo.RolePermsBO">
<result property="roleCode" column="role_code"/>
<collection property="perms" ofType="string" javaType="java.util.Set">
@@ -26,11 +26,11 @@
<!-- 获取权限和拥有权限的角色列表 -->
<select id="getRolePermsList" resultMap="PremRolesMap">
SELECT
t2.`code` role_code,
t3.perm
t3.perm,
t2.`code` role_code
FROM
`sys_role_menu` t1
INNER JOIN sys_role t2 ON t1.role_id = t2.id AND t2.deleted = 0 AND t2.`status` = 1
INNER JOIN sys_role t2 ON t1.role_id = t2.id AND t2.is_deleted = 0 AND t2.`status` = 1
INNER JOIN sys_menu t3 ON t1.menu_id = t3.id
WHERE
type = '${@com.youlai.system.common.enums.MenuTypeEnum@BUTTON.getValue()}'
@@ -38,4 +38,21 @@
AND t2.`code` = #{roleCode}
</if>
</select>
<!-- 获取角色拥有的权限列表 -->
<select id="listRolePerms" resultType="java.lang.String">
SELECT
DISTINCT t2.perm
FROM
sys_role_menu t1
INNER JOIN sys_menu t2 ON t2.id = t1.menu_id
INNER JOIN sys_role t3 ON t3.id = t1.role_id
WHERE
t2.type = '${@com.youlai.system.common.enums.MenuTypeEnum@BUTTON.getValue()}'
AND t2.perm IS NOT NULL
AND t3.CODE IN
<foreach collection="roles" item="role" separator="," open="(" close=")">
#{role}
</foreach>
</select>
</mapper>

View File

@@ -23,7 +23,7 @@
LEFT JOIN sys_user_role sur ON u.id = sur.user_id
LEFT JOIN sys_role r ON sur.role_id = r.id
<where>
u.deleted = 0 AND u.username != 'root'
u.is_deleted = 0 AND u.username != 'root'
<if test='queryParams.keywords!=null and queryParams.keywords.trim() neq ""'>
AND (
u.username LIKE CONCAT('%',#{queryParams.keywords},'%')
@@ -112,11 +112,11 @@
LEFT JOIN sys_user_role t2 ON t2.user_id = t1.id
LEFT JOIN sys_role t3 ON t3.id = t2.role_id
WHERE
t1.username = #{username} AND t1.deleted=0
t1.username = #{username} AND t1.is_deleted=0
</select>
<!-- 获取用户导出列表 -->
<select id="listExportUsers" resultType="com.youlai.system.model.vo.UserExportVO">
<select id="listExportUsers" resultType="com.youlai.system.model.dto.UserExportDTO">
SELECT
u.username,
u.nickname,
@@ -132,7 +132,7 @@
sys_user u
LEFT JOIN sys_dept d ON u.dept_id = d.id
<where>
u.deleted = 0 AND u.username != 'root'
u.is_deleted = 0 AND u.username != 'root'
<if test='keywords!=null and keywords.trim() neq ""'>
AND (u.username LIKE CONCAT('%',#{keywords},'%')
OR u.nickname LIKE CONCAT('%',#{keywords},'%')

View File

@@ -20,9 +20,9 @@
count(*)
FROM
sys_user_role t1
INNER JOIN sys_role t2 ON t1.role_id = t2.id AND t2.deleted = 0
INNER JOIN sys_role t2 ON t1.role_id = t2.id AND t2.is_deleted = 0
INNER JOIN sys_user t3 ON t1.user_id = t3.id
AND t3.deleted = 0
AND t3.is_deleted = 0
WHERE
t1.role_id = #{roleId}
</select>