2025-12-02 13:21:18 +08:00
|
|
|
|
<?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="org.xyzh.system.mapper.permission.TbSysPermissionMapper">
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 结果映射 -->
|
|
|
|
|
|
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysPermissionDTO">
|
|
|
|
|
|
<!-- 权限字段 -->
|
|
|
|
|
|
<id column="permission_id" property="permissionId" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="name" property="name" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="code" property="code" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="description" property="description" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="module_id" property="moduleId" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="status" property="status" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<!-- 基础字段 -->
|
|
|
|
|
|
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="creator" property="creator" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="updater" property="updater" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="remark" property="remark" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="create_time" property="createTime" jdbcType="DATE"/>
|
|
|
|
|
|
<result column="update_time" property="updateTime" jdbcType="DATE"/>
|
|
|
|
|
|
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
|
2025-12-02 16:13:28 +08:00
|
|
|
|
<result column="deleted" property="deleted" jdbcType="Boolean"/>
|
2025-12-02 13:21:18 +08:00
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- VO结果映射(用于前端展示) -->
|
|
|
|
|
|
<resultMap id="PermissionVOResultMap" type="org.xyzh.api.system.vo.PermissionVO">
|
|
|
|
|
|
<!-- 权限字段 -->
|
|
|
|
|
|
<id column="permission_id" property="permissionId" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="permission_name" property="permissionName" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="permission_code" property="permissionCode" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="permission_description" property="permissionDescription" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="permission_status" property="permissionStatus" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<!-- 模块关联字段 -->
|
|
|
|
|
|
<result column="module_id" property="moduleId" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="module_name" property="moduleName" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="module_description" property="moduleDescription" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<!-- BaseVO 基础字段 -->
|
|
|
|
|
|
<result column="optsn" property="optsn" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="creator" property="creator" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="updater" property="updater" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="dept_path" property="deptPath" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="remark" property="remark" jdbcType="VARCHAR"/>
|
|
|
|
|
|
<result column="create_time" property="createTime" jdbcType="DATE"/>
|
|
|
|
|
|
<result column="update_time" property="updateTime" jdbcType="DATE"/>
|
|
|
|
|
|
<result column="delete_time" property="deleteTime" jdbcType="DATE"/>
|
2025-12-02 16:13:28 +08:00
|
|
|
|
<result column="deleted" property="deleted" jdbcType="Boolean"/>
|
2025-12-02 13:21:18 +08:00
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 基础列 -->
|
|
|
|
|
|
<sql id="Base_Column_List">
|
|
|
|
|
|
permission_id, name, code, description, module_id, status,
|
|
|
|
|
|
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
|
|
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 插入系统权限(必填 + 可选字段动态列,仅修改 insert) -->
|
|
|
|
|
|
<insert id="insertPermission" parameterType="org.xyzh.common.dto.sys.TbSysPermissionDTO">
|
|
|
|
|
|
INSERT INTO sys.tb_sys_permission
|
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
|
<!-- 必填字段:permission_id, name, code, module_id, optsn -->
|
|
|
|
|
|
permission_id,
|
|
|
|
|
|
name,
|
|
|
|
|
|
code,
|
|
|
|
|
|
module_id,
|
|
|
|
|
|
optsn,
|
|
|
|
|
|
<!-- 可选字段:description, status 及基础字段 -->
|
|
|
|
|
|
<if test="description != null and description != ''">description,</if>
|
|
|
|
|
|
<if test="status != null">status,</if>
|
|
|
|
|
|
<if test="creator != null and creator != ''">creator,</if>
|
|
|
|
|
|
<if test="deptPath != null and deptPath != ''">dept_path,</if>
|
|
|
|
|
|
<if test="remark != null and remark != ''">remark,</if>
|
|
|
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
|
|
|
<if test="updateTime != null">update_time,</if>
|
|
|
|
|
|
<if test="deleteTime != null">delete_time,</if>
|
|
|
|
|
|
<if test="deleted != null">deleted,</if>
|
|
|
|
|
|
</trim>
|
|
|
|
|
|
VALUES
|
|
|
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
|
|
|
<!-- 必填字段对应的值 -->
|
|
|
|
|
|
#{permissionId},
|
|
|
|
|
|
#{name},
|
|
|
|
|
|
#{code},
|
|
|
|
|
|
#{moduleId},
|
|
|
|
|
|
#{optsn},
|
|
|
|
|
|
<!-- 可选字段对应的值 -->
|
|
|
|
|
|
<if test="description != null and description != ''">#{description},</if>
|
|
|
|
|
|
<if test="status != null">#{status},</if>
|
|
|
|
|
|
<if test="creator != null and creator != ''">#{creator},</if>
|
|
|
|
|
|
<if test="deptPath != null and deptPath != ''">#{deptPath},</if>
|
|
|
|
|
|
<if test="remark != null and remark != ''">#{remark},</if>
|
|
|
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
|
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
|
|
|
|
<if test="deleteTime != null">#{deleteTime},</if>
|
|
|
|
|
|
<if test="deleted != null">#{deleted},</if>
|
|
|
|
|
|
</trim>
|
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 更新系统权限 -->
|
|
|
|
|
|
<update id="updatePermission" parameterType="org.xyzh.common.dto.sys.TbSysPermissionDTO">
|
|
|
|
|
|
UPDATE sys.tb_sys_permission
|
|
|
|
|
|
<set>
|
|
|
|
|
|
<if test="name != null and name != ''">
|
|
|
|
|
|
name = #{name},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="code != null and code != ''">
|
|
|
|
|
|
code = #{code},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="description != null">
|
|
|
|
|
|
description = #{description},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="moduleId != null">
|
|
|
|
|
|
module_id = #{moduleId},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="status != null and status != ''">
|
|
|
|
|
|
status = #{status},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="updater != null and updater != ''">
|
|
|
|
|
|
updater = #{updater},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="deptPath != null and deptPath != ''">
|
|
|
|
|
|
dept_path = #{deptPath},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="remark != null">
|
|
|
|
|
|
remark = #{remark},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="updateTime != null">
|
|
|
|
|
|
update_time = #{updateTime},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</set>
|
|
|
|
|
|
WHERE permission_id = #{permissionId}
|
|
|
|
|
|
<if test="deleted != null">
|
|
|
|
|
|
AND deleted = #{deleted}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 删除系统权限 -->
|
|
|
|
|
|
<update id="deletePermission" parameterType="org.xyzh.common.dto.sys.TbSysPermissionDTO">
|
|
|
|
|
|
UPDATE sys.tb_sys_permission
|
|
|
|
|
|
SET deleted = true,
|
|
|
|
|
|
delete_time = NOW()
|
|
|
|
|
|
WHERE permission_id = #{permissionId}
|
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 根据权限ID查询系统权限 -->
|
|
|
|
|
|
<select id="getPermissionById" resultMap="PermissionVOResultMap" parameterType="java.lang.String">
|
|
|
|
|
|
SELECT
|
|
|
|
|
|
p.permission_id, p.name AS permission_name, p.code AS permission_code, p.description AS permission_description, p.status AS permission_status,
|
|
|
|
|
|
p.module_id, m.name AS module_name, m.description AS module_description,
|
|
|
|
|
|
p.optsn, p.creator, p.updater, p.dept_path, p.remark, p.create_time, p.update_time, p.delete_time, p.deleted
|
|
|
|
|
|
FROM sys.tb_sys_permission p
|
|
|
|
|
|
LEFT JOIN sys.tb_sys_module m ON p.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
|
|
|
|
|
|
WHERE p.permission_id = #{permissionId}
|
|
|
|
|
|
AND (p.deleted IS NULL OR p.deleted = false)
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 根据条件查询系统权限列表 -->
|
|
|
|
|
|
<select id="getPermissionByFilter" resultMap="PermissionVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysPermissionDTO">
|
|
|
|
|
|
SELECT
|
|
|
|
|
|
p.permission_id, p.name AS permission_name, p.code AS permission_code, p.description AS permission_description, p.status AS permission_status,
|
|
|
|
|
|
p.module_id, m.name AS module_name, m.description AS module_description,
|
|
|
|
|
|
p.optsn, p.creator, p.updater, p.dept_path, p.remark, p.create_time, p.update_time, p.delete_time, p.deleted
|
|
|
|
|
|
FROM sys.tb_sys_permission p
|
|
|
|
|
|
LEFT JOIN sys.tb_sys_module m ON p.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
|
|
|
|
|
|
<where>
|
|
|
|
|
|
<if test="filter.permissionId != null and filter.permissionId != ''">
|
|
|
|
|
|
AND p.permission_id = #{filter.permissionId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="filter.name != null and filter.name != ''">
|
|
|
|
|
|
AND p.name LIKE CONCAT('%', #{filter.name}, '%')
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="filter.code != null and filter.code != ''">
|
|
|
|
|
|
AND p.code LIKE CONCAT('%', #{filter.code}, '%')
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="filter.moduleId != null and filter.moduleId != ''">
|
|
|
|
|
|
AND p.module_id = #{filter.moduleId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="filter.status != null and filter.status != ''">
|
|
|
|
|
|
AND p.status = #{filter.status}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="filter.deptPath != null and filter.deptPath != ''">
|
|
|
|
|
|
AND p.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
|
|
|
|
|
|
</if>
|
|
|
|
|
|
AND (p.deleted IS NULL OR p.deleted = false)
|
|
|
|
|
|
</where>
|
|
|
|
|
|
ORDER BY p.create_time DESC
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 根据条件查询系统权限分页列表 -->
|
|
|
|
|
|
<select id="getPermissionPageByFilter" resultMap="PermissionVOResultMap">
|
|
|
|
|
|
SELECT
|
|
|
|
|
|
p.permission_id, p.name AS permission_name, p.code AS permission_code, p.description AS permission_description, p.status AS permission_status,
|
|
|
|
|
|
p.module_id, m.name AS module_name, m.description AS module_description,
|
|
|
|
|
|
p.optsn, p.creator, p.updater, p.dept_path, p.remark, p.create_time, p.update_time, p.delete_time, p.deleted
|
|
|
|
|
|
FROM sys.tb_sys_permission p
|
|
|
|
|
|
LEFT JOIN sys.tb_sys_module m ON p.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
|
|
|
|
|
|
<where>
|
|
|
|
|
|
<if test="filter.permissionId != null and filter.permissionId != ''">
|
|
|
|
|
|
AND p.permission_id = #{filter.permissionId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="filter.name != null and filter.name != ''">
|
|
|
|
|
|
AND p.name LIKE CONCAT('%', #{filter.name}, '%')
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="filter.code != null and filter.code != ''">
|
|
|
|
|
|
AND p.code LIKE CONCAT('%', #{filter.code}, '%')
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="filter.moduleId != null and filter.moduleId != ''">
|
|
|
|
|
|
AND p.module_id = #{filter.moduleId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="filter.status != null and filter.status != ''">
|
|
|
|
|
|
AND p.status = #{filter.status}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="filter.deptPath != null and filter.deptPath != ''">
|
|
|
|
|
|
AND p.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
|
|
|
|
|
|
</if>
|
|
|
|
|
|
AND (p.deleted IS NULL OR p.deleted = false)
|
|
|
|
|
|
</where>
|
|
|
|
|
|
ORDER BY p.create_time DESC
|
|
|
|
|
|
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 根据条件查询系统权限数量 -->
|
2025-12-02 16:13:28 +08:00
|
|
|
|
<select id="getPermissionCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysPermissionDTO">
|
2025-12-02 13:21:18 +08:00
|
|
|
|
SELECT COUNT(1)
|
|
|
|
|
|
FROM sys.tb_sys_permission
|
|
|
|
|
|
<where>
|
|
|
|
|
|
<if test="filter.permissionId != null and filter.permissionId != ''">
|
|
|
|
|
|
AND permission_id = #{filter.permissionId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="filter.name != null and filter.name != ''">
|
|
|
|
|
|
AND name LIKE CONCAT('%', #{filter.name}, '%')
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="filter.code != null and filter.code != ''">
|
|
|
|
|
|
AND code LIKE CONCAT('%', #{filter.code}, '%')
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="filter.moduleId != null and filter.moduleId != ''">
|
|
|
|
|
|
AND module_id = #{filter.moduleId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="filter.status != null and filter.status != ''">
|
|
|
|
|
|
AND status = #{filter.status}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="filter.deptPath != null and filter.deptPath != ''">
|
|
|
|
|
|
AND dept_path LIKE CONCAT(#{filter.deptPath}, '%')
|
|
|
|
|
|
</if>
|
|
|
|
|
|
AND (deleted IS NULL OR deleted = false)
|
|
|
|
|
|
</where>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
</mapper>
|
|
|
|
|
|
|