temp
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user