208 lines
5.6 KiB
XML
208 lines
5.6 KiB
XML
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.bonus.aqgqj.system.dao.UserDao">
|
|
<!--修改用户登录时间-->
|
|
<update id="updateLoginTime">
|
|
update sys_user set login_time=now()
|
|
WHERE id=#{id}
|
|
|
|
</update>
|
|
<!--用户状态修改-->
|
|
<update id="updateUserState" parameterType="String">
|
|
update sys_user set
|
|
<if test="delFlag!=null and delFlag!=''">
|
|
del_flag=#{delFlag}
|
|
</if>
|
|
<if test="state!=null and state!=''">
|
|
state=#{state}
|
|
</if>
|
|
<if test='state=="0"'>
|
|
,sleep_time=now()
|
|
</if>
|
|
<where>
|
|
<if test="username!=null and username!=''">
|
|
and login_name=#{username}
|
|
</if>
|
|
<if test="id!=null and id!=''">
|
|
and id=#{id}
|
|
</if>
|
|
</where>
|
|
</update>
|
|
<select id="getLockUser" resultType="com.bonus.aqgqj.model.SysUser">
|
|
select user_name userName,login_name loginName,ls_time lsTime ,
|
|
type,sleep_time sleepTime,id,login_time loginTimes
|
|
from sys_user
|
|
where del_flag=0
|
|
<if test="state!=null and state!=''">
|
|
and state=#{state}
|
|
</if>
|
|
<if test="type!=null and type!=''">
|
|
and type=#{type}
|
|
</if>
|
|
</select>
|
|
<!--新增用户-->
|
|
<insert id="saveUser" parameterType="com.bonus.aqgqj.model.SysUser" >
|
|
insert into sys_user(login_name, user_name, user_code, sex, org_id, role_id, phone, user_type, state, password,team_id,create_time)
|
|
values (#{loginName}, #{username}, #{userCode}, #{sex}, #{orgId}, #{roleId}, #{phone}, #{userType}, #{state},
|
|
#{password},#{teamId},NOW())
|
|
</insert>
|
|
<!--登录查询用户-->
|
|
<select id="getUser" parameterType="String" resultType="com.bonus.aqgqj.model.SysUser">
|
|
select t.id,t.user_name as username,t.login_name as loginName,
|
|
t.password,t.state,t.role_id as roleId,t.login_type loginType,t.new_user newUser,
|
|
sr.role_code AS roleCode,sr.role_name AS roleName,t.team_id AS teamId
|
|
from sys_user t
|
|
LEFT JOIN sys_role sr ON t.role_id = sr.role_id AND sr.del_flag = 0
|
|
where t.login_name = #{username}
|
|
</select>
|
|
|
|
<sql id="where">
|
|
<where>
|
|
<if test="username != null and username != ''">
|
|
and t.user_name like concat('%', #{username}, '%')
|
|
</if>
|
|
<if test="loginName != null and loginName != ''">
|
|
and t.login_name like concat('%', #{loginName}, '%')
|
|
</if>
|
|
|
|
<if test="phone != null and phone != ''">
|
|
and t.phone like concat('%', #{phone}, '%')
|
|
</if>
|
|
</where>
|
|
</sql>
|
|
|
|
<select id="count" resultType="int">
|
|
select count(1) from sys_user t
|
|
<include refid="where" />
|
|
</select>
|
|
|
|
<select id="list" resultType="com.bonus.aqgqj.model.SysUser">
|
|
SELECT
|
|
t.id,
|
|
t.login_name AS loginName,
|
|
t.user_name AS username,
|
|
t.user_code AS userCode,
|
|
t.sex,
|
|
t.org_id as orgId,
|
|
CONCAT(so.org_name,'/',tt.team_name) as orgName,
|
|
sr.role_name roleName,
|
|
t.phone AS phone,
|
|
t.team_id as teamId,
|
|
tt.team_name as teamName,
|
|
CASE
|
|
t.user_type
|
|
WHEN '0' THEN
|
|
'内部用户'
|
|
WHEN '1' THEN
|
|
'外部用户' ELSE ''
|
|
END userType,
|
|
t.state AS state,
|
|
t.del_flag AS delFlag
|
|
FROM
|
|
sys_user t
|
|
LEFT JOIN sys_role sr ON sr.role_id = t.role_id
|
|
left join tb_team tt on tt.id = t.team_id and tt.del_flag = 0
|
|
LEFT JOIN sys_org so ON so.org_id = t.org_id
|
|
where t.del_flag = 0
|
|
<if test="username != null and username != ''">
|
|
and t.user_name like concat('%', #{username}, '%')
|
|
</if>
|
|
<if test="phone != null and phone != ''">
|
|
and t.phone like concat('%', #{phone}, '%')
|
|
</if>
|
|
<if test="orgId != null and orgId != ''">
|
|
and t.org_id = #{orgId}
|
|
</if>
|
|
<if test="userType != null and userType != ''">
|
|
and t.user_type = #{userType}
|
|
</if>
|
|
order by t.del_flag ASC , t.state,t.create_time DESC
|
|
</select>
|
|
<select id="getPasswordConfigById" resultType="com.bonus.aqgqj.model.PasswordConfig">
|
|
select pwd_strength as pwdStrength,
|
|
min_length as minLength,
|
|
max_length as maxLength
|
|
from sys_password_config
|
|
where id = 1
|
|
</select>
|
|
<select id="getById" resultType="com.bonus.aqgqj.system.vo.UserDto">
|
|
select id,
|
|
user_name as username,
|
|
login_name as loginName,
|
|
sex,
|
|
user_code as userCode,
|
|
phone,
|
|
email,
|
|
org_id as orgId,
|
|
user_type as userType,
|
|
type,
|
|
login_type as loginType,
|
|
role_id as roleId,
|
|
state
|
|
from sys_user
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<select id="getOrg" resultType="com.bonus.aqgqj.system.vo.Org">
|
|
select org_id as id,
|
|
org_name as title,
|
|
p_id as parentId,
|
|
'0' AS checkArr
|
|
from sys_org
|
|
where del_flag = 0
|
|
and state=1
|
|
order by org_sort asc
|
|
</select>
|
|
<select id="getPhone" resultType="com.bonus.aqgqj.model.SysUser">
|
|
select id,phone
|
|
from sys_user
|
|
where phone = #{phone}
|
|
</select>
|
|
<select id="getOrgTree" resultType="com.bonus.aqgqj.base.entity.DtreeVo">
|
|
SELECT so.org_id AS id,
|
|
so.org_name AS title,
|
|
so.p_id AS parentId
|
|
FROM sys_org so
|
|
WHERE so.del_flag = 0
|
|
and so.state=1
|
|
</select>
|
|
|
|
<insert id="saveUserRoles">
|
|
insert into sys_role_user(roleId, userId) values
|
|
<foreach collection="roleIds" item="roleId" separator=",">
|
|
(#{roleId}, #{userId})
|
|
</foreach>
|
|
</insert>
|
|
|
|
<update id="update">
|
|
update sys_user t
|
|
set t.user_name = #{username},
|
|
t.login_name = #{loginName},
|
|
t.user_code = #{userCode},
|
|
t.sex = #{sex},
|
|
t.org_id = #{orgId},
|
|
t.role_id = #{roleId},
|
|
t.phone = #{phone},
|
|
t.user_type = #{userType},
|
|
t.state = #{state},
|
|
t.update_time = now()
|
|
where t.id = #{id}
|
|
</update>
|
|
|
|
<update id="delUser">
|
|
update sys_user
|
|
set del_flag = 1
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<update id="password">
|
|
update sys_user
|
|
set password = #{password}
|
|
where id = #{id}
|
|
</update>
|
|
<update id="updateEnableState">
|
|
update sys_user
|
|
set state = #{state}
|
|
where id = #{id}
|
|
</update>
|
|
</mapper> |