192 lines
5.2 KiB
XML
192 lines
5.2 KiB
XML
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||
|
|
<mapper namespace="com.bonus.zhly.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.zhly.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.zhly.model.SysUser" >
|
||
|
|
insert into sys_user(user_name,login_name,password,sex,phone,email,org_id,unit,dept,login_type,
|
||
|
|
role_id,state,del_flag,create_time,new_user,type
|
||
|
|
<if test='type=="0"'>
|
||
|
|
,ls_time
|
||
|
|
</if>
|
||
|
|
)values (
|
||
|
|
#{username},#{loginName},#{password},#{sex},#{phone},#{email},#{orgId},#{unit},#{dept},#{loginType},
|
||
|
|
#{roleId},'1','0',now(),'0',#{type}
|
||
|
|
<if test='type=="0"'>
|
||
|
|
,now()
|
||
|
|
</if>
|
||
|
|
)
|
||
|
|
</insert>
|
||
|
|
<!--登录查询用户-->
|
||
|
|
<select id="getUser" parameterType="String" resultType="com.bonus.zhly.model.SysUser">
|
||
|
|
select id,user_name as username,login_name as loginName,
|
||
|
|
password,state,role_id as roleId,login_type loginType,new_user newUser
|
||
|
|
from sys_user t
|
||
|
|
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.zhly.model.SysUser">
|
||
|
|
select t.id, t.user_name as username, t.login_name as loginName,
|
||
|
|
t.sex as sex, t.phone as phone, t.email as email,so.abb_name,so.org_name orgName,
|
||
|
|
t.state as state,t.del_flag as delFlag,sr.role_name roleName
|
||
|
|
from sys_user t
|
||
|
|
left join sys_role sr on sr.role_id=t.role_id
|
||
|
|
left join sys_org so on so.org_id=t.org_id
|
||
|
|
<where>
|
||
|
|
<if test="state!=null">
|
||
|
|
<if test="state==999">
|
||
|
|
and t.del_flag='1'
|
||
|
|
</if>
|
||
|
|
<if test="state!=999">
|
||
|
|
and t.state = #{state} and t.del_flag='0'
|
||
|
|
</if>
|
||
|
|
</if>
|
||
|
|
<if test="loginName != null and loginName != ''">
|
||
|
|
and t.login_name like concat('%', #{loginName}, '%')
|
||
|
|
</if>
|
||
|
|
<if test="username != null and username != ''">
|
||
|
|
and t.user_name like concat('%', #{username}, '%')
|
||
|
|
</if>
|
||
|
|
<if test="roleId != null and roleId != ''">
|
||
|
|
and t.role_id = #{roleId}
|
||
|
|
</if>
|
||
|
|
</where>
|
||
|
|
order by t.del_flag ASC , t.state,t.create_time DESC
|
||
|
|
</select>
|
||
|
|
<select id="getPasswordConfigById" resultType="com.bonus.zhly.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.zhly.system.vo.UserDto">
|
||
|
|
select id,
|
||
|
|
user_name as username,
|
||
|
|
login_name as loginName,
|
||
|
|
sex,
|
||
|
|
phone,
|
||
|
|
email,
|
||
|
|
org_id as orgId,
|
||
|
|
unit,
|
||
|
|
dept,
|
||
|
|
type,
|
||
|
|
login_type as loginType,
|
||
|
|
role_id as roleId,
|
||
|
|
state
|
||
|
|
from sys_user
|
||
|
|
where id = #{id}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getOrg" resultType="com.bonus.zhly.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
|
||
|
|
order by org_sort asc
|
||
|
|
</select>
|
||
|
|
<select id="getPhone" resultType="com.bonus.zhly.model.SysUser">
|
||
|
|
select id,phone
|
||
|
|
from sys_user
|
||
|
|
where phone = #{phone}
|
||
|
|
</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.sex = #{sex},
|
||
|
|
t.phone = #{phone},
|
||
|
|
t.email = #{email},
|
||
|
|
t.org_id = #{orgId},
|
||
|
|
t.unit = #{unit},
|
||
|
|
t.dept = #{dept},
|
||
|
|
t.login_type = #{loginType},
|
||
|
|
t.role_id = #{roleId},
|
||
|
|
t.type=#{type},
|
||
|
|
<if test='type=="0"'>
|
||
|
|
ls_time=now(),
|
||
|
|
</if>
|
||
|
|
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>
|
||
|
|
</mapper>
|