125 lines
5.5 KiB
XML
125 lines
5.5 KiB
XML
|
|
<?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.securityControl.system.mapper.UserManageDao">
|
||
|
|
<!--查询用户角色-->
|
||
|
|
<select id="selectUserByUserName" parameterType="String" resultType="com.securityControl.system.api.domain.SysUser">
|
||
|
|
select su.id userId,user_name userName,login_name nickName,role_id roleId,sr.`name` roleName,
|
||
|
|
su.org_id orgId,pwd password,phone phonenumber ,sex,mailbox email,su.status,
|
||
|
|
so.abb_name orgName,IFNULL(su.unit,so.abb_name) unitName
|
||
|
|
FROM sys_user su
|
||
|
|
left join sys_org so on so.org_id=su.org_id
|
||
|
|
LEFT JOIN sys_role sr on sr.id=su.role_id
|
||
|
|
where su.`status`!='1'
|
||
|
|
and login_name=#{username}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!--分页查询用户-->
|
||
|
|
<select id="getUserList" parameterType="com.securityControl.system.domain.vo.SysUserEntity" resultType="com.securityControl.system.domain.vo.SysUserEntity">
|
||
|
|
select su.id userId,su.user_name userName,su.login_name loginName,su.role_name roleName,su.phone,
|
||
|
|
su.sex,so.org_name orgName,su.status,su.unit
|
||
|
|
from sys_user su
|
||
|
|
left join sys_org so on so.org_id=su.org_id and so.is_active=1
|
||
|
|
<where>
|
||
|
|
<if test="status!=null and status!=''">
|
||
|
|
and su.status=#{status}
|
||
|
|
</if>
|
||
|
|
<if test="roleId!=null and roleId!=''">
|
||
|
|
and su.role_id=#{roleId}
|
||
|
|
</if>
|
||
|
|
<if test="orgId!=null and orgId!=''">
|
||
|
|
and su.org_id=#{orgId}
|
||
|
|
</if>
|
||
|
|
<if test="keyWord!=null and keyWord!=''">
|
||
|
|
and (
|
||
|
|
su.user_name like concat('%',concat(#{keyWord},'%')) or
|
||
|
|
su.login_name like concat('%',concat(#{keyWord},'%')) or
|
||
|
|
su.role_name like concat('%',concat(#{keyWord},'%')) or
|
||
|
|
su.phone like concat('%',concat(#{keyWord},'%')) or
|
||
|
|
INSTR(su.unit,#{keyWord}) > 0
|
||
|
|
)
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</where>
|
||
|
|
</select>
|
||
|
|
<!--查询账号唯一-->
|
||
|
|
<select id="getUserLoginNum" parameterType="com.securityControl.system.domain.vo.SysUserEntity" resultType="Integer">
|
||
|
|
select count(1)
|
||
|
|
from sys_user
|
||
|
|
where login_name=#{loginName}
|
||
|
|
<if test="userId!=null and userId!=''">
|
||
|
|
and id!=#{userId}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!--查询手机号唯一-->
|
||
|
|
<select id="getUserPhoneNum" parameterType="com.securityControl.system.domain.vo.SysUserEntity" resultType="Integer">
|
||
|
|
select count(1)
|
||
|
|
from sys_user
|
||
|
|
where phone=#{phone}
|
||
|
|
<if test="userId!=null and userId!=''">
|
||
|
|
and id!=#{userId}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
<!--新增用户-->
|
||
|
|
<insert id="insertUser" parameterType="com.securityControl.system.domain.vo.SysUserEntity" >
|
||
|
|
insert into sys_user(user_name,login_name,role_name,role_id,org_id,pwd,phone,sex,mailbox,status,unit)values (
|
||
|
|
#{userName}, #{loginName}, #{roleName}, #{roleId}, #{orgId}, #{passWord}, #{phone}, #{sex},#{mailbox},#{status},#{unit}
|
||
|
|
)
|
||
|
|
</insert>
|
||
|
|
<!--修改用户-->
|
||
|
|
<update id="updateUser" parameterType="com.securityControl.system.domain.vo.SysUserEntity" >
|
||
|
|
update sys_user
|
||
|
|
<set>
|
||
|
|
<if test="userName!=null and userName!=''">
|
||
|
|
user_name=#{userName}
|
||
|
|
</if>
|
||
|
|
<if test="loginName!=null and loginName!=''">
|
||
|
|
, login_name=#{loginName}
|
||
|
|
</if>
|
||
|
|
<if test="roleName!=null and roleName!=''">
|
||
|
|
,role_name=#{roleName}
|
||
|
|
</if>
|
||
|
|
<if test="roleId!=null and roleId!=''">
|
||
|
|
,role_id=#{roleId}
|
||
|
|
</if>
|
||
|
|
<if test="orgId!=null and orgId!=''">
|
||
|
|
, org_id=#{orgId}
|
||
|
|
</if>
|
||
|
|
<if test="passWord!=null and passWord!=''">
|
||
|
|
,pwd=#{passWord}
|
||
|
|
</if>
|
||
|
|
<if test="phone!=null and phone!=''">
|
||
|
|
,phone=#{phone}
|
||
|
|
</if>
|
||
|
|
<if test="sex!=null and sex!=''">
|
||
|
|
, sex=#{sex}
|
||
|
|
</if>
|
||
|
|
<if test="mailbox!=null and mailbox!=''">
|
||
|
|
, mailbox=#{mailbox}
|
||
|
|
</if>
|
||
|
|
<if test="status!=null and status!=''">
|
||
|
|
, status=#{status}
|
||
|
|
</if>
|
||
|
|
<if test="unit!=null and unit!=''">
|
||
|
|
, unit=#{unit}
|
||
|
|
</if>
|
||
|
|
</set>
|
||
|
|
where id=#{userId}
|
||
|
|
</update>
|
||
|
|
<update id="deleteUser" parameterType="String">
|
||
|
|
update sys_user set status='1' where id=#{userId}
|
||
|
|
</update>
|
||
|
|
<update id="updatePwd" parameterType="com.securityControl.system.domain.vo.SysUserEntity">
|
||
|
|
update sys_user set pwd=#{passWord} where id=#{userId}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<!--查询用户信息 -->
|
||
|
|
<select id="getUserDetail" resultType="com.securityControl.system.domain.vo.SysUserEntity" parameterType="String">
|
||
|
|
select su.id userId,su.user_name userName,su.login_name loginName,su.role_name roleName,su.phone,su.mailbox,su.pwd passWord,
|
||
|
|
su.org_id orgId,su.role_id roleId,
|
||
|
|
su.sex,so.org_name orgName,su.status,su.unit
|
||
|
|
from sys_user su
|
||
|
|
left join sys_org so on so.org_id=su.org_id and so.is_active=1
|
||
|
|
where su.id=#{userId}
|
||
|
|
</select>
|
||
|
|
</mapper>
|