wlcb-smart-city-usercenter/src/main/resources/mybatis/mapper/user-expand/user-expand-mapper.xml

371 lines
13 KiB
XML
Raw Normal View History

2021-11-12 17:03:53 +08:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.tenlion.usercenter.dao.userexpand.IUserExpandDao">
<resultMap id="userExpandPO" type="cn.com.tenlion.usercenter.pojo.pos.userexpand.UserExpandPO">
<result column="user_id" property="userId"/>
<result column="area_code" property="areaCode"/>
<result column="area_name" property="areaName"/>
<result column="user_level" property="userLevel"/>
2022-01-22 20:37:54 +08:00
<result column="user_sex" property="userSex"/>
<result column="user_sex_name" property="userSexName"/>
<result column="user_birth" property="userBirth"/>
<result column="user_education" property="userEducation"/>
<result column="user_education_name" property="userEducationName"/>
<result column="user_politic" property="userPolitic"/>
<result column="user_politic_name" property="userPoliticName"/>
2022-02-27 02:36:20 +08:00
<result column="smc_state" property="smcState"/>
<result column="smc_meeting" property="smcMeetingId"/>
<result column="smc_username" property="smcUsername"/>
<result column="smc_password" property="smcPassword"/>
<result column="smc_number" property="smcNumber"/>
2021-11-12 17:03:53 +08:00
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
</resultMap>
<resultMap id="userExpandDTO" type="cn.com.tenlion.usercenter.pojo.dtos.userexpand.UserExpandDTO">
<result column="user_id" property="userId"/>
<result column="area_code" property="areaCode"/>
<result column="area_name" property="areaName"/>
<result column="user_level" property="userLevel"/>
2022-01-22 20:37:54 +08:00
<result column="user_sex" property="userSex"/>
<result column="user_sex_name" property="userSexName"/>
<result column="user_birth" property="userBirth"/>
<result column="user_education" property="userEducation"/>
<result column="user_education_name" property="userEducationName"/>
<result column="user_politic" property="userPolitic"/>
<result column="user_politic_name" property="userPoliticName"/>
2022-02-27 02:36:20 +08:00
<result column="smc_state" property="smcState"/>
<result column="smc_meeting_id" property="smcMeetingId"/>
<result column="smc_username" property="smcUsername"/>
<result column="smc_password" property="smcPassword"/>
<result column="smc_number" property="smcNumber"/>
2021-11-12 17:03:53 +08:00
<result column="gmt_create" property="gmtCreate"/>
</resultMap>
<!-- 建表 -->
<update id="createTable">
CREATE TABLE IF NOT EXISTS `sys_user_expand` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_id` char(36) DEFAULT NULL COMMENT '主键',
2022-01-22 20:37:54 +08:00
`area_code` varchar(255) DEFAULT NULL COMMENT '名称',
`area_name` varchar(255) DEFAULT NULL COMMENT '描述',
`user_level` int(2) DEFAULT '1' COMMENT '用户级别',
2022-01-23 12:16:28 +08:00
`user_sex` char(36) DEFAULT NULL COMMENT '性别',
2022-01-22 20:37:54 +08:00
`user_sex_name` varchar(255) DEFAULT NULL COMMENT '性别',
`user_birth` varchar(255) DEFAULT NULL COMMENT '出生年月',
2022-01-23 12:16:28 +08:00
`user_politic` char(36) DEFAULT NULL COMMENT '政治面貌',
2022-01-22 20:37:54 +08:00
`user_politic_name` varchar(255) DEFAULT NULL COMMENT '政治面貌',
2022-01-23 12:16:28 +08:00
`user_education` char(36) DEFAULT NULL COMMENT '学历',
2022-02-27 02:36:20 +08:00
`smc_state` varchar(255) DEFAULT NULL COMMENT '融合通信状态',
`smc_meeting_id` varchar(255) DEFAULT NULL COMMENT '融合通信会议室ID',
`smc_username` varchar(255) DEFAULT NULL COMMENT '融合通信账号',
`smc_password` varchar(255) DEFAULT NULL COMMENT '融合通信密码',
`smc_number` varchar(255) DEFAULT NULL COMMENT '融合通信会议室号码',
2021-11-12 17:03:53 +08:00
`creator` char(36) DEFAULT NULL COMMENT '创建人',
`gmt_create` datetime DEFAULT NULL COMMENT '创建时间',
`modifier` char(36) DEFAULT NULL COMMENT '修改人',
`gmt_modified` datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`id`),
UNIQUE KEY `user_id` (`user_id`)
2022-01-22 20:37:54 +08:00
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='用户拓展属性';
2021-11-12 17:03:53 +08:00
</update>
<!-- 新增 -->
<insert id="save" parameterType="map">
INSERT INTO sys_user_expand(
user_id,
area_code,
area_name,
user_level,
2022-01-22 20:37:54 +08:00
user_sex,
user_sex_name,
user_birth,
user_education,
user_education_name,
user_politic,
user_politic_name,
2022-02-27 02:36:20 +08:00
smc_state,
smc_meeting_id,
smc_username,
smc_password,
smc_number,
2021-11-12 17:03:53 +08:00
creator,
gmt_create,
modifier,
gmt_modified
) VALUES(
#{userId},
#{areaCode},
#{areaName},
#{userLevel},
2022-01-22 20:37:54 +08:00
#{userSex},
#{userSexName},
#{userBirth},
#{userEducation},
#{userEducationName},
#{userPolitic},
#{userPoliticName},
2022-02-27 02:36:20 +08:00
#{smcState},
#{smcMeetingId},
#{smcUsername},
#{smcPassword},
#{smcNumber},
2021-11-12 17:03:53 +08:00
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified}
)
</insert>
<!-- 删除(物理) -->
<update id="delete" parameterType="map">
DELETE FROM
sys_user_expand
WHERE
user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</update>
<!-- 修改 -->
<update id="update" parameterType="map">
UPDATE
sys_user_expand
SET
<if test="areaCode != null">
area_code = #{areaCode},
</if>
<if test="areaName != null">
area_name = #{areaName},
2021-11-15 11:11:24 +08:00
</if>
<if test="userLevel != null">
user_level = #{userLevel},
2022-01-22 20:37:54 +08:00
</if>
<if test="userSex != null">
user_sex = #{userSex},
</if>
<if test="userSexName != null">
user_sex_name = #{userSexName},
</if>
<if test="userBirth != null">
user_birth = #{userBirth},
</if>
<if test="userEducation != null">
user_education = #{userEducation},
</if>
<if test="userEducationName != null">
user_education_name = #{userEducationName},
</if>
<if test="userPolitic != null">
user_politic = #{userPolitic},
</if>
<if test="userPoliticName != null">
user_politic_name = #{userPoliticName},
2021-11-12 17:03:53 +08:00
</if>
2022-02-27 02:36:20 +08:00
smc_state = #{smcState},
smc_meeting_id = #{smcMeetingId},
smc_username = #{smcUsername},
smc_password = #{smcPassword},
smc_number = #{smcNumber},
2021-11-12 17:03:53 +08:00
gmt_modified = #{gmtModified},
modifier = #{modifier}
WHERE
user_id = #{userId}
</update>
<!-- 详情 -->
<select id="get" parameterType="map" resultMap="userExpandDTO">
SELECT
t1.user_id,
t1.area_code,
t1.area_name,
t1.user_level,
2022-01-22 20:37:54 +08:00
t1.user_sex,
t1.user_sex_name,
t1.user_birth,
t1.user_education,
t1.user_education_name,
t1.user_politic,
t1.user_politic_name,
2022-02-27 02:36:20 +08:00
t1.smc_state,
t1.smc_meeting_id,
t1.smc_username,
t1.smc_password,
t1.smc_number,
2021-11-12 17:03:53 +08:00
t1.gmt_create
FROM
sys_user_expand t1
WHERE
t1.user_id = #{userId}
</select>
2022-02-27 02:36:20 +08:00
2021-11-12 17:03:53 +08:00
<!-- 详情 -->
<select id="getPO" parameterType="map" resultMap="userExpandPO">
SELECT
t1.user_id,
t1.area_code,
t1.area_name,
t1.user_level,
2022-01-22 20:37:54 +08:00
t1.user_sex,
t1.user_sex_name,
t1.user_birth,
t1.user_education,
t1.user_education_name,
t1.user_politic,
t1.user_politic_name,
2022-02-27 02:36:20 +08:00
t1.smc_state,
t1.smc_meeting_id,
t1.smc_username,
t1.smc_password,
t1.smc_number,
2021-11-12 17:03:53 +08:00
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified
FROM
sys_user_expand t1
WHERE
t1.user_id = #{userId}
</select>
<!-- 列表 -->
<select id="listPO" parameterType="map" resultMap="userExpandPO">
SELECT
t1.user_id,
t1.area_code,
t1.area_name,
t1.user_level,
2022-01-22 20:37:54 +08:00
t1.user_sex,
t1.user_sex_name,
t1.user_birth,
t1.user_education,
t1.user_education_name,
t1.user_politic,
t1.user_politic_name,
2022-02-27 02:36:20 +08:00
t1.smc_state,
t1.smc_meeting_id,
t1.smc_username,
t1.smc_password,
t1.smc_number,
2021-11-12 17:03:53 +08:00
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified
FROM
sys_user_expand t1
2021-11-15 23:34:23 +08:00
<where>
<if test="areaCode != null and areaCode != ''">
t1.area_code = #{areaCode}
</if>
<if test="userIds != null and userIds.size > 0">
AND
t1.user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
</where>
2021-11-12 17:03:53 +08:00
</select>
<!-- 列表 -->
<select id="list" parameterType="map" resultMap="userExpandDTO">
SELECT
t1.user_id,
t1.area_code,
t1.area_name,
2022-01-22 20:37:54 +08:00
t1.user_level,
t1.user_sex,
t1.user_sex_name,
t1.user_birth,
t1.user_education,
t1.user_education_name,
t1.user_politic,
2022-02-27 17:54:19 +08:00
t1.user_politic_name,
2022-02-27 02:36:20 +08:00
t1.smc_state,
t1.smc_meeting_id,
t1.smc_username,
t1.smc_password,
t1.smc_number
FROM
sys_user_expand t1
2021-11-15 23:34:23 +08:00
<where>
<if test="areaCode != null and areaCode != ''">
t1.area_code = #{areaCode}
</if>
2022-02-25 22:56:07 +08:00
<if test="areaCodeLike != null and areaCodeLike != ''">
AND
t1.area_code LIKE CONCAT(#{areaCodeLike}, '%')
</if>
2021-11-15 23:34:23 +08:00
<if test="userIds != null and userIds.size > 0">
AND
t1.user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
2023-04-12 09:55:13 +08:00
<if test="roleId != null and roleId != ''">
AND
EXISTS (SELECT 1 FROM sys_role_user st1 WHERE t1.user_id = st1.user_id AND st1.role_id = #{roleId})
</if>
AND
EXISTS (SELECT 1 FROM sys_user st1 WHERE t1.user_id = st1.user_id)
2021-11-15 23:34:23 +08:00
</where>
</select>
2023-05-18 22:00:44 +08:00
<select id="count" parameterType="map" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM
sys_user_expand sue
INNER JOIN
sys_user su
ON
sue.user_id = su.user_id
<where>
su.is_delete = 0
2023-07-18 16:55:43 +08:00
<if test="areaCode != null and areaCode != ''">
2023-05-18 22:00:44 +08:00
AND
2023-07-18 16:55:43 +08:00
area_code = #{areaCode}
2023-05-18 22:00:44 +08:00
</if>
<if test="areaCodeLike != null and areaCodeLike != ''">
AND
area_code LIKE CONCAT(#{areaCodeLike}, '%')
</if>
2023-06-09 09:27:30 +08:00
<if test="roleId != null and roleId != ''">
AND
su.user_id IN (
SELECT
sru.user_id
FROM
sys_role_user sru
WHERE
sru.role_id = #{roleId}
)
</if>
<if test="gridCode != null and gridCode != ''">
AND
su.user_id IN (
SELECT
mgr.relation_id
FROM
map_grid_relation mgr
WHERE
mgr.grid_id IN (
SELECT
mg.grid_id
FROM
map_grid mg
WHERE
mg.grid_code = #{gridCode}
)
)
</if>
2023-05-18 22:00:44 +08:00
</where>
</select>
2021-11-12 17:03:53 +08:00
</mapper>