serv\web- 日志

This commit is contained in:
2025-10-30 16:40:56 +08:00
parent 82b6f14e64
commit 2b252e1b3c
91 changed files with 6003 additions and 1485 deletions

View File

@@ -47,23 +47,97 @@
</where>
</sql>
<!-- selectAllRoles -->
<!-- 权限过滤条件基于dept_path的高效继承 -->
<sql id="Permission_Filter">
INNER JOIN tb_resource_permission rp ON r.role_id = rp.resource_id
AND rp.resource_type = 5
AND rp.deleted = 0
AND rp.can_read = 1
AND (
-- 全局权限:所有用户可访问
(rp.dept_id IS NULL AND rp.role_id IS NULL)
<if test="userDeptRoles != null and userDeptRoles.size() > 0">
OR EXISTS (
SELECT 1
FROM (
<foreach collection="userDeptRoles" item="udr" separator=" UNION ALL ">
SELECT #{udr.deptID} AS dept_id, #{udr.deptPath} AS dept_path, #{udr.roleID} AS role_id
</foreach>
) user_roles
LEFT JOIN tb_sys_dept perm_dept ON perm_dept.dept_id = rp.dept_id AND perm_dept.deleted = 0
WHERE
-- 部门级权限当前部门或父部门通过dept_path判断继承关系
(rp.role_id IS NULL AND rp.dept_id IS NOT NULL
AND user_roles.dept_path LIKE CONCAT(perm_dept.dept_path, '%'))
-- 角色级权限:跨部门的角色权限
OR (rp.dept_id IS NULL AND rp.role_id = user_roles.role_id)
-- 精确权限:特定部门的特定角色
OR (rp.dept_id = user_roles.dept_id AND rp.role_id = user_roles.role_id)
)
</if>
)
</sql>
<select id="selectAllRoles" resultMap="tbSysRoleResultMap">
SELECT
<include refid="TbSysRole_Column_List"/>
FROM tb_sys_role
WHERE deleted = 0
ORDER BY role_id, create_time ASC
<!-- 角色VO结果映射包含创建人更新人名称 -->
<resultMap id="RoleVOResultMap" type="org.xyzh.common.vo.PermissionVO">
<id column="id" property="id" jdbcType="VARCHAR"/>
<result column="role_id" property="roleID" jdbcType="VARCHAR"/>
<result column="role_name" property="roleName" jdbcType="VARCHAR"/>
<result column="role_description" property="roleDescription" jdbcType="VARCHAR"/>
<result column="creator" property="creator" jdbcType="VARCHAR"/>
<result column="creator_name" property="creatorName" jdbcType="VARCHAR"/>
<result column="updater" property="updater" jdbcType="VARCHAR"/>
<result column="updater_name" property="updaterName" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<!-- selectAllRoles - 添加权限过滤和VO返回 -->
<select id="selectAllRoles" resultMap="RoleVOResultMap">
SELECT DISTINCT
r.id,
r.role_id,
r.name AS role_name,
r.description AS role_description,
r.creator,
cu.username AS creator_name,
r.updater,
uu.username AS updater_name,
r.create_time,
r.update_time
FROM tb_sys_role r
<include refid="Permission_Filter"/>
LEFT JOIN tb_sys_user cu ON r.creator = cu.id AND cu.deleted = 0
LEFT JOIN tb_sys_user uu ON r.updater = uu.id AND uu.deleted = 0
WHERE r.deleted = 0
ORDER BY r.role_id, r.create_time ASC
</select>
<!-- 根据过滤条件查询角色列表 -->
<select id="selectRole" resultMap="tbSysRoleResultMap">
SELECT
<include refid="TbSysRole_Column_List"/>
FROM tb_sys_role
<include refid="Where_Clause"/>
ORDER BY role_id, create_time ASC
<!-- 根据过滤条件查询角色列表 - 添加权限过滤 -->
<select id="selectRole" resultMap="RoleVOResultMap">
SELECT DISTINCT
r.id,
r.role_id,
r.name AS role_name,
r.description AS role_description,
r.creator,
cu.username AS creator_name,
r.updater,
uu.username AS updater_name,
r.create_time,
r.update_time
FROM tb_sys_role r
<include refid="Permission_Filter"/>
LEFT JOIN tb_sys_user cu ON r.creator = cu.id AND cu.deleted = 0
LEFT JOIN tb_sys_user uu ON r.updater = uu.id AND uu.deleted = 0
WHERE r.deleted = 0
<if test="filter.roleID != null and filter.roleID != ''">
AND r.role_id = #{filter.roleID}
</if>
<if test="filter.name != null and filter.name != ''">
AND r.name LIKE CONCAT('%', #{filter.name}, '%')
</if>
ORDER BY r.role_id, r.create_time ASC
</select>
<!-- 插入角色 -->
@@ -108,35 +182,15 @@
ORDER BY dr.create_time ASC
</select>
<!-- 根据角色编码查询角色 -->
<select id="selectByRoleCode" resultMap="tbSysRoleResultMap">
SELECT
<include refid="TbSysRole_Column_List"/>
FROM tb_sys_role
WHERE deleted = 0
AND role_code = #{roleCode}
LIMIT 1
</select>
<!-- 检查角色名称是否存在 -->
<!-- 检查角色名称是否存在 - 添加权限过滤 -->
<select id="countByRoleName" resultType="int">
SELECT COUNT(1)
FROM tb_sys_role
WHERE deleted = 0
AND name = #{roleName}
SELECT COUNT(DISTINCT r.id)
FROM tb_sys_role r
<include refid="Permission_Filter"/>
WHERE r.deleted = 0
AND r.name = #{roleName}
<if test="excludeId != null and excludeId != ''">
AND id != #{excludeId}
</if>
</select>
<!-- 检查角色编码是否存在 -->
<select id="countByRoleCode" resultType="int">
SELECT COUNT(1)
FROM tb_sys_role
WHERE deleted = 0
AND role_code = #{roleCode}
<if test="excludeId != null and excludeId != ''">
AND id != #{excludeId}
AND r.id != #{excludeId}
</if>
</select>
@@ -155,9 +209,8 @@
<!-- checkRoleExists -->
<select id="checkRoleExists">
<!-- checkRoleExists - 检查角色是否存在,不需要权限过滤 -->
<select id="checkRoleExists" resultMap="tbSysRoleResultMap">
SELECT
<include refid="TbSysRole_Column_List"/>
FROM tb_sys_role