<?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.cloud.user.dao.AppUserDao">
|
|
<sql id="appUser" >
|
t.id id,t.orgId,t.officeId,t.username,t.password,t.nickname,t.phone,t.sex,t.type,t.no no,t.eMail eMail,t.telPhone,
|
t.headImgUrl,t.qrCode,t.idCard,t.userType,t.dataScope,t.enabled
|
</sql>
|
<sql id="org" >
|
org.name orgName,parentOrg.name parentName, concat(IFNULL(parentOrg.name,"")," ",org.name) parentAndMyName
|
</sql>
|
<sql id="where">
|
<where>
|
t.delFlag = '0'
|
<if test="username != null and username != ''">
|
and t.username like concat('%', #{username}, '%')
|
</if>
|
<if test="name != null and name != ''">
|
and t.nickname like concat('%', #{name}, '%')
|
</if>
|
<if test="enabled != null and enabled != ''">
|
and t.enabled = #{enabled}
|
</if>
|
<if test="type != null and type != ''">
|
and t.type = #{type}
|
</if>
|
<if test="orgId != null and orgId != ''">
|
and t.orgId = #{orgId}
|
</if>
|
</where>
|
</sql>
|
<select id="count1" resultType="int">
|
select count(*) from app_user t
|
<include refid="where" />
|
</select>
|
|
<select id="findData1" resultType="com.cloud.model.sys.AppUser">
|
select * from app_user t
|
<include refid="where" />
|
order by t.id desc
|
limit #{start}, #{length}
|
</select>
|
|
<select id="count" resultType="int">
|
SELECT COUNT(t.id) FROM app_user t INNER JOIN sys_organization org ON t.officeId = org.id
|
AND t.delFlag = 0
|
AND org.parentIds LIKE CONCAT((select parentIds from sys_organization where id = #{id}),"%")
|
<include refid="where" />
|
</select>
|
|
<select id="findData" resultType="com.cloud.user.model.OrgNameAppUser">
|
SELECT
|
<include refid="appUser" /> , <include refid="org" />
|
FROM app_user t
|
INNER JOIN sys_organization org ON t.officeId = org.id
|
AND t.delFlag = 0
|
AND org.parentIds LIKE CONCAT((select parentIds from sys_organization where id = #{id}),"%")
|
left join sys_organization parentOrg on org.parentId = parentOrg.id
|
<include refid="where" />
|
order by t.id desc
|
limit #{start}, #{length}
|
</select>
|
|
<select id="login" resultType="com.cloud.model.sys.AppUser">
|
select *
|
from app_user
|
where username = #{username}
|
and password = #{password}
|
and enabled=1
|
and delFlag=0
|
<if test="orgId != null and orgId != ''">
|
and orgId = #{orgId}
|
</if>
|
</select>
|
|
<select id="findById" resultType="com.cloud.model.sys.AppUser">
|
select *
|
from app_user
|
where id = #{id,jdbcType=INTEGER}
|
<if test="orgId != null and orgId != ''">
|
and orgId = #{orgId}
|
</if>
|
</select>
|
<select id="findDataByOfficeId" resultType="com.cloud.model.sys.AppUser">
|
select a.*
|
from app_user a
|
LEFT JOIN sys_organization b on a.officeId = b.id
|
where b.parentIds like CONCAT("%,",#{id},",%")
|
and a.delFlag = #{delFlag}
|
and b.delFlag = #{delFlag}
|
</select>
|
<update id="updateOfficeId" parameterType="map">
|
update app_user
|
<set>
|
<if test="updateOfficeId != null">
|
officeId = #{updateOfficeId,jdbcType=CHAR},
|
</if>
|
<if test="updateOrgId != null">
|
orgId = #{updateOrgId,jdbcType=CHAR},
|
</if>
|
</set>
|
<where>
|
<if test="officeId != null and officeId != ''">
|
and officeId in (
|
SELECT id
|
from sys_organization
|
where parentIds LIKE CONCAT("%,",#{officeId},",%") and delFlag=0
|
)
|
</if>
|
<if test="userIds != null and userIds != ''">
|
and id in (${userIds})
|
</if>
|
<!--<if test="orgId != null and orgId != ''">
|
and orgId = #{orgId}
|
</if>-->
|
</where>
|
</update>
|
|
<!--用户保存-->
|
<insert id="save" parameterType="com.cloud.model.sys.AppUser" useGeneratedKeys="true" keyProperty="id">
|
insert into app_user
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="orgId != null">
|
orgId,
|
</if>
|
<if test="officeId != null">
|
officeId,
|
</if>
|
<if test="username != null">
|
username,
|
</if>
|
<if test="password != null">
|
password,
|
</if>
|
<if test="nickname != null">
|
nickname,
|
</if>
|
<if test="phone != null">
|
phone,
|
</if>
|
<if test="sex != null">
|
sex,
|
</if>
|
<if test="type != null">
|
type,
|
</if>
|
<if test="no != null">
|
no,
|
</if>
|
<if test="eMail != null">
|
eMail,
|
</if>
|
<if test="telPhone != null">
|
telPhone,
|
</if>
|
<if test="headImgUrl != null">
|
headImgUrl,
|
</if>
|
<if test="qrCode != null">
|
qrCode,
|
</if>
|
<if test="idCard != null">
|
idCard,
|
</if>
|
<if test="userType != null">
|
userType,
|
</if>
|
<if test="dataScope != null">
|
dataScope,
|
</if>
|
<if test="enabled != null">
|
enabled,
|
</if>
|
<if test="delFlag != null">
|
delFlag,
|
</if>
|
<if test="createTime != null">
|
createTime,
|
</if>
|
<if test="updateTime != null">
|
updateTime,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="orgId != null">
|
#{orgId,jdbcType=INTEGER},
|
</if>
|
<if test="officeId != null">
|
#{officeId,jdbcType=INTEGER},
|
</if>
|
<if test="username != null">
|
#{username,jdbcType=VARCHAR},
|
</if>
|
<if test="password != null">
|
#{password,jdbcType=VARCHAR},
|
</if>
|
<if test="nickname != null">
|
#{nickname,jdbcType=VARCHAR},
|
</if>
|
<if test="phone != null">
|
#{phone,jdbcType=VARCHAR},
|
</if>
|
<if test="sex != null">
|
#{sex,jdbcType=VARCHAR},
|
</if>
|
<if test="type != null">
|
#{type,jdbcType=VARCHAR},
|
</if>
|
<if test="no != null">
|
#{no,jdbcType=VARCHAR},
|
</if>
|
<if test="eMail != null">
|
#{eMail,jdbcType=VARCHAR},
|
</if>
|
<if test="telPhone != null">
|
#{telPhone,jdbcType=VARCHAR},
|
</if>
|
<if test="headImgUrl != null">
|
#{headImgUrl,jdbcType=VARCHAR},
|
</if>
|
<if test="qrCode != null">
|
#{qrCode,jdbcType=VARCHAR},
|
</if>
|
<if test="idCard != null">
|
#{idCard,jdbcType=VARCHAR},
|
</if>
|
<if test="userType != null">
|
#{userType,jdbcType=VARCHAR},
|
</if>
|
<if test="dataScope != null">
|
#{dataScope,jdbcType=VARCHAR},
|
</if>
|
<if test="enabled != null">
|
#{enabled,jdbcType=VARCHAR},
|
</if>
|
<if test="delFlag != null">
|
#{delFlag,jdbcType=VARCHAR},
|
</if>
|
<if test="createTime != null">
|
#{createTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="updateTime != null">
|
#{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
</trim>
|
</insert>
|
|
<!--用户修改-->
|
<update id="update" parameterType="com.cloud.model.sys.AppUser">
|
update app_user
|
<set>
|
<if test="orgId != null">
|
orgId = #{orgId,jdbcType=INTEGER},
|
</if>
|
<if test="officeId != null">
|
officeId = #{officeId,jdbcType=INTEGER},
|
</if>
|
<if test="username != null">
|
username = #{username,jdbcType=VARCHAR},
|
</if>
|
<if test="password != null">
|
password = #{password,jdbcType=VARCHAR},
|
</if>
|
<if test="nickname != null">
|
nickname = #{nickname,jdbcType=VARCHAR},
|
</if>
|
<if test="phone != null">
|
phone = #{phone,jdbcType=VARCHAR},
|
</if>
|
<if test="sex != null">
|
sex = #{sex,jdbcType=VARCHAR},
|
</if>
|
<if test="type != null">
|
type = #{type,jdbcType=VARCHAR},
|
</if>
|
<if test="no != null">
|
no = #{no,jdbcType=VARCHAR},
|
</if>
|
<if test="eMail != null">
|
eMail = #{eMail,jdbcType=VARCHAR},
|
</if>
|
<if test="telPhone != null">
|
telPhone = #{telPhone,jdbcType=VARCHAR},
|
</if>
|
<if test="headImgUrl != null">
|
headImgUrl = #{headImgUrl,jdbcType=VARCHAR},
|
</if>
|
<if test="qrCode != null">
|
qrCode = #{qrCode,jdbcType=VARCHAR},
|
</if>
|
<if test="idCard != null">
|
idCard = #{idCard,jdbcType=VARCHAR},
|
</if>
|
<if test="userType != null">
|
userType = #{userType,jdbcType=VARCHAR},
|
</if>
|
<if test="dataScope != null">
|
dataScope = #{dataScope,jdbcType=VARCHAR},
|
</if>
|
<if test="enabled != null">
|
enabled = #{enabled,jdbcType=VARCHAR},
|
</if>
|
<if test="delFlag != null">
|
delFlag = #{delFlag,jdbcType=VARCHAR},
|
</if>
|
<if test="createTime != null">
|
createTime = #{createTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="updateTime != null">
|
updateTime = #{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
</set>
|
where id = #{id,jdbcType=INTEGER}
|
</update>
|
</mapper>
|