master
parent
244a5afd19
commit
24ca545763
@ -1,119 +1,7 @@
|
||||
<?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.jingcheng.template.mapper.UsersMapper">
|
||||
<select id="getUsersByConditions" resultType="com.jingcheng.template.model.Users">
|
||||
SELECT u.`id`,u.`name`,u.`user_no`,u.`password`,u.`work_units`,u.`sex`,u.`is_certificate`,
|
||||
u.`create_date_time`,u.`update_date_time`,u.`create_by`,u.`update_by`,u.`state`,u.`business_level_id`,
|
||||
u.`business_level_name`,u.`role_id`,u.role_name,u.`phone`,u.`score` from users u
|
||||
LEFT JOIN
|
||||
(SELECT tu.`id`,tu.`training_id`,tu.`users_id`,tu.`state`,t.training_name
|
||||
from training_users tu
|
||||
left join training t
|
||||
on tu.training_id = t.id
|
||||
where tu.state = 1
|
||||
) ntu
|
||||
on ntu.users_id = u.id
|
||||
left join
|
||||
(select `groups_id`,`users_id` from groups_users where state = 1) gu
|
||||
on gu.users_id = u.id
|
||||
WHERE
|
||||
1 = 1
|
||||
<if test="isCertificate != null">
|
||||
AND u.is_certificate = #{isCertificate}
|
||||
</if>
|
||||
<if test="roleId != null">
|
||||
AND u.role_id = #{roleId}
|
||||
</if>
|
||||
<if test="joinStartTime != null and joinStartTime != '' and joinEndTime != null and joinEndTime != ''">
|
||||
AND u.create_date_time between #{joinStartTime} and #{joinEndTime}
|
||||
</if>
|
||||
<if test="param != null">
|
||||
and (u.`phone` LIKE CONCAT('%',#{param},'%')
|
||||
or u.name like concat('%',#{param},'%')
|
||||
or u.work_units like concat('%',#{param},'%')
|
||||
or u.user_no like concat('%',#{param},'%'))
|
||||
</if>
|
||||
<if test="trainingId != null">
|
||||
AND ntu.training_id = #{trainingId}
|
||||
</if>
|
||||
<if test="groupsId != null">
|
||||
AND gu.groups_id = #{groupsId}
|
||||
</if>
|
||||
and (u.state = 1 or u.state = 2)
|
||||
and u.`role_id` != 5
|
||||
group by u.`id`
|
||||
</select>
|
||||
|
||||
<select id="getExportUsersByConditions" resultType="java.util.LinkedHashMap">
|
||||
SELECT u.`id` as ID,u.`user_no` as 账号 ,u.`name` as 姓名,u.`password` as 密码 ,
|
||||
(case when u.`sex` = 0 then '女'
|
||||
when u.`sex` = 1 then '男'
|
||||
ELSE '未知' end) as 性别
|
||||
,u.`work_units` as 单位,u.role_name as 角色,
|
||||
g.groups_name as 分组,
|
||||
(case when u.`is_certificate` = 0 then '否'
|
||||
ELSE '是' end) as 是否认证,
|
||||
u.`create_date_time` as 加入时间,
|
||||
(case when u.`state` = 0 then '已删除'
|
||||
when u.`state` = 1 then '已启用'
|
||||
ELSE '已冻结' end) as 状态
|
||||
from users u
|
||||
LEFT JOIN
|
||||
(SELECT tu.`id`,tu.`training_id`,tu.`users_id`,tu.`state`,t.training_name
|
||||
from training_users tu
|
||||
left join training t
|
||||
on tu.training_id = t.id
|
||||
) ntu
|
||||
on ntu.users_id = u.id
|
||||
left join
|
||||
(select GROUP_CONCAT(groups_name SEPARATOR "," ) as groups_name ,users_id FROM `groups_users` where state = 1 GROUP BY users_id) g
|
||||
on g.users_id = u.id
|
||||
left join
|
||||
(select `groups_id`,`users_id` from groups_users where state = 1) gu
|
||||
on gu.users_id = u.id
|
||||
WHERE
|
||||
1 = 1
|
||||
<if test="isCertificate != null">
|
||||
AND u.is_certificate = #{isCertificate}
|
||||
</if>
|
||||
<if test="roleId != null">
|
||||
AND u.role_id = #{roleId}
|
||||
</if>
|
||||
|
||||
<if test="joinStartTime != null and joinStartTime != '' and joinEndTime != null and joinEndTime != ''">
|
||||
AND u.create_date_time between #{joinStartTime} and #{joinEndTime}
|
||||
</if>
|
||||
<if test="param != null">
|
||||
and (u.`phone` LIKE CONCAT('%',#{param},'%')
|
||||
or u.name like concat('%',#{param},'%')
|
||||
or u.work_units like concat('%',#{param},'%')
|
||||
or u.user_no like concat('%',#{param},'%'))
|
||||
</if>
|
||||
<if test="trainingId != null">
|
||||
AND ntu.training_id = #{trainingId}
|
||||
</if>
|
||||
<if test="groupsId != null">
|
||||
AND gu.groups_id = #{groupsId}
|
||||
</if>
|
||||
and u.state = 1 or u.state = 2
|
||||
group by u.`id`
|
||||
</select>
|
||||
<select id="superAdminGetUsersList" resultType="com.jingcheng.template.model.Users">
|
||||
select u.`id`,u.`name`,u.`role_name`,u.`role_id`,u.`user_no`,u.`password`,u.`work_units`,
|
||||
u.`sex`,u.`is_certificate`,u.`business_level_name`,u.`business_level_id`,u.`create_date_time`,
|
||||
u.`update_date_time`,u.`create_by`,u.`update_by`,u.`state`,u.`phone`,u.`score`
|
||||
from users u
|
||||
left join groups_users gu
|
||||
on gu.users_id = u.`id`
|
||||
where gu.groups_id = #{groupsId} and (u.`role_id` = 1 or u.`role_id` = 2) AND u.state = 1 and gu.state = 1
|
||||
<if test="name != null and name !=''">
|
||||
and u.`name` LIKE CONCAT('%',#{name},'%')
|
||||
</if>
|
||||
</select>
|
||||
<select id="getbanUsers" resultType="com.jingcheng.template.model.Users">
|
||||
select u.`id`,u.`name`,u.`role_id`,u.`role_name` from users u left join groups_users gu
|
||||
on gu.users_id = u.id
|
||||
where
|
||||
gu.groups_id = #{groupsId} AND u.role_id = 2 and u.state = 1 and gu.state = 1
|
||||
</select>
|
||||
<update id="updateChancesTask">
|
||||
UPDATE users set chances = 3
|
||||
</update>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue