<?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="com.mzl.flower.mapper.system.UserMapper">
|
<select id="loginUser" resultType="com.mzl.flower.entity.system.User">
|
SELECT *
|
FROM t_user t
|
WHERE t.deleted = 0 AND t.status = 'A'
|
and t.type = 'customer'
|
and (t.login_name = #{username} or t.tel = #{username})
|
</select>
|
|
<select id="getActiveUser" resultType="com.mzl.flower.entity.system.User">
|
SELECT *
|
FROM t_user t
|
WHERE (t.login_name = #{username} or t.tel = #{username})
|
AND t.status = 'A'
|
AND t.deleted = 0
|
AND (t.`type` IN
|
<foreach collection="userTypes" item="type" open="(" separator="," close=")">
|
#{type}
|
</foreach>
|
)
|
</select>
|
|
<select id="searchUser" resultType="com.mzl.flower.dto.response.system.UserListDTO">
|
SELECT
|
u.ID AS id,
|
u.LOGIN_NAME AS loginName,
|
u.TEL AS tel,
|
u.NICK_NAME AS nickName,
|
u.STATUS AS STATUS,
|
uu.NICK_NAME AS createdName,
|
u.create_time AS createdDate,
|
u.IS_SYS AS isSys,
|
(SELECT GROUP_CONCAT(DISTINCT(role.ID)) FROM t_role role INNER JOIN t_user_role ur ON ur.ROLE_ID = role.ID
|
WHERE
|
ur.USER_ID = u.ID
|
ORDER BY ROLE_NAME
|
) AS roleIds,
|
(SELECT GROUP_CONCAT(DISTINCT(ROLE_NAME)) FROM t_role role INNER JOIN t_user_role ur ON ur.ROLE_ID = role.ID
|
WHERE
|
ur.USER_ID = u.ID
|
ORDER BY ROLE_NAME
|
) AS roleDesc,
|
e.birthday,
|
e.gender,
|
e.id_card,
|
e.post_name,
|
e.work_content,
|
e.in_date,
|
e.salary
|
FROM t_user u
|
LEFT JOIN t_user uu ON u.create_by = uu.id
|
left join t_employee e on e.user_id = u.id
|
where u.deleted = 0
|
<if test="condition.loginName != null and condition.loginName != ''">
|
AND (u.LOGIN_NAME LIKE concat('%', #{condition.loginName},'%')
|
or u.NICK_NAME LIKE concat('%', #{condition.loginName},'%')
|
or u.tel LIKE concat('%', #{condition.loginName},'%')
|
)
|
</if>
|
<if test="condition.status != null and condition.status != ''">
|
AND u.STATUS = #{condition.status}
|
</if>
|
AND (u.`type` in
|
<foreach collection="condition.userTypes" item="type" open="(" separator="," close=")">
|
#{type}
|
</foreach>
|
)
|
order by u.create_time desc
|
</select>
|
|
<select id="selectUserRoleDesc" resultType="string">
|
SELECT GROUP_CONCAT(DISTINCT(ROLE_NAME))
|
FROM t_role role
|
INNER JOIN t_user_role ur ON ur.ROLE_ID = role.ID
|
WHERE ur.USER_ID = #{userId}
|
ORDER BY ROLE_NAME
|
</select>
|
<select id="getByOpenID" resultType="com.mzl.flower.entity.system.User">
|
SELECT
|
t.*
|
FROM
|
t_user_wechat w
|
LEFT JOIN t_user t ON t.id = w.user_id WHERE w.open_id = #{openId}
|
AND t.`type` IN
|
<foreach collection="userTypes" item="type" open="(" separator="," close=")">
|
#{type}
|
</foreach>
|
|
</select>
|
|
<select id="searchUserInfo" resultType="com.mzl.flower.dto.response.system.UserListInfoDTO">
|
SELECT
|
user_id,
|
id,
|
name AS loginName,
|
contact_tel tel,
|
type
|
FROM (
|
SELECT user_id, id, name, contact_tel, 'supplier' AS type
|
FROM t_supplier_info
|
WHERE user_id IN (SELECT id FROM t_user WHERE type = 'supplier')
|
|
UNION ALL
|
|
SELECT user_id, id, name, contact_tel, 'partner' AS type
|
FROM t_partner_info
|
WHERE user_id IN (SELECT id FROM t_user WHERE type = 'partner')
|
|
UNION ALL
|
|
SELECT c.user_id, c.id, c.name, u.tel AS contact_tel, 'customer' AS type
|
FROM t_customer_info c
|
JOIN t_user u ON c.user_id = u.id
|
WHERE c.user_id IN (SELECT id FROM t_user WHERE type = 'customer')
|
) AS combined_table
|
<where>
|
<if test="condition.userType != null and condition.userType != ''">
|
AND type = #{condition.userType}
|
</if>
|
<if test="condition.id != null and condition.id != ''">
|
AND id = #{condition.id}
|
</if>
|
<if test="condition.loginName != null and condition.loginName != ''">
|
AND name like concat('%', #{condition.loginName},'%')
|
</if>
|
<if test="condition.tel != null and condition.tel != ''">
|
AND contact_tel like concat('%', #{condition.tel},'%')
|
</if>
|
</where>
|
ORDER BY user_id, id
|
</select>
|
|
<select id="getSelectList" resultType="com.mzl.flower.dto.response.sms.SmsSelectVO">
|
SELECT
|
user_id,
|
id,
|
name AS loginName,
|
contact_tel tel,
|
type
|
FROM (
|
SELECT user_id, id, name, contact_tel, 'supplier' AS type
|
FROM t_supplier_info
|
WHERE user_id IN (SELECT id FROM t_user WHERE type = 'supplier')
|
|
UNION ALL
|
|
SELECT user_id, id, name, contact_tel, 'partner' AS type
|
FROM t_partner_info
|
WHERE user_id IN (SELECT id FROM t_user WHERE type = 'partner')
|
|
UNION ALL
|
|
SELECT c.user_id, c.id, c.name, u.tel AS contact_tel, 'customer' AS type
|
FROM t_customer_info c
|
JOIN t_user u ON c.user_id = u.id
|
WHERE c.user_id IN (SELECT id FROM t_user WHERE type = 'customer')
|
) AS combined_table
|
<where>
|
1=1
|
<if test="idList != null and idList.size() > 0">
|
AND user_id IN
|
<foreach collection="idList" item="id" open="(" separator="," close=")">
|
#{id}
|
</foreach>
|
</if>
|
</where>
|
</select>
|
</mapper>
|