This commit is contained in:
2025-12-02 13:21:18 +08:00
parent fab8c13cb3
commit ee6dd64f98
192 changed files with 25783 additions and 0 deletions

View File

@@ -0,0 +1,99 @@
# ================== Server ==================
server:
port: 8082
servlet:
context-path: /urban-lifeline/system
# ================== Auth ====================
urban-lifeline:
auth:
enabled: true
# 认证接口:可以按服务自定义
login-path: /urban-lifeline/auth/login
logout-path: /urban-lifeline/auth/logout
captcha-path: /urban-lifeline/auth/captcha
refresh-path: /urban-lifeline/auth/refresh
# 通用白名单(非认证接口)
whitelist:
# Swagger/OpenAPI 文档相关(建议不带 context-path
- /swagger-ui/**
- /swagger-ui.html
- /v3/api-docs/**
- /webjars/**
# 静态资源
- /favicon.ico
- /error
# 健康检查
- /actuator/health
- /actuator/info
# 其他需要放行的路径
# - /public/**
# - /api/public/**
# ================== Spring ==================
spring:
# ================== DataSource ==================
datasource:
# 按你的实际库名改一下,比如 urban-lifeline_system
url: jdbc:postgresql://127.0.0.1:5432/urban-lifeline # 换成你的 PG 库名
username: postgres # PG 用户
password: "123456" # PG 密码
driver-class-name: org.postgresql.Driver
# ================== Redis ==================
data:
redis:
host: 127.0.0.1 # 如果是 docker 跑的 redis按实际 host / 端口改
port: 6379
database: 0
# password: "" # 如果有密码就填上,没密码可以去掉这一行
# ================== SpringDoc ==================
springdoc:
api-docs:
enabled: true
path: /v3/api-docs
swagger-ui:
enabled: true
path: /swagger-ui.html
try-it-out-enabled: true
show-common-extensions: true
show-extensions: true
show-request-duration: true
filter: true
tags-sorter: alpha
operations-sorter: alpha
group-configs:
- group: 'default'
display-name: '系统服务 API'
paths-to-match: '/**'
# ================== Dubbo + Nacos 注册中心 ==================
dubbo:
application:
name: urban-lifeline-system
qos-enable: false
protocol:
name: dubbo
port: -1 # -1 表示随机端口,避免端口冲突;也可以写死一个端口
registry:
# Nacos 注册中心地址:使用 docker-compose 中映射到宿主机的 8848 端口
address: nacos://127.0.0.1:8848
# 如果 Nacos 有用户名密码,可以加上:
# username: nacos
# password: nacos
# Dubbo 服务扫描包(你 @DubboService 标注的位置)
scan:
base-packages: org.xyzh.system.service.impl
# ================== MyBatis ==================
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: org.xyzh.common.dto, org.xyzh.api

View File

@@ -0,0 +1,99 @@
# ================== Server ==================
server:
port: 8082
servlet:
context-path: /urban-lifeline/system
# ================== Auth ====================
urban-lifeline:
auth:
enabled: true
# 认证接口:可以按服务自定义
login-path: /urban-lifeline/auth/login
logout-path: /urban-lifeline/auth/logout
captcha-path: /urban-lifeline/auth/captcha
refresh-path: /urban-lifeline/auth/refresh
# 通用白名单(非认证接口)
whitelist:
# Swagger/OpenAPI 文档相关(建议不带 context-path
- /swagger-ui/**
- /swagger-ui.html
- /v3/api-docs/**
- /webjars/**
# 静态资源
- /favicon.ico
- /error
# 健康检查
- /actuator/health
- /actuator/info
# 其他需要放行的路径
# - /public/**
# - /api/public/**
# ================== Spring ==================
spring:
# ================== DataSource ==================
datasource:
# 按你的实际库名改一下,比如 urban-lifeline_system
url: jdbc:postgresql://127.0.0.1:5432/urban-lifeline # 换成你的 PG 库名
username: postgres # PG 用户
password: "123456" # PG 密码
driver-class-name: org.postgresql.Driver
# ================== Redis ==================
data:
redis:
host: 127.0.0.1 # 如果是 docker 跑的 redis按实际 host / 端口改
port: 6379
database: 0
# password: "" # 如果有密码就填上,没密码可以去掉这一行
# ================== SpringDoc ==================
springdoc:
api-docs:
enabled: true
path: /v3/api-docs
swagger-ui:
enabled: true
path: /swagger-ui.html
try-it-out-enabled: true
show-common-extensions: true
show-extensions: true
show-request-duration: true
filter: true
tags-sorter: alpha
operations-sorter: alpha
group-configs:
- group: 'default'
display-name: '系统服务 API'
paths-to-match: '/**'
# ================== Dubbo + Nacos 注册中心 ==================
dubbo:
application:
name: urban-lifeline-system
qos-enable: false
protocol:
name: dubbo
port: -1 # -1 表示随机端口,避免端口冲突;也可以写死一个端口
registry:
# Nacos 注册中心地址:使用 docker-compose 中映射到宿主机的 8848 端口
address: nacos://127.0.0.1:8848
# 如果 Nacos 有用户名密码,可以加上:
# username: nacos
# password: nacos
# Dubbo 服务扫描包(你 @DubboService 标注的位置)
scan:
base-packages: org.xyzh.system.service.impl
# ================== MyBatis ==================
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: org.xyzh.common.dto, org.xyzh.api

View File

@@ -0,0 +1,285 @@
<?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.acl.TbSysAclMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysAclDTO">
<!-- ACL 字段 -->
<id column="acl_id" property="aclId" jdbcType="VARCHAR"/>
<result column="object_type" property="objectType" jdbcType="VARCHAR"/>
<result column="object_id" property="objectId" jdbcType="VARCHAR"/>
<result column="principal_type" property="principalType" jdbcType="VARCHAR"/>
<result column="principal_id" property="principalId" jdbcType="VARCHAR"/>
<result column="principal_dept_id" property="principalDeptId" jdbcType="VARCHAR"/>
<result column="permission" property="permission" jdbcType="VARCHAR"/>
<result column="allow" property="allow" jdbcType="BOOLEAN"/>
<result column="include_descendants" property="includeDescendants" jdbcType="BOOLEAN"/>
<!-- 基础字段 -->
<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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="AclVOResultMap" type="org.xyzh.api.system.vo.AclVO">
<!-- ACL 字段 -->
<id column="acl_id" property="aclId" jdbcType="VARCHAR"/>
<result column="object_type" property="objectType" jdbcType="VARCHAR"/>
<result column="object_id" property="objectId" jdbcType="VARCHAR"/>
<result column="principal_type" property="principalType" jdbcType="VARCHAR"/>
<result column="principal_id" property="principalId" jdbcType="VARCHAR"/>
<result column="principal_dept_id" property="principalDeptId" jdbcType="VARCHAR"/>
<result column="permission" property="permission" jdbcType="INTEGER"/>
<result column="allow" property="allow" jdbcType="BOOLEAN"/>
<result column="include_descendants" property="includeDescendants" jdbcType="BOOLEAN"/>
<!-- 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
acl_id, object_type, object_id, principal_type, principal_id, principal_dept_id, permission, allow, include_descendants,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统访问控制列表(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertAcl" parameterType="org.xyzh.common.dto.sys.TbSysAclDTO">
INSERT INTO sys.tb_sys_acl
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段ACL 主字段 + optsn -->
acl_id,
object_type,
object_id,
principal_type,
principal_id,
principal_dept_id,
permission,
allow,
include_descendants,
optsn,
<!-- 可选字段:根据是否有值动态拼接 -->
<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=",">
<!-- 必填字段值 -->
#{aclId},
#{objectType},
#{objectId},
#{principalType},
#{principalId},
#{principalDeptId},
#{permission},
#{allow},
#{includeDescendants},
#{optsn},
<!-- 可选字段值 -->
<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="updateAcl" parameterType="org.xyzh.common.dto.sys.TbSysAclDTO">
UPDATE sys.tb_sys_acl
<set>
<if test="objectType != null and objectType != ''">
object_type = #{objectType},
</if>
<if test="updater != null and updater != ''">
updater = #{updater},
</if>
<if test="principalId != null and principalId != ''">
principal_id = #{principalId},
</if>
<if test="principalDeptId != null and principalDeptId != ''">
principal_dept_id = #{principalDeptId},
</if>
<if test="permission != null and permission != ''">
permission = #{permission},
</if>
<if test="allow != null">
allow = #{allow},
</if>
<if test="includeDescendants != null">
include_descendants = #{includeDescendants},
</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 acl_id = #{aclId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统访问控制列表 -->
<update id="deleteAcl" parameterType="org.xyzh.common.dto.sys.TbSysAclDTO">
DELETE FROM sys.tb_sys_acl
WHERE acl_id = #{aclId}
</update>
<!-- 根据ID查询系统访问控制列表 -->
<select id="getAclById" resultMap="AclVOResultMap" parameterType="java.lang.String">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_acl
WHERE acl_id = #{aclId}
AND (deleted IS NULL OR deleted = false)
</select>
<!-- 根据对象ID查询系统访问控制列表 -->
<select id="getAclByObjectId" resultMap="AclVOResultMap" parameterType="java.lang.String">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_acl
WHERE object_id = #{objectId}
AND (deleted IS NULL OR deleted = false)
</select>
<!-- 根据条件查询系统访问控制列表列表 -->
<select id="getAclByFilter" resultMap="AclVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysAclDTO">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_acl
<where>
<if test="filter.aclId != null and filter.aclId != ''">
AND acl_id = #{filter.aclId}
</if>
<if test="filter.objectType != null and filter.objectType != ''">
AND object_type LIKE CONCAT('%', #{filter.objectType}, '%')
</if>
<if test="filter.objectId != null and filter.objectId != ''">
AND object_id LIKE CONCAT('%', #{filter.objectId}, '%')
</if>
<if test="filter.principalType != null and filter.principalType != ''">
AND principal_type LIKE CONCAT('%', #{filter.principalType}, '%')
</if>
<if test="filter.principalId != null and filter.principalId != ''">
AND principal_id LIKE CONCAT('%', #{filter.principalId}, '%')
</if>
<if test="filter.principalDeptId != null and filter.principalDeptId != ''">
AND principal_dept_id LIKE CONCAT('%', #{filter.principalDeptId}, '%')
</if>
<if test="filter.permission != null and filter.permission != ''">
AND permission LIKE CONCAT('%', #{filter.permission}, '%')
</if>
<if test="filter.allow != null">
AND allow = #{filter.allow}
</if>
<if test="filter.includeDescendants != null">
AND include_descendants = #{filter.includeDescendants}
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY create_time DESC
</select>
<!-- 根据条件查询系统访问控制列表分页列表 -->
<select id="getAclPageByFilter" resultMap="AclVOResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_acl
<where>
<if test="filter.aclId != null and filter.aclId != ''">
AND acl_id = #{filter.aclId}
</if>
<if test="filter.objectType != null and filter.objectType != ''">
AND object_type LIKE CONCAT('%', #{filter.objectType}, '%')
</if>
<if test="filter.objectId != null and filter.objectId != ''">
AND object_id LIKE CONCAT('%', #{filter.objectId}, '%')
</if>
<if test="filter.principalType != null and filter.principalType != ''">
AND principal_type LIKE CONCAT('%', #{filter.principalType}, '%')
</if>
<if test="filter.principalId != null and filter.principalId != ''">
AND principal_id LIKE CONCAT('%', #{filter.principalId}, '%')
</if>
<if test="filter.principalDeptId != null and filter.principalDeptId != ''">
AND principal_dept_id LIKE CONCAT('%', #{filter.principalDeptId}, '%')
</if>
<if test="filter.permission != null and filter.permission != ''">
AND permission LIKE CONCAT('%', #{filter.permission}, '%')
</if>
<if test="filter.allow != null">
AND allow = #{filter.allow}
</if>
<if test="filter.includeDescendants != null">
AND include_descendants = #{filter.includeDescendants}
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统访问控制列表数量 -->
<select id="getAclCountByFilter" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysAclDTO">
SELECT COUNT(1)
FROM sys.tb_sys_acl
<where>
<if test="filter.aclId != null and filter.aclId != ''">
AND acl_id = #{filter.aclId}
</if>
<if test="filter.objectType != null and filter.objectType != ''">
AND object_type LIKE CONCAT('%', #{filter.objectType}, '%')
</if>
<if test="filter.objectId != null and filter.objectId != ''">
AND object_id LIKE CONCAT('%', #{filter.objectId}, '%')
</if>
<if test="filter.principalType != null and filter.principalType != ''">
AND principal_type LIKE CONCAT('%', #{filter.principalType}, '%')
</if>
<if test="filter.principalId != null and filter.principalId != ''">
AND principal_id LIKE CONCAT('%', #{filter.principalId}, '%')
</if>
<if test="filter.principalDeptId != null and filter.principalDeptId != ''">
AND principal_dept_id LIKE CONCAT('%', #{filter.principalDeptId}, '%')
</if>
<if test="filter.permission != null and filter.permission != ''">
AND permission LIKE CONCAT('%', #{filter.permission}, '%')
</if>
<if test="filter.allow != null">
AND allow = #{filter.allow}
</if>
<if test="filter.includeDescendants != null">
AND include_descendants = #{filter.includeDescendants}
</if>
AND (deleted IS NULL OR deleted = false)
</where>
</select>
</mapper>

View File

@@ -0,0 +1,239 @@
<?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.acl.TbSysAclPolicyMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysAclPolicyDTO">
<!-- ACL 策略字段 -->
<id column="policy_id" property="policyId" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="object_type" property="objectType" jdbcType="VARCHAR"/>
<result column="edit_hierarchy_rule" property="editHierarchyRule" jdbcType="VARCHAR"/>
<result column="view_hierarchy_rule" property="viewHierarchyRule" jdbcType="VARCHAR"/>
<result column="default_permission" property="defaultPermission" jdbcType="INTEGER"/>
<result column="default_allow" property="defaultAllow" jdbcType="BOOLEAN"/>
<result column="apply_to_children" property="applyToChildren" jdbcType="BOOLEAN"/>
<!-- 基础字段 -->
<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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="AclPolicyVOResultMap" type="org.xyzh.api.system.vo.AclVO">
<!-- ACL 策略字段 -->
<id column="policy_id" property="policyId" jdbcType="VARCHAR"/>
<result column="name" property="policyName" jdbcType="VARCHAR"/>
<result column="object_type" property="policyObjectType" jdbcType="VARCHAR"/>
<result column="edit_hierarchy_rule" property="editHierarchyRule" jdbcType="VARCHAR"/>
<result column="view_hierarchy_rule" property="viewHierarchyRule" jdbcType="VARCHAR"/>
<result column="default_permission" property="defaultPermission" jdbcType="INTEGER"/>
<result column="default_allow" property="defaultAllow" jdbcType="BOOLEAN"/>
<result column="apply_to_children" property="applyToChildren" jdbcType="BOOLEAN"/>
<!-- 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
policy_id, name, object_type, edit_hierarchy_rule, view_hierarchy_rule, default_permission, default_allow, apply_to_children,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统访问控制策略(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertAclPolicy" parameterType="org.xyzh.common.dto.sys.TbSysAclPolicyDTO">
INSERT INTO sys.tb_sys_acl_policy
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段:策略主字段 + optsn -->
policy_id,
name,
object_type,
edit_hierarchy_rule,
view_hierarchy_rule,
default_permission,
default_allow,
apply_to_children,
optsn,
<!-- 可选字段:根据是否有值动态拼接 -->
<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=",">
<!-- 必填字段值 -->
#{policyId},
#{name},
#{objectType},
#{editHierarchyRule},
#{viewHierarchyRule},
#{defaultPermission},
#{defaultAllow},
#{applyToChildren},
#{optsn},
<!-- 可选字段值 -->
<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="updateAclPolicy" parameterType="org.xyzh.common.dto.sys.TbSysAclPolicyDTO">
UPDATE sys.tb_sys_acl_policy
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="objectType != null and objectType != ''">
object_type = #{objectType},
</if>
<if test="editHierarchyRule != null and editHierarchyRule != ''">
edit_hierarchy_rule = #{editHierarchyRule},
</if>
<if test="viewHierarchyRule != null and viewHierarchyRule != ''">
view_hierarchy_rule = #{viewHierarchyRule},
</if>
<if test="defaultPermission != null">
default_permission = #{defaultPermission},
</if>
<if test="defaultAllow != null">
default_allow = #{defaultAllow},
</if>
<if test="applyToChildren != null">
apply_to_children = #{applyToChildren},
</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 policy_id = #{policyId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统访问控制策略 -->
<update id="deleteAclPolicy" parameterType="org.xyzh.common.dto.sys.TbSysAclPolicyDTO">
DELETE FROM sys.tb_sys_acl_policy
WHERE policy_id = #{policyId}
</update>
<!-- 根据ID查询系统访问控制策略 -->
<select id="getAclPolicyById" resultMap="AclPolicyVOResultMap" parameterType="java.lang.String">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_acl_policy
WHERE policy_id = #{policyId}
AND (deleted IS NULL OR deleted = false)
</select>
<!-- 根据条件查询系统访问控制策略列表 -->
<select id="getAclPolicyByFilter" resultMap="AclPolicyVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysAclPolicyDTO">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_acl_policy
<where>
<if test="filter.policyId != null and filter.policyId != ''">
AND policy_id = #{filter.policyId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.objectType != null and filter.objectType != ''">
AND object_type = #{filter.objectType}
</if>
<if test="filter.editHierarchyRule != null and filter.editHierarchyRule != ''">
AND edit_hierarchy_rule = #{filter.editHierarchyRule}
</if>
<if test="filter.viewHierarchyRule != null and filter.viewHierarchyRule != ''">
AND view_hierarchy_rule = #{filter.viewHierarchyRule}
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY create_time DESC
</select>
<!-- 根据条件查询系统访问控制策略分页列表 -->
<select id="getAclPolicyPageByFilter" resultMap="AclPolicyVOResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_acl_policy
<where>
<if test="filter.policyId != null and filter.policyId != ''">
AND policy_id = #{filter.policyId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.objectType != null and filter.objectType != ''">
AND object_type = #{filter.objectType}
</if>
<if test="filter.editHierarchyRule != null and filter.editHierarchyRule != ''">
AND edit_hierarchy_rule = #{filter.editHierarchyRule}
</if>
<if test="filter.viewHierarchyRule != null and filter.viewHierarchyRule != ''">
AND view_hierarchy_rule = #{filter.viewHierarchyRule}
</if>
AND (deleted IS NULL OR deleted = false)
</where>
ORDER BY create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统访问控制策略数量 -->
<select id="getAclPolicyCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysAclPolicyDTO">
SELECT COUNT(1)
FROM sys.tb_sys_acl_policy
<where>
<if test="filter.policyId != null and filter.policyId != ''">
AND policy_id = #{filter.policyId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.objectType != null and filter.objectType != ''">
AND object_type = #{filter.objectType}
</if>
<if test="filter.editHierarchyRule != null and filter.editHierarchyRule != ''">
AND edit_hierarchy_rule = #{filter.editHierarchyRule}
</if>
<if test="filter.viewHierarchyRule != null and filter.viewHierarchyRule != ''">
AND view_hierarchy_rule = #{filter.viewHierarchyRule}
</if>
AND (deleted IS NULL OR deleted = false)
</where>
</select>
</mapper>

View File

@@ -0,0 +1,258 @@
<?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.config.TbSysConfigMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysConfigDTO">
<!-- 配置字段 -->
<id column="config_id" property="configId" jdbcType="VARCHAR"/>
<result column="key" property="key" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="value" property="value" jdbcType="VARCHAR"/>
<result column="config_type" property="configType" jdbcType="VARCHAR"/>
<result column="render_type" property="renderType" jdbcType="VARCHAR"/>
<result column="description" property="description" jdbcType="VARCHAR"/>
<result column="re" property="re" jdbcType="OTHER"/>
<result column="options" property="options" jdbcType="OTHER"/>
<result column="group" property="group" jdbcType="VARCHAR"/>
<result column="module_id" property="moduleId" jdbcType="VARCHAR"/>
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<!-- 基础字段 -->
<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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="ConfigVOResultMap" type="org.xyzh.api.system.vo.SysConfigVO">
<!-- 配置字段 -->
<id column="config_id" property="configId" jdbcType="VARCHAR"/>
<result column="key" property="key" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="value" property="value" jdbcType="VARCHAR"/>
<result column="config_type" property="configType" jdbcType="VARCHAR"/>
<result column="render_type" property="renderType" jdbcType="VARCHAR"/>
<result column="description" property="description" jdbcType="VARCHAR"/>
<result column="re" property="re" jdbcType="OTHER"/>
<result column="options" property="options" jdbcType="OTHER"/>
<result column="group" property="group" jdbcType="VARCHAR"/>
<result column="module_id" property="moduleId" jdbcType="VARCHAR"/>
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<!-- 模块关联字段 -->
<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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
config_id, key, name, value, config_type, render_type, description, re, options, "group", module_id, order_num, status,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统配置 -->
<insert id="insertConfig" parameterType="TbSysConfigDTO">
INSERT INTO config.tb_sys_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 无默认值字段:必填固定列 -->
config_id,
key,
name,
value,
config_type,
render_type,
description,
"group",
module_id,
order_num,
optsn,
remark,
<!-- 有默认值/可空字段:根据是否传值动态拼接 -->
<if test="re != null">re,</if>
<if test="options != null">options,</if>
<if test="status != null">status,</if>
<if test="creator != null and creator != ''">creator,</if>
<if test="updater != null and updater != ''">updater,</if>
<if test="deptPath != null and deptPath != ''">dept_path,</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=",">
<!-- 无默认值字段:必填固定值 -->
#{configId},
#{key},
#{name},
#{value},
#{configType},
#{renderType},
#{description},
#{group},
#{moduleId},
#{orderNum},
#{optsn},
#{remark},
<!-- 有默认值/可空字段:根据是否传值动态拼接 -->
<if test="re != null">#{re},</if>
<if test="options != null">#{options},</if>
<if test="status != null">#{status},</if>
<if test="creator != null and creator != ''">#{creator},</if>
<if test="updater != null and updater != ''">#{updater},</if>
<if test="deptPath != null and deptPath != ''">#{deptPath},</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="updateConfig" parameterType="TbSysConfigDTO">
UPDATE config.tb_sys_config
<set>
<if test="key != null and key != ''">key = #{key},</if>
<if test="name != null and name != ''">name = #{name},</if>
<if test="value != null and value != ''">value = #{value},</if>
<if test="configType != null and configType != ''">config_type = #{configType},</if>
<if test="renderType != null and renderType != ''">render_type = #{renderType},</if>
<if test="description != null and description != ''">description = #{description},</if>
<if test="re != null">re = #{re},</if>
<if test="options != null">options = #{options},</if>
<if test="group != null and group != ''">"group" = #{group},</if>
<if test="moduleId != null and moduleId != ''">module_id = #{moduleId},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="status != null">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>
<if test="deleteTime != null">delete_time = #{deleteTime},</if>
<if test="deleted != null">deleted = #{deleted},</if>
</set>
WHERE config_id = #{configId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统配置 -->
<update id="deleteConfig" parameterType="TbSysConfigDTO">
UPDATE config.tb_sys_config
SET deleted = true,
delete_time = NOW()
WHERE config_id = #{configId}
</update>
<!-- 根据条件查询系统配置列表 -->
<select id="getConfigByFilter" resultMap="ConfigVOResultMap" parameterType="TbSysConfigDTO">
SELECT
c.config_id, c.key, c.name, c.value, c.config_type, c.render_type, c.description, c.re, c.options, c."group", c.module_id, c.order_num, c.status,
c.optsn, c.creator, c.updater, c.dept_path, c.remark, c.create_time, c.update_time, c.delete_time, c.deleted,
m.name AS module_name, m.description AS module_description
FROM config.tb_sys_config c
LEFT JOIN sys.tb_sys_module m ON c.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
<where>
<if test="filter.configId != null and filter.configId != ''">
AND c.config_id = #{filter.configId}
</if>
<if test="filter.key != null and filter.key != ''">
AND c.key LIKE CONCAT('%', #{filter.key}, '%')
</if>
<if test="filter.configType != null and filter.configType != ''">
AND c.config_type = #{filter.configType}
</if>
<if test="filter.moduleId != null and filter.moduleId != ''">
AND c.module_id = #{filter.moduleId}
</if>
<if test="filter.status != null and filter.status != ''">
AND c.status = #{filter.status}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND c.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (c.deleted IS NULL OR c.deleted = false)
</where>
ORDER BY c.order_num ASC, c.create_time DESC
</select>
<!-- 根据条件查询系统配置分页列表 -->
<select id="getConfigPageByFilter" resultMap="ConfigVOResultMap">
SELECT
c.config_id, c.key, c.name, c.value, c.config_type, c.render_type, c.description, c.re, c.options, c."group", c.module_id, c.order_num, c.status,
c.optsn, c.creator, c.updater, c.dept_path, c.remark, c.create_time, c.update_time, c.delete_time, c.deleted,
m.name AS module_name, m.description AS module_description
FROM config.tb_sys_config c
LEFT JOIN sys.tb_sys_module m ON c.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
<where>
<if test="filter.configId != null and filter.configId != ''">
AND c.config_id = #{filter.configId}
</if>
<if test="filter.key != null and filter.key != ''">
AND c.key LIKE CONCAT('%', #{filter.key}, '%')
</if>
<if test="filter.configType != null and filter.configType != ''">
AND c.config_type = #{filter.configType}
</if>
<if test="filter.moduleId != null and filter.moduleId != ''">
AND c.module_id = #{filter.moduleId}
</if>
<if test="filter.status != null and filter.status != ''">
AND c.status = #{filter.status}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND c.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (c.deleted IS NULL OR c.deleted = false)
</where>
ORDER BY c.order_num ASC, c.create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统配置数量 -->
<select id="getConfigCount" resultType="java.lang.Integer" parameterType="TbSysConfigDTO">
SELECT COUNT(1)
FROM config.tb_sys_config
<where>
<if test="filter.configId != null and filter.configId != ''">
AND config_id = #{filter.configId}
</if>
<if test="filter.key != null and filter.key != ''">
AND key LIKE CONCAT('%', #{filter.key}, '%')
</if>
<if test="filter.configType != null and filter.configType != ''">
AND config_type = #{filter.configType}
</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>

View File

@@ -0,0 +1,196 @@
<?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.dept.TbSysDeptMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysDeptDTO">
<!-- 部门字段 -->
<id column="dept_id" property="deptId" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="parent_id" property="parentId" jdbcType="VARCHAR"/>
<result column="description" property="description" 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="PermissionVOResultMap" type="org.xyzh.api.system.vo.PermissionVO">
<!-- 部门字段 -->
<id column="dept_id" property="deptId" jdbcType="VARCHAR"/>
<result column="name" property="deptName" jdbcType="VARCHAR"/>
<result column="parent_id" property="deptParentId" jdbcType="VARCHAR"/>
<result column="description" property="deptDescription" 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
dept_id, name, parent_id, description,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统部门(按表字段 + 默认值动态列,仅修改 insert -->
<insert id="insertDept" parameterType="org.xyzh.common.dto.sys.TbSysDeptDTO">
INSERT INTO sys.tb_sys_dept
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段NOT NULL 且无默认值):根据建表约束,这里视 dept_id, name, optsn 为必填 -->
dept_id,
name,
optsn,
<!-- 其他字段(可空或有默认值):动态拼接 -->
<if test="parentId != null and parentId != ''">parent_id,</if>
<if test="description != null and description != ''">description,</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=",">
<!-- 必填字段对应的值 -->
#{deptId},
#{name},
#{optsn},
<!-- 其他字段对应的值 -->
<if test="parentId != null and parentId != ''">#{parentId},</if>
<if test="description != null and description != ''">#{description},</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="updateDept" parameterType="org.xyzh.common.dto.sys.TbSysDeptDTO">
UPDATE sys.tb_sys_dept
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="parentId != null">
parent_id = #{parentId},
</if>
<if test="description != null">
description = #{description},
</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 dept_id = #{deptId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统部门 -->
<update id="deleteDept" parameterType="org.xyzh.common.dto.sys.TbSysDeptDTO">
UPDATE sys.tb_sys_dept
SET deleted = true,
delete_time = NOW()
WHERE dept_id = #{deptId}
</update>
<!-- 根据条件查询系统部门列表 -->
<select id="getDeptByFilter" resultMap="PermissionVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysDeptDTO">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_dept
<where>
<if test="filter.deptId != null and filter.deptId != ''">
AND dept_id = #{filter.deptId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.parentId != null and filter.parentId != ''">
AND parent_id = #{filter.parentId}
</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>
ORDER BY create_time DESC
</select>
<!-- 根据条件查询系统部门分页列表 -->
<select id="getDeptPageByFilter" resultMap="PermissionVOResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_dept
<where>
<if test="filter.deptId != null and filter.deptId != ''">
AND dept_id = #{filter.deptId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.parentId != null and filter.parentId != ''">
AND parent_id = #{filter.parentId}
</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>
ORDER BY create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统部门数量 -->
<select id="getDeptCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysDeptDTO">
SELECT COUNT(1)
FROM sys.tb_sys_dept
<where>
<if test="filter.deptId != null and filter.deptId != ''">
AND dept_id = #{filter.deptId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.parentId != null and filter.parentId != ''">
AND parent_id = #{filter.parentId}
</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>

View File

@@ -0,0 +1,203 @@
<?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.dept.TbSysDeptRoleMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysDeptRoleDTO">
<!-- 部门角色关系字段 -->
<id column="dept_id" property="deptId" jdbcType="VARCHAR"/>
<id column="role_id" property="roleId" 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="PermissionVOResultMap" type="org.xyzh.api.system.vo.PermissionVO">
<!-- 部门字段 -->
<result column="dept_id" property="deptId" jdbcType="VARCHAR"/>
<result column="dept_name" property="deptName" jdbcType="VARCHAR"/>
<result column="parent_id" property="deptParentId" jdbcType="VARCHAR"/>
<result column="dept_description" property="deptDescription" 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="scope" property="roleScope" jdbcType="VARCHAR"/>
<result column="owner_dept_id" property="roleOwnerDeptId" jdbcType="VARCHAR"/>
<result column="role_status" property="roleStatus" jdbcType="BOOLEAN"/>
<!-- 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
dept_id, role_id,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统部门角色关系(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertDeptRole" parameterType="org.xyzh.common.dto.sys.TbSysDeptRoleDTO">
INSERT INTO sys.tb_sys_dept_role
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段dept_id, role_id, optsn -->
dept_id,
role_id,
optsn,
<!-- 可选字段:根据是否有值动态拼接 -->
<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=",">
<!-- 必填字段值 -->
#{deptId},
#{roleId},
#{optsn},
<!-- 可选字段值 -->
<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="updateDeptRole" parameterType="org.xyzh.common.dto.sys.TbSysDeptRoleDTO">
UPDATE sys.tb_sys_dept_role
<set>
<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 dept_id = #{deptId} AND role_id = #{roleId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统部门角色关系 -->
<update id="deleteDeptRole" parameterType="org.xyzh.common.dto.sys.TbSysDeptRoleDTO">
UPDATE sys.tb_sys_dept_role
SET deleted = true,
delete_time = NOW()
WHERE dept_id = #{deptId} AND role_id = #{roleId}
</update>
<!-- 根据部门ID和角色ID查询系统部门角色关系 -->
<select id="getDeptRoleByDeptId" resultMap="PermissionVOResultMap">
SELECT
dr.dept_id, dr.role_id,
d.dept_id, d.name AS dept_name, d.parent_id, d.description AS dept_description,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope, r.owner_dept_id, r.status AS role_status,
dr.optsn, dr.creator, dr.updater, dr.dept_path, dr.remark, dr.create_time, dr.update_time, dr.delete_time, dr.deleted
FROM sys.tb_sys_dept_role dr
LEFT JOIN sys.tb_sys_dept d ON dr.dept_id = d.dept_id AND (d.deleted IS NULL OR d.deleted = false)
LEFT JOIN sys.tb_sys_role r ON dr.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
WHERE dr.dept_id = #{deptId} AND dr.role_id = #{roleId}
AND (dr.deleted IS NULL OR dr.deleted = false)
</select>
<!-- 根据条件查询系统部门角色关系列表 -->
<select id="getDeptRoleByFilter" resultMap="PermissionVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysDeptRoleDTO">
SELECT DISTINCT
dr.dept_id, dr.role_id,
d.dept_id, d.name AS dept_name, d.parent_id, d.description AS dept_description,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope, r.owner_dept_id, r.status AS role_status,
dr.optsn, dr.creator, dr.updater, dr.dept_path, dr.remark, dr.create_time, dr.update_time, dr.delete_time, dr.deleted
FROM sys.tb_sys_dept_role dr
LEFT JOIN sys.tb_sys_dept d ON dr.dept_id = d.dept_id AND (d.deleted IS NULL OR d.deleted = false)
LEFT JOIN sys.tb_sys_role r ON dr.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
<where>
<if test="filter.deptId != null and filter.deptId != ''">
AND dr.dept_id = #{filter.deptId}
</if>
<if test="filter.roleId != null and filter.roleId != ''">
AND dr.role_id = #{filter.roleId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dr.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (dr.deleted IS NULL OR dr.deleted = false)
</where>
ORDER BY dr.create_time DESC
</select>
<!-- 根据条件查询系统部门角色关系分页列表 -->
<select id="getDeptRolePageByFilter" resultMap="PermissionVOResultMap">
SELECT DISTINCT
dr.dept_id, dr.role_id,
d.dept_id, d.name AS dept_name, d.parent_id, d.description AS dept_description,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope, r.owner_dept_id, r.status AS role_status,
dr.optsn, dr.creator, dr.updater, dr.dept_path, dr.remark, dr.create_time, dr.update_time, dr.delete_time, dr.deleted
FROM sys.tb_sys_dept_role dr
LEFT JOIN sys.tb_sys_dept d ON dr.dept_id = d.dept_id AND (d.deleted IS NULL OR d.deleted = false)
LEFT JOIN sys.tb_sys_role r ON dr.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
<where>
<if test="filter.deptId != null and filter.deptId != ''">
AND dr.dept_id = #{filter.deptId}
</if>
<if test="filter.roleId != null and filter.roleId != ''">
AND dr.role_id = #{filter.roleId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND dr.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (dr.deleted IS NULL OR dr.deleted = false)
</where>
ORDER BY dr.create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统部门角色关系数量 -->
<select id="getDeptRoleCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysDeptRoleDTO">
SELECT COUNT(1)
FROM sys.tb_sys_dept_role
<where>
<if test="filter.deptId != null and filter.deptId != ''">
AND dept_id = #{filter.deptId}
</if>
<if test="filter.roleId != null and filter.roleId != ''">
AND role_id = #{filter.roleId}
</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>

View File

@@ -0,0 +1,189 @@
<?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.module.TbSysModuleMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysModuleDTO">
<!-- 模块字段 -->
<id column="module_id" property="moduleId" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="description" property="description" 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="PermissionVOResultMap" type="org.xyzh.api.system.vo.PermissionVO">
<!-- 模块字段 -->
<id column="module_id" property="moduleId" jdbcType="VARCHAR"/>
<result column="name" property="moduleName" jdbcType="VARCHAR"/>
<result column="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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
module_id, name, description,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统模块(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertModule" parameterType="org.xyzh.common.dto.sys.TbSysModuleDTO">
INSERT INTO sys.tb_sys_module
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段module_id, name, optsn -->
module_id,
name,
optsn,
<!-- 可选字段description 及基础字段 -->
<if test="description != null and description != ''">description,</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=",">
<!-- 必填字段对应的值 -->
#{moduleId},
#{name},
#{optsn},
<!-- 可选字段对应的值 -->
<if test="description != null and description != ''">#{description},</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="updateModule" parameterType="org.xyzh.common.dto.sys.TbSysModuleDTO">
UPDATE sys.tb_sys_module
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="description != null">
description = #{description},
</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 module_id = #{moduleId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统模块 -->
<update id="deleteModule" parameterType="org.xyzh.common.dto.sys.TbSysModuleDTO">
UPDATE sys.tb_sys_module
SET deleted = true,
delete_time = NOW()
WHERE module_id = #{moduleId}
</update>
<!-- 根据模块ID查询系统模块 -->
<select id="getModuleById" resultMap="PermissionVOResultMap" parameterType="java.lang.String">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_module
WHERE module_id = #{moduleId}
AND (deleted IS NULL OR deleted = false)
</select>
<!-- 根据条件查询系统模块列表 -->
<select id="getModuleByFilter" resultMap="PermissionVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysModuleDTO">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_module
<where>
<if test="filter.moduleId != null and filter.moduleId != ''">
AND module_id = #{filter.moduleId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</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>
ORDER BY create_time DESC
</select>
<!-- 根据条件查询系统模块分页列表 -->
<select id="getModulePageByFilter" resultMap="PermissionVOResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_module
<where>
<if test="filter.moduleId != null and filter.moduleId != ''">
AND module_id = #{filter.moduleId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</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>
ORDER BY create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统模块数量 -->
<select id="getModuleCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysModuleDTO">
SELECT COUNT(1)
FROM sys.tb_sys_module
<where>
<if test="filter.moduleId != null and filter.moduleId != ''">
AND module_id = #{filter.moduleId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</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>

View File

@@ -0,0 +1,249 @@
<?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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</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>
<!-- 根据条件查询系统权限数量 -->
<select id="getPermissionCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysPermissionDTO">
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>

View File

@@ -0,0 +1,221 @@
<?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.TbSysViewPermissionMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysViewPermissionDTO">
<!-- 视图权限关系字段 -->
<id column="view_id" property="viewId" jdbcType="VARCHAR"/>
<id column="permission_id" property="permissionId" 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="PermissionVOResultMap" type="org.xyzh.api.system.vo.PermissionVO">
<!-- 视图字段 -->
<result column="view_id" property="viewId" jdbcType="VARCHAR"/>
<result column="view_name" property="viewName" jdbcType="VARCHAR"/>
<result column="view_parent_id" property="viewParentId" jdbcType="VARCHAR"/>
<result column="view_url" property="viewUrl" jdbcType="VARCHAR"/>
<result column="view_component" property="viewComponent" jdbcType="VARCHAR"/>
<result column="view_icon" property="viewIcon" jdbcType="VARCHAR"/>
<result column="view_type" property="viewType" jdbcType="INTEGER"/>
<result column="view_layout" property="viewLayout" jdbcType="VARCHAR"/>
<result column="view_order_num" property="viewOrderNum" jdbcType="INTEGER"/>
<result column="view_description" property="viewDescription" jdbcType="VARCHAR"/>
<!-- 权限字段 -->
<result 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
view_id, permission_id,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统视图权限关系(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertViewPermission" parameterType="org.xyzh.common.dto.sys.TbSysViewPermissionDTO">
INSERT INTO sys.tb_sys_view_permission
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段view_id, permission_id, optsn -->
view_id,
permission_id,
optsn,
<!-- 可选字段:基础审计字段 -->
<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=",">
<!-- 必填字段值 -->
#{viewId},
#{permissionId},
#{optsn},
<!-- 可选字段值 -->
<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="updateViewPermission" parameterType="org.xyzh.common.dto.sys.TbSysViewPermissionDTO">
UPDATE sys.tb_sys_view_permission
<set>
<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 view_id = #{viewId} AND permission_id = #{permissionId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统视图权限关系 -->
<update id="deleteViewPermission" parameterType="org.xyzh.common.dto.sys.TbSysViewPermissionDTO">
UPDATE sys.tb_sys_view_permission
SET deleted = true,
delete_time = NOW()
WHERE view_id = #{viewId} AND permission_id = #{permissionId}
</update>
<!-- 根据视图ID和权限ID查询系统视图权限关系 -->
<select id="getViewPermissionByViewId" resultMap="PermissionVOResultMap">
SELECT
vp.view_id, vp.permission_id,
v.view_id, v.name AS view_name, v.parent_id AS view_parent_id, v.url AS view_url, v.component AS view_component,
v.icon AS view_icon, v.type AS view_type, v.layout AS view_layout, v.order_num AS view_order_num, v.description AS view_description,
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,
vp.optsn, vp.creator, vp.updater, vp.dept_path, vp.remark, vp.create_time, vp.update_time, vp.delete_time, vp.deleted
FROM sys.tb_sys_view_permission vp
LEFT JOIN sys.tb_sys_view v ON vp.view_id = v.view_id AND (v.deleted IS NULL OR v.deleted = false)
LEFT JOIN sys.tb_sys_permission p ON vp.permission_id = p.permission_id AND (p.deleted IS NULL OR p.deleted = false)
LEFT JOIN sys.tb_sys_module m ON p.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
WHERE vp.view_id = #{viewId} AND vp.permission_id = #{permissionId}
AND (vp.deleted IS NULL OR vp.deleted = false)
</select>
<!-- 根据条件查询系统视图权限关系列表 -->
<select id="getViewPermissionByFilter" resultMap="PermissionVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysViewPermissionDTO">
SELECT
vp.view_id, vp.permission_id,
v.view_id, v.name AS view_name, v.parent_id AS view_parent_id, v.url AS view_url, v.component AS view_component,
v.icon AS view_icon, v.type AS view_type, v.layout AS view_layout, v.order_num AS view_order_num, v.description AS view_description,
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,
vp.optsn, vp.creator, vp.updater, vp.dept_path, vp.remark, vp.create_time, vp.update_time, vp.delete_time, vp.deleted
FROM sys.tb_sys_view_permission vp
LEFT JOIN sys.tb_sys_view v ON vp.view_id = v.view_id AND (v.deleted IS NULL OR v.deleted = false)
LEFT JOIN sys.tb_sys_permission p ON vp.permission_id = p.permission_id AND (p.deleted IS NULL OR p.deleted = false)
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.viewId != null and filter.viewId != ''">
AND vp.view_id = #{filter.viewId}
</if>
<if test="filter.permissionId != null and filter.permissionId != ''">
AND vp.permission_id = #{filter.permissionId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND vp.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (vp.deleted IS NULL OR vp.deleted = false)
</where>
ORDER BY vp.create_time DESC
</select>
<!-- 根据条件查询系统视图权限关系分页列表 -->
<select id="getViewPermissionPageByFilter" resultMap="PermissionVOResultMap">
SELECT
vp.view_id, vp.permission_id,
v.view_id, v.name AS view_name, v.parent_id AS view_parent_id, v.url AS view_url, v.component AS view_component,
v.icon AS view_icon, v.type AS view_type, v.layout AS view_layout, v.order_num AS view_order_num, v.description AS view_description,
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,
vp.optsn, vp.creator, vp.updater, vp.dept_path, vp.remark, vp.create_time, vp.update_time, vp.delete_time, vp.deleted
FROM sys.tb_sys_view_permission vp
LEFT JOIN sys.tb_sys_view v ON vp.view_id = v.view_id AND (v.deleted IS NULL OR v.deleted = false)
LEFT JOIN sys.tb_sys_permission p ON vp.permission_id = p.permission_id AND (p.deleted IS NULL OR p.deleted = false)
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.viewId != null and filter.viewId != ''">
AND vp.view_id = #{filter.viewId}
</if>
<if test="filter.permissionId != null and filter.permissionId != ''">
AND vp.permission_id = #{filter.permissionId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND vp.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (vp.deleted IS NULL OR vp.deleted = false)
</where>
ORDER BY vp.create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统视图权限关系数量 -->
<select id="getViewPermissionCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysViewPermissionDTO">
SELECT COUNT(1)
FROM sys.tb_sys_view_permission
<where>
<if test="filter.viewId != null and filter.viewId != ''">
AND view_id = #{filter.viewId}
</if>
<if test="filter.permissionId != null and filter.permissionId != ''">
AND permission_id = #{filter.permissionId}
</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>

View File

@@ -0,0 +1,228 @@
<?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.role.TbSysRoleMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysRoleDTO">
<!-- 角色字段 -->
<id column="role_id" property="roleId" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="description" property="description" jdbcType="VARCHAR"/>
<result column="scope" property="scope" jdbcType="VARCHAR"/>
<result column="owner_dept_id" property="ownerDeptId" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="BOOLEAN"/>
<!-- 基础字段 -->
<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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="PermissionVOResultMap" type="org.xyzh.api.system.vo.PermissionVO">
<!-- 角色字段 -->
<id column="role_id" property="roleId" jdbcType="VARCHAR"/>
<result column="name" property="roleName" jdbcType="VARCHAR"/>
<result column="description" property="roleDescription" jdbcType="VARCHAR"/>
<result column="scope" property="roleScope" jdbcType="VARCHAR"/>
<result column="owner_dept_id" property="roleOwnerDeptId" jdbcType="VARCHAR"/>
<result column="status" property="roleStatus" jdbcType="BOOLEAN"/>
<!-- 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
role_id, name, description, scope, owner_dept_id, status,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统角色(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertRole" parameterType="org.xyzh.common.dto.sys.TbSysRoleDTO">
INSERT INTO sys.tb_sys_role
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 假定必填字段role_id, name, optsn -->
role_id,
name,
optsn,
<!-- 其他字段视为可选/有默认:动态拼接 -->
<if test="description != null and description != ''">description,</if>
<if test="scope != null and scope != ''">scope,</if>
<if test="ownerDeptId != null and ownerDeptId != ''">owner_dept_id,</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=",">
<!-- 必填字段值 -->
#{roleId},
#{name},
#{optsn},
<!-- 可选字段值 -->
<if test="description != null and description != ''">#{description},</if>
<if test="scope != null and scope != ''">#{scope},</if>
<if test="ownerDeptId != null and ownerDeptId != ''">#{ownerDeptId},</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="updateRole" parameterType="org.xyzh.common.dto.sys.TbSysRoleDTO">
UPDATE sys.tb_sys_role
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="description != null">
description = #{description},
</if>
<if test="scope != null and scope != ''">
scope = #{scope},
</if>
<if test="ownerDeptId != null">
owner_dept_id = #{ownerDeptId},
</if>
<if test="status != null">
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 role_id = #{roleId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统角色 -->
<update id="deleteRole" parameterType="org.xyzh.common.dto.sys.TbSysRoleDTO">
UPDATE sys.tb_sys_role
SET deleted = true,
delete_time = NOW()
WHERE role_id = #{roleId}
</update>
<!-- 根据条件查询系统角色列表 -->
<select id="getRoleByFilter" resultMap="PermissionVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysRoleDTO">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_role
<where>
<if test="filter.roleId != null and filter.roleId != ''">
AND role_id = #{filter.roleId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.scope != null and filter.scope != ''">
AND scope = #{filter.scope}
</if>
<if test="filter.ownerDeptId != null and filter.ownerDeptId != ''">
AND owner_dept_id = #{filter.ownerDeptId}
</if>
<if test="filter.status != null">
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>
ORDER BY create_time DESC
</select>
<!-- 根据条件查询系统角色分页列表 -->
<select id="getRolePageByFilter" resultMap="PermissionVOResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_role
<where>
<if test="filter.roleId != null and filter.roleId != ''">
AND role_id = #{filter.roleId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.scope != null and filter.scope != ''">
AND scope = #{filter.scope}
</if>
<if test="filter.ownerDeptId != null and filter.ownerDeptId != ''">
AND owner_dept_id = #{filter.ownerDeptId}
</if>
<if test="filter.status != null">
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>
ORDER BY create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统角色数量 -->
<select id="getRoleCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysRoleDTO">
SELECT COUNT(1)
FROM sys.tb_sys_role
<where>
<if test="filter.roleId != null and filter.roleId != ''">
AND role_id = #{filter.roleId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.scope != null and filter.scope != ''">
AND scope = #{filter.scope}
</if>
<if test="filter.ownerDeptId != null and filter.ownerDeptId != ''">
AND owner_dept_id = #{filter.ownerDeptId}
</if>
<if test="filter.status != null">
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>

View File

@@ -0,0 +1,245 @@
<?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.role.TbSysRolePermissionMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysRolePermissionDTO">
<!-- 角色权限关系字段 -->
<id column="role_id" property="roleId" jdbcType="VARCHAR"/>
<id column="permission_id" property="permissionId" 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="PermissionVOResultMap" type="org.xyzh.api.system.vo.PermissionVO">
<!-- 角色字段 -->
<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="role_scope" property="roleScope" jdbcType="VARCHAR"/>
<result column="role_owner_dept_id" property="roleOwnerDeptId" jdbcType="VARCHAR"/>
<result column="role_status" property="roleStatus" jdbcType="BOOLEAN"/>
<!-- 权限字段 -->
<result 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
role_id, permission_id,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 批量插入系统角色权限关系(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertRolePermissionBatch" parameterType="java.util.List">
INSERT INTO sys.tb_sys_role_permission
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段role_id, permission_id, optsn -->
role_id,
permission_id,
optsn,
<!-- 可选字段:统一列定义,值侧按 item 是否有值动态拼接 -->
<if test="list[0].creator != null">creator,</if>
<if test="list[0].deptPath != null">dept_path,</if>
<if test="list[0].remark != null">remark,</if>
<if test="list[0].createTime != null">create_time,</if>
<if test="list[0].updateTime != null">update_time,</if>
<if test="list[0].deleteTime != null">delete_time,</if>
<if test="list[0].deleted != null">deleted</if>
</trim>
VALUES
<foreach collection="list" item="item" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段值 -->
#{item.roleId},
#{item.permissionId},
#{item.optsn},
<!-- 可选字段值:允许为 null走数据库默认值或 NULL -->
<if test="item.creator != null">#{item.creator},</if>
<if test="item.deptPath != null">#{item.deptPath},</if>
<if test="item.remark != null">#{item.remark},</if>
<if test="item.createTime != null">#{item.createTime},</if>
<if test="item.updateTime != null">#{item.updateTime},</if>
<if test="item.deleteTime != null">#{item.deleteTime},</if>
<if test="item.deleted != null">#{item.deleted}</if>
</trim>
</foreach>
</insert>
<!-- 插入系统角色权限关系 -->
<insert id="insertRolePermission" parameterType="org.xyzh.common.dto.sys.TbSysRolePermissionDTO">
INSERT INTO sys.tb_sys_role_permission (
role_id, permission_id,
optsn, creator, dept_path, remark, create_time
) VALUES (
#{roleId}, #{permissionId},
#{optsn}, #{creator}, #{deptPath}, #{remark}, #{createTime}
)
</insert>
<!-- 更新系统角色权限关系 -->
<update id="updateRolePermission" parameterType="org.xyzh.common.dto.sys.TbSysRolePermissionDTO">
UPDATE sys.tb_sys_role_permission
<set>
<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 role_id = #{roleId} AND permission_id = #{permissionId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统角色权限关系 -->
<update id="deleteRolePermission" parameterType="org.xyzh.common.dto.sys.TbSysRolePermissionDTO">
UPDATE sys.tb_sys_role_permission
SET deleted = true,
delete_time = NOW()
WHERE role_id = #{roleId} AND permission_id = #{permissionId}
</update>
<!-- 根据角色ID查询系统角色权限关系 -->
<select id="getRolePermissionByRoleId" resultMap="PermissionVOResultMap" parameterType="java.lang.String">
SELECT
rp.role_id, rp.permission_id,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope AS role_scope, r.owner_dept_id AS role_owner_dept_id, r.status AS role_status,
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,
rp.optsn, rp.creator, rp.updater, rp.dept_path, rp.remark, rp.create_time, rp.update_time, rp.delete_time, rp.deleted
FROM sys.tb_sys_role_permission rp
LEFT JOIN sys.tb_sys_role r ON rp.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
LEFT JOIN sys.tb_sys_permission p ON rp.permission_id = p.permission_id AND (p.deleted IS NULL OR p.deleted = false)
LEFT JOIN sys.tb_sys_module m ON p.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
WHERE rp.role_id = #{roleId}
AND (rp.deleted IS NULL OR rp.deleted = false)
ORDER BY rp.create_time DESC
</select>
<!-- 根据条件查询系统角色权限关系列表 -->
<select id="getRolePermissionByFilter" resultMap="PermissionVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysRolePermissionDTO">
SELECT
rp.role_id, rp.permission_id,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope AS role_scope, r.owner_dept_id AS role_owner_dept_id, r.status AS role_status,
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,
rp.optsn, rp.creator, rp.updater, rp.dept_path, rp.remark, rp.create_time, rp.update_time, rp.delete_time, rp.deleted
FROM sys.tb_sys_role_permission rp
LEFT JOIN sys.tb_sys_role r ON rp.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
LEFT JOIN sys.tb_sys_permission p ON rp.permission_id = p.permission_id AND (p.deleted IS NULL OR p.deleted = false)
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.roleId != null and filter.roleId != ''">
AND rp.role_id = #{filter.roleId}
</if>
<if test="filter.permissionId != null and filter.permissionId != ''">
AND rp.permission_id = #{filter.permissionId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND rp.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (rp.deleted IS NULL OR rp.deleted = false)
</where>
ORDER BY rp.create_time DESC
</select>
<!-- 根据条件查询系统角色权限关系分页列表 -->
<select id="getRolePermissionPageByFilter" resultMap="PermissionVOResultMap">
SELECT
rp.role_id, rp.permission_id,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope AS role_scope, r.owner_dept_id AS role_owner_dept_id, r.status AS role_status,
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,
rp.optsn, rp.creator, rp.updater, rp.dept_path, rp.remark, rp.create_time, rp.update_time, rp.delete_time, rp.deleted
FROM sys.tb_sys_role_permission rp
LEFT JOIN sys.tb_sys_role r ON rp.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
LEFT JOIN sys.tb_sys_permission p ON rp.permission_id = p.permission_id AND (p.deleted IS NULL OR p.deleted = false)
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.roleId != null and filter.roleId != ''">
AND rp.role_id = #{filter.roleId}
</if>
<if test="filter.permissionId != null and filter.permissionId != ''">
AND rp.permission_id = #{filter.permissionId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND rp.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (rp.deleted IS NULL OR rp.deleted = false)
</where>
ORDER BY rp.create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统角色权限关系数量 -->
<select id="getRolePermissionCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysRolePermissionDTO">
SELECT COUNT(1)
FROM sys.tb_sys_role_permission
<where>
<if test="filter.roleId != null and filter.roleId != ''">
AND role_id = #{filter.roleId}
</if>
<if test="filter.permissionId != null and filter.permissionId != ''">
AND permission_id = #{filter.permissionId}
</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>
<!-- getPermissionsByUserId -->
<select id="getPermissionsByUserId" resultMap="PermissionVOResultMap">
SELECT p.permission_id AS permissionId,
p.name AS permissionName,
p.code AS permissionCode,
p.description AS permissionDescription,
p.dept_path AS deptPath,
p.deleted AS deleted,
p.module_id AS moduleId
FROM sys.tb_sys_user_role ur
JOIN sys.tb_sys_role_permission rp ON ur.role_id = rp.role_id
JOIN sys.tb_sys_permission p ON rp.permission_id = p.permission_id
WHERE ur.user_id = #{userId}
AND (p.deleted IS NULL OR p.deleted = false)
AND (rp.deleted IS NULL OR rp.deleted = false)
</select>
</mapper>

View File

@@ -0,0 +1,237 @@
<?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.user.TbSysUserInfoMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysUserInfoDTO">
<!-- 用户信息字段 -->
<id column="user_id" property="userId" jdbcType="VARCHAR"/>
<result column="avatar" property="avatar" jdbcType="VARCHAR"/>
<result column="gender" property="gender" jdbcType="INTEGER"/>
<result column="family_name" property="familyName" jdbcType="VARCHAR"/>
<result column="given_name" property="givenName" jdbcType="VARCHAR"/>
<result column="full_name" property="fullName" jdbcType="VARCHAR"/>
<result column="level" property="level" jdbcType="INTEGER"/>
<result column="id_card" property="idCard" jdbcType="VARCHAR"/>
<result column="address" property="address" 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
user_id, avatar, gender, family_name, given_name, full_name, level, id_card, address,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统用户信息(按表字段 + 默认值动态列,仅修改 insert -->
<insert id="insertUserInfo" parameterType="org.xyzh.common.dto.sys.TbSysUserInfoDTO">
INSERT INTO sys.tb_sys_user_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段NOT NULL 且无默认值optsn, user_id -->
optsn,
user_id,
<!-- 可空/有默认值字段:按是否有入参动态拼接 -->
<if test="avatar != null and avatar != ''">avatar,</if>
<if test="gender != null">gender,</if>
<if test="familyName != null and familyName != ''">family_name,</if>
<if test="givenName != null and givenName != ''">given_name,</if>
<if test="fullName != null and fullName != ''">full_name,</if>
<if test="level != null">level,</if>
<if test="idCard != null and idCard != ''">id_card,</if>
<if test="address != null and address != ''">address,</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=",">
<!-- 必填字段对应的值 -->
#{optsn},
#{userId},
<!-- 可空/有默认值字段对应的值 -->
<if test="avatar != null and avatar != ''">#{avatar},</if>
<if test="gender != null">#{gender},</if>
<if test="familyName != null and familyName != ''">#{familyName},</if>
<if test="givenName != null and givenName != ''">#{givenName},</if>
<if test="fullName != null and fullName != ''">#{fullName},</if>
<if test="level != null">#{level},</if>
<if test="idCard != null and idCard != ''">#{idCard},</if>
<if test="address != null and address != ''">#{address},</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="updateUserInfo" parameterType="org.xyzh.common.dto.sys.TbSysUserInfoDTO">
UPDATE sys.tb_sys_user_info
<set>
<if test="avatar != null">
avatar = #{avatar},
</if>
<if test="gender != null">
gender = #{gender},
</if>
<if test="familyName != null">
family_name = #{familyName},
</if>
<if test="givenName != null">
given_name = #{givenName},
</if>
<if test="fullName != null">
full_name = #{fullName},
</if>
<if test="level != null">
level = #{level},
</if>
<if test="idCard != null">
id_card = #{idCard},
</if>
<if test="address != null">
address = #{address},
</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 user_id = #{userId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统用户信息 -->
<update id="deleteUserInfo" parameterType="org.xyzh.common.dto.sys.TbSysUserInfoDTO">
UPDATE sys.tb_sys_user_info
SET deleted = true,
delete_time = NOW()
WHERE user_id = #{userId}
</update>
<!-- 根据用户ID查询系统用户信息 -->
<select id="getUserInfoById" resultMap="BaseResultMap" parameterType="java.lang.String">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_user_info
WHERE user_id = #{userId}
AND (deleted IS NULL OR deleted = false)
</select>
<!-- 根据条件查询系统用户信息列表 -->
<select id="getUserInfoByFilter" resultMap="BaseResultMap" parameterType="org.xyzh.common.dto.sys.TbSysUserInfoDTO">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_user_info
<where>
<if test="filter.userId != null and filter.userId != ''">
AND user_id = #{filter.userId}
</if>
<if test="filter.fullName != null and filter.fullName != ''">
AND full_name LIKE CONCAT('%', #{filter.fullName}, '%')
</if>
<if test="filter.familyName != null and filter.familyName != ''">
AND family_name LIKE CONCAT('%', #{filter.familyName}, '%')
</if>
<if test="filter.givenName != null and filter.givenName != ''">
AND given_name LIKE CONCAT('%', #{filter.givenName}, '%')
</if>
<if test="filter.idCard != null and filter.idCard != ''">
AND id_card = #{filter.idCard}
</if>
<if test="filter.gender != null">
AND gender = #{filter.gender}
</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>
ORDER BY create_time DESC
</select>
<!-- 根据条件查询系统用户信息分页列表 -->
<select id="getUserInfoPageByFilter" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_user_info
<where>
<if test="filter.userId != null and filter.userId != ''">
AND user_id = #{filter.userId}
</if>
<if test="filter.fullName != null and filter.fullName != ''">
AND full_name LIKE CONCAT('%', #{filter.fullName}, '%')
</if>
<if test="filter.familyName != null and filter.familyName != ''">
AND family_name LIKE CONCAT('%', #{filter.familyName}, '%')
</if>
<if test="filter.givenName != null and filter.givenName != ''">
AND given_name LIKE CONCAT('%', #{filter.givenName}, '%')
</if>
<if test="filter.idCard != null and filter.idCard != ''">
AND id_card = #{filter.idCard}
</if>
<if test="filter.gender != null">
AND gender = #{filter.gender}
</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>
ORDER BY create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统用户信息数量 -->
<select id="getUserInfoCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysUserInfoDTO">
SELECT COUNT(1)
FROM sys.tb_sys_user_info
<where>
<if test="filter.userId != null and filter.userId != ''">
AND user_id = #{filter.userId}
</if>
<if test="filter.fullName != null and filter.fullName != ''">
AND full_name LIKE CONCAT('%', #{filter.fullName}, '%')
</if>
<if test="filter.familyName != null and filter.familyName != ''">
AND family_name LIKE CONCAT('%', #{filter.familyName}, '%')
</if>
<if test="filter.givenName != null and filter.givenName != ''">
AND given_name LIKE CONCAT('%', #{filter.givenName}, '%')
</if>
<if test="filter.idCard != null and filter.idCard != ''">
AND id_card = #{filter.idCard}
</if>
<if test="filter.gender != null">
AND gender = #{filter.gender}
</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>

View File

@@ -0,0 +1,240 @@
<?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.user.TbSysUserMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysUserDTO">
<!-- 用户表字段(按 createTableUser.sql -->
<id column="user_id" property="userId" jdbcType="VARCHAR"/>
<result column="password" property="password" jdbcType="VARCHAR"/>
<result column="email" property="email" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="wechat_id" property="wechatId" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<!-- BaseDTO 中在该表实际存在的字段 -->
<result column="optsn" property="optsn" 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="UserVOResultMap" type="org.xyzh.api.system.vo.SysUserVO">
<!-- 用户字段(按表结构对齐) -->
<id column="user_id" property="userId" jdbcType="VARCHAR"/>
<result column="password" property="password" jdbcType="VARCHAR"/>
<result column="email" property="email" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="wechat_id" property="wechatId" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<!-- 用户信息关联字段 -->
<result column="avatar" property="avatar" jdbcType="VARCHAR"/>
<result column="gender" property="gender" jdbcType="INTEGER"/>
<result column="family_name" property="familyName" jdbcType="VARCHAR"/>
<result column="given_name" property="givenName" jdbcType="VARCHAR"/>
<result column="full_name" property="fullName" jdbcType="VARCHAR"/>
<result column="level" property="level" jdbcType="INTEGER"/>
<result column="id_card" property="idCard" jdbcType="VARCHAR"/>
<result column="address" property="address" jdbcType="VARCHAR"/>
<!-- BaseVO 中在该表实际存在的字段 -->
<result column="optsn" property="optsn" 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列(完全按表结构) -->
<sql id="Base_Column_List">
user_id, password, email, phone, wechat_id, status,
optsn, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入用户(按表字段 + 默认值动态列) -->
<insert id="insertUser" parameterType="org.xyzh.common.dto.sys.TbSysUserDTO">
INSERT INTO sys.tb_sys_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段NOT NULL 且无默认值optsn, user_id, password -->
optsn,
user_id,
password,
<!-- 可空/有默认值字段:按是否有入参动态拼接 -->
<if test="email != null and email != ''">email,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="wechatId != null and wechatId != ''">wechat_id,</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>
<if test="status != null">status,</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段对应的值 -->
#{optsn},
#{userId},
#{password},
<!-- 可空/有默认值字段对应的值 -->
<if test="email != null and email != ''">#{email},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="wechatId != null and wechatId != ''">#{wechatId},</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>
<if test="status != null">#{status},</if>
</trim>
</insert>
<!-- 更新用户 -->
<update id="updateUser" parameterType="org.xyzh.common.dto.sys.TbSysUserDTO">
UPDATE sys.tb_sys_user
<set>
<if test="username != null and username != ''">
username = #{username},
</if>
<if test="password != null and password != ''">
password = #{password},
</if>
<if test="email != null and email != ''">
email = #{email},
</if>
<if test="phone != null and phone != ''">
phone = #{phone},
</if>
<if test="wechatId != null and wechatId != ''">
wechat_id = #{wechatId},
</if>
<if test="status != null and status != ''">
status = #{status},
</if>
<if test="userType != null and userType != ''">
user_type = #{userType},
</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 user_id = #{userId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除用户(逻辑删除) -->
<update id="deleteUser" parameterType="org.xyzh.common.dto.sys.TbSysUserDTO">
UPDATE sys.tb_sys_user
SET deleted = true,
delete_time = NOW()
WHERE user_id = #{userId}
</update>
<!-- 根据ID查询用户 -->
<select id="getUserById" resultMap="UserVOResultMap" parameterType="java.lang.String">
SELECT
u.user_id, u.password, u.email, u.phone, u.wechat_id, u.status,
u.optsn, u.create_time, u.update_time, u.delete_time, u.deleted,
ui.avatar, ui.gender, ui.family_name, ui.given_name, ui.full_name, ui.level, ui.id_card, ui.address
FROM sys.tb_sys_user u
LEFT JOIN sys.tb_sys_user_info ui ON u.user_id = ui.user_id AND (ui.deleted IS NULL OR ui.deleted = false)
WHERE u.user_id = #{userId}
AND (u.deleted IS NULL OR u.deleted = false)
</select>
<!-- 根据条件查询用户列表 -->
<select id="getUserByFilter" resultMap="UserVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysUserDTO">
SELECT
u.user_id, u.username, u.password, u.email, u.phone, u.wechat_id, u.status, u.user_type,
u.optsn, u.creator, u.updater, u.dept_path, u.remark, u.create_time, u.update_time, u.delete_time, u.deleted,
ui.avatar, ui.gender, ui.family_name, ui.given_name, ui.full_name, ui.level, ui.id_card, ui.address
FROM sys.tb_sys_user u
LEFT JOIN sys.tb_sys_user_info ui ON u.user_id = ui.user_id AND (ui.deleted IS NULL OR ui.deleted = false)
<where>
<if test="filter.userId != null and filter.userId != ''">
AND u.user_id = #{filter.userId}
</if>
<if test="filter.email != null and filter.email != ''">
AND u.email = #{filter.email}
</if>
<if test="filter.phone != null and filter.phone != ''">
AND u.phone = #{filter.phone}
</if>
<if test="filter.status != null and filter.status != ''">
AND u.status = #{filter.status}
</if>
<!-- username / userType / deptPath 在表中不存在,按 SQL 为准移除相关条件 -->
AND (u.deleted IS NULL OR u.deleted = false)
</where>
ORDER BY u.create_time DESC
</select>
<!-- 根据条件查询用户分页列表 -->
<select id="getUserPageByFilter" resultMap="UserVOResultMap">
SELECT
u.user_id, u.username, u.password, u.email, u.phone, u.wechat_id, u.status, u.user_type,
u.optsn, u.creator, u.updater, u.dept_path, u.remark, u.create_time, u.update_time, u.delete_time, u.deleted,
ui.avatar, ui.gender, ui.family_name, ui.given_name, ui.full_name, ui.level, ui.id_card, ui.address
FROM sys.tb_sys_user u
LEFT JOIN sys.tb_sys_user_info ui ON u.user_id = ui.user_id AND (ui.deleted IS NULL OR ui.deleted = false)
<where>
<if test="filter.userId != null and filter.userId != ''">
AND u.user_id = #{filter.userId}
</if>
<if test="filter.username != null and filter.username != ''">
AND u.username LIKE CONCAT('%', #{filter.username}, '%')
</if>
<if test="filter.email != null and filter.email != ''">
AND u.email = #{filter.email}
</if>
<if test="filter.phone != null and filter.phone != ''">
AND u.phone = #{filter.phone}
</if>
<if test="filter.status != null and filter.status != ''">
AND u.status = #{filter.status}
</if>
<if test="filter.userType != null and filter.userType != ''">
AND u.user_type = #{filter.userType}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND u.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (u.deleted IS NULL OR u.deleted = false)
</where>
ORDER BY u.create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询用户数量 -->
<select id="getUserCountByFilter" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysUserDTO">
SELECT COUNT(1)
FROM sys.tb_sys_user
<where>
<if test="filter.userId != null and filter.userId != ''">
AND user_id = #{filter.userId}
</if>
<if test="filter.email != null and filter.email != ''">
AND email = #{filter.email}
</if>
<if test="filter.phone != null and filter.phone != ''">
AND phone = #{filter.phone}
</if>
<if test="filter.status != null">
AND status = #{filter.status}
</if>
AND (deleted IS NULL OR deleted = false)
</where>
</select>
</mapper>

View File

@@ -0,0 +1,247 @@
<?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.user.TbSysUserRoleMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysUserRoleDTO">
<!-- 用户角色关系字段 -->
<id column="user_id" property="userId" jdbcType="VARCHAR"/>
<id column="role_id" property="roleId" 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- VO结果映射用于前端展示 -->
<resultMap id="UserDeptRoleVOResultMap" type="org.xyzh.api.system.vo.UserDeptRoleVO">
<!-- 用户字段 -->
<id column="user_id" property="userId" jdbcType="VARCHAR"/>
<result column="username" property="username" jdbcType="VARCHAR"/>
<result column="password" property="password" jdbcType="VARCHAR"/>
<result column="email" property="email" jdbcType="VARCHAR"/>
<result column="phone" property="phone" jdbcType="VARCHAR"/>
<result column="wechat_id" property="wechatId" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="VARCHAR"/>
<result column="user_type" property="userType" jdbcType="VARCHAR"/>
<!-- 用户信息字段 -->
<result column="avatar" property="avatar" jdbcType="VARCHAR"/>
<result column="gender" property="gender" jdbcType="INTEGER"/>
<result column="family_name" property="familyName" jdbcType="VARCHAR"/>
<result column="given_name" property="givenName" jdbcType="VARCHAR"/>
<result column="full_name" property="fullName" jdbcType="VARCHAR"/>
<result column="level" property="level" jdbcType="INTEGER"/>
<result column="id_card" property="idCard" jdbcType="VARCHAR"/>
<result column="address" property="address" jdbcType="VARCHAR"/>
<!-- 部门字段 -->
<result column="dept_id" property="deptId" jdbcType="VARCHAR"/>
<result column="dept_name" property="deptName" jdbcType="VARCHAR"/>
<result column="parent_id" property="parentId" jdbcType="VARCHAR"/>
<result column="dept_description" property="deptDescription" 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="scope" property="scope" jdbcType="VARCHAR"/>
<result column="owner_dept_id" property="ownerDeptId" jdbcType="VARCHAR"/>
<result column="role_status" property="roleStatus" jdbcType="BOOLEAN"/>
<!-- 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
user_id, role_id,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统用户角色关系(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertUserRole" parameterType="org.xyzh.common.dto.sys.TbSysUserRoleDTO">
INSERT INTO sys.tb_sys_user_role
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段user_id, role_id, optsn -->
user_id,
role_id,
optsn,
<!-- 可选字段:基础字段按是否有值动态拼接 -->
<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=",">
<!-- 必填字段值 -->
#{userId},
#{roleId},
#{optsn},
<!-- 可选字段值 -->
<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="updateUserRole" parameterType="org.xyzh.common.dto.sys.TbSysUserRoleDTO">
UPDATE sys.tb_sys_user_role
<set>
<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 user_id = #{userId} AND role_id = #{roleId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统用户角色关系 -->
<update id="deleteUserRole" parameterType="org.xyzh.common.dto.sys.TbSysUserRoleDTO">
UPDATE sys.tb_sys_user_role
SET deleted = true,
delete_time = NOW()
WHERE user_id = #{userId} AND role_id = #{roleId}
</update>
<!-- 根据用户ID查询系统用户角色关系 -->
<select id="getUserRoleByUserId" resultMap="UserDeptRoleVOResultMap" parameterType="java.lang.String">
SELECT
u.user_id, u.username, u.password, u.email, u.phone, u.wechat_id, u.status, u.user_type,
ui.avatar, ui.gender, ui.family_name, ui.given_name, ui.full_name, ui.level, ui.id_card, ui.address,
d.dept_id, d.name AS dept_name, d.parent_id, d.description AS dept_description,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope, r.owner_dept_id, r.status AS role_status,
ur.optsn, ur.creator, ur.updater, ur.dept_path, ur.remark, ur.create_time, ur.update_time, ur.delete_time, ur.deleted
FROM sys.tb_sys_user_role ur
LEFT JOIN sys.tb_sys_user u ON ur.user_id = u.user_id AND (u.deleted IS NULL OR u.deleted = false)
LEFT JOIN sys.tb_sys_user_info ui ON u.user_id = ui.user_id AND (ui.deleted IS NULL OR ui.deleted = false)
LEFT JOIN sys.tb_sys_dept d ON u.dept_path LIKE CONCAT('%/', d.dept_id, '/%') AND (d.deleted IS NULL OR d.deleted = false)
LEFT JOIN sys.tb_sys_role r ON ur.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
WHERE ur.user_id = #{userId}
AND (ur.deleted IS NULL OR ur.deleted = false)
ORDER BY ur.create_time DESC
</select>
<!-- 根据条件查询系统用户角色关系列表 -->
<select id="getUserRoleByFilter" resultMap="UserDeptRoleVOResultMap" parameterType="org.xyzh.common.dto.sys.TbSysUserRoleDTO">
SELECT DISTINCT
u.user_id, u.username, u.password, u.email, u.phone, u.wechat_id, u.status, u.user_type,
ui.avatar, ui.gender, ui.family_name, ui.given_name, ui.full_name, ui.level, ui.id_card, ui.address,
d.dept_id, d.name AS dept_name, d.parent_id, d.description AS dept_description,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope, r.owner_dept_id, r.status AS role_status,
ur.optsn, ur.creator, ur.updater, ur.dept_path, ur.remark, ur.create_time, ur.update_time, ur.delete_time, ur.deleted
FROM sys.tb_sys_user_role ur
LEFT JOIN sys.tb_sys_user u ON ur.user_id = u.user_id AND (u.deleted IS NULL OR u.deleted = false)
LEFT JOIN sys.tb_sys_user_info ui ON u.user_id = ui.user_id AND (ui.deleted IS NULL OR ui.deleted = false)
LEFT JOIN sys.tb_sys_dept d ON u.dept_path LIKE CONCAT('%/', d.dept_id, '/%') AND (d.deleted IS NULL OR d.deleted = false)
LEFT JOIN sys.tb_sys_role r ON ur.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
<where>
<if test="filter.userId != null and filter.userId != ''">
AND ur.user_id = #{filter.userId}
</if>
<if test="filter.roleId != null and filter.roleId != ''">
AND ur.role_id = #{filter.roleId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND ur.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (ur.deleted IS NULL OR ur.deleted = false)
</where>
ORDER BY ur.create_time DESC
</select>
<!-- 根据条件查询系统用户角色关系分页列表 -->
<select id="getUserRolePageByFilter" resultMap="UserDeptRoleVOResultMap">
SELECT DISTINCT
u.user_id, u.username, u.password, u.email, u.phone, u.wechat_id, u.status, u.user_type,
ui.avatar, ui.gender, ui.family_name, ui.given_name, ui.full_name, ui.level, ui.id_card, ui.address,
d.dept_id, d.name AS dept_name, d.parent_id, d.description AS dept_description,
r.role_id, r.name AS role_name, r.description AS role_description, r.scope, r.owner_dept_id, r.status AS role_status,
(SELECT m.module_id FROM sys.tb_sys_role_permission rp2
LEFT JOIN sys.tb_sys_permission p2 ON rp2.permission_id = p2.permission_id AND (p2.deleted IS NULL OR p2.deleted = false)
LEFT JOIN sys.tb_sys_module m ON p2.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
WHERE rp2.role_id = r.role_id AND (rp2.deleted IS NULL OR rp2.deleted = false)
ORDER BY rp2.create_time ASC LIMIT 1) AS module_id,
(SELECT m.name FROM sys.tb_sys_role_permission rp2
LEFT JOIN sys.tb_sys_permission p2 ON rp2.permission_id = p2.permission_id AND (p2.deleted IS NULL OR p2.deleted = false)
LEFT JOIN sys.tb_sys_module m ON p2.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
WHERE rp2.role_id = r.role_id AND (rp2.deleted IS NULL OR rp2.deleted = false)
ORDER BY rp2.create_time ASC LIMIT 1) AS module_name,
(SELECT m.description FROM sys.tb_sys_role_permission rp2
LEFT JOIN sys.tb_sys_permission p2 ON rp2.permission_id = p2.permission_id AND (p2.deleted IS NULL OR p2.deleted = false)
LEFT JOIN sys.tb_sys_module m ON p2.module_id = m.module_id AND (m.deleted IS NULL OR m.deleted = false)
WHERE rp2.role_id = r.role_id AND (rp2.deleted IS NULL OR rp2.deleted = false)
ORDER BY rp2.create_time ASC LIMIT 1) AS module_description,
ur.optsn, ur.creator, ur.updater, ur.dept_path, ur.remark, ur.create_time, ur.update_time, ur.delete_time, ur.deleted
FROM sys.tb_sys_user_role ur
LEFT JOIN sys.tb_sys_user u ON ur.user_id = u.user_id AND (u.deleted IS NULL OR u.deleted = false)
LEFT JOIN sys.tb_sys_user_info ui ON u.user_id = ui.user_id AND (ui.deleted IS NULL OR ui.deleted = false)
LEFT JOIN sys.tb_sys_dept d ON u.dept_path LIKE CONCAT('%/', d.dept_id, '/%') AND (d.deleted IS NULL OR d.deleted = false)
LEFT JOIN sys.tb_sys_role r ON ur.role_id = r.role_id AND (r.deleted IS NULL OR r.deleted = false)
<where>
<if test="filter.userId != null and filter.userId != ''">
AND ur.user_id = #{filter.userId}
</if>
<if test="filter.roleId != null and filter.roleId != ''">
AND ur.role_id = #{filter.roleId}
</if>
<if test="filter.deptPath != null and filter.deptPath != ''">
AND ur.dept_path LIKE CONCAT(#{filter.deptPath}, '%')
</if>
AND (ur.deleted IS NULL OR ur.deleted = false)
</where>
ORDER BY ur.create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统用户角色关系数量 -->
<select id="getUserRoleCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysUserRoleDTO">
SELECT COUNT(1)
FROM sys.tb_sys_user_role
<where>
<if test="filter.userId != null and filter.userId != ''">
AND user_id = #{filter.userId}
</if>
<if test="filter.roleId != null and filter.roleId != ''">
AND role_id = #{filter.roleId}
</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>

View File

@@ -0,0 +1,231 @@
<?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.view.TbSysViewMapper">
<!-- 结果映射 -->
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.sys.TbSysViewDTO">
<!-- 视图字段 -->
<id column="view_id" property="viewId" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="parent_id" property="parentId" jdbcType="VARCHAR"/>
<result column="url" property="url" jdbcType="VARCHAR"/>
<result column="component" property="component" jdbcType="VARCHAR"/>
<result column="icon" property="icon" jdbcType="VARCHAR"/>
<result column="type" property="type" jdbcType="INTEGER"/>
<result column="layout" property="layout" jdbcType="VARCHAR"/>
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
<result column="description" property="description" 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"/>
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
</resultMap>
<!-- 基础列 -->
<sql id="Base_Column_List">
view_id, name, parent_id, url, component, icon, type, layout, order_num, description,
optsn, creator, updater, dept_path, remark, create_time, update_time, delete_time, deleted
</sql>
<!-- 插入系统视图(必填 + 可选字段动态列,仅修改 insert -->
<insert id="insertView" parameterType="org.xyzh.common.dto.sys.TbSysViewDTO">
INSERT INTO sys.tb_sys_view
<trim prefix="(" suffix=")" suffixOverrides=",">
<!-- 必填字段view_id, name, type, layout, order_num, optsn -->
view_id,
name,
type,
layout,
order_num,
optsn,
<!-- 可选字段parent_id, url, component, icon, description 及基础字段 -->
<if test="parentId != null and parentId != ''">parent_id,</if>
<if test="url != null and url != ''">url,</if>
<if test="component != null and component != ''">component,</if>
<if test="icon != null and icon != ''">icon,</if>
<if test="description != null and description != ''">description,</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=",">
<!-- 必填字段对应的值 -->
#{viewId},
#{name},
#{type},
#{layout},
#{orderNum},
#{optsn},
<!-- 可选字段对应的值 -->
<if test="parentId != null and parentId != ''">#{parentId},</if>
<if test="url != null and url != ''">#{url},</if>
<if test="component != null and component != ''">#{component},</if>
<if test="icon != null and icon != ''">#{icon},</if>
<if test="description != null and description != ''">#{description},</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="updateView" parameterType="org.xyzh.common.dto.sys.TbSysViewDTO">
UPDATE sys.tb_sys_view
<set>
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="parentId != null">
parent_id = #{parentId},
</if>
<if test="url != null">
url = #{url},
</if>
<if test="component != null">
component = #{component},
</if>
<if test="icon != null">
icon = #{icon},
</if>
<if test="type != null">
type = #{type},
</if>
<if test="layout != null">
layout = #{layout},
</if>
<if test="orderNum != null">
order_num = #{orderNum},
</if>
<if test="description != null">
description = #{description},
</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 view_id = #{viewId}
<if test="deleted != null">
AND deleted = #{deleted}
</if>
</update>
<!-- 删除系统视图 -->
<update id="deleteView" parameterType="org.xyzh.common.dto.sys.TbSysViewDTO">
UPDATE sys.tb_sys_view
SET deleted = true,
delete_time = NOW()
WHERE view_id = #{viewId}
</update>
<!-- 根据ID查询系统视图 -->
<select id="getViewById" resultMap="BaseResultMap" parameterType="java.lang.String">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_view
WHERE view_id = #{viewId}
AND (deleted IS NULL OR deleted = false)
</select>
<!-- 根据条件查询系统视图列表 -->
<select id="getViewByFilter" resultMap="BaseResultMap" parameterType="org.xyzh.common.dto.sys.TbSysViewDTO">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_view
<where>
<if test="filter.viewId != null and filter.viewId != ''">
AND view_id = #{filter.viewId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.parentId != null and filter.parentId != ''">
AND parent_id = #{filter.parentId}
</if>
<if test="filter.type != null">
AND type = #{filter.type}
</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>
ORDER BY order_num ASC, create_time DESC
</select>
<!-- 根据条件查询系统视图分页列表 -->
<select id="getViewPageByFilter" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM sys.tb_sys_view
<where>
<if test="filter.viewId != null and filter.viewId != ''">
AND view_id = #{filter.viewId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.parentId != null and filter.parentId != ''">
AND parent_id = #{filter.parentId}
</if>
<if test="filter.type != null">
AND type = #{filter.type}
</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>
ORDER BY order_num ASC, create_time DESC
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.offset}
</select>
<!-- 根据条件查询系统视图数量 -->
<select id="getViewCount" resultType="java.lang.Integer" parameterType="org.xyzh.common.dto.sys.TbSysViewDTO">
SELECT COUNT(1)
FROM sys.tb_sys_view
<where>
<if test="filter.viewId != null and filter.viewId != ''">
AND view_id = #{filter.viewId}
</if>
<if test="filter.name != null and filter.name != ''">
AND name LIKE CONCAT('%', #{filter.name}, '%')
</if>
<if test="filter.parentId != null and filter.parentId != ''">
AND parent_id = #{filter.parentId}
</if>
<if test="filter.type != null">
AND type = #{filter.type}
</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>