Files
faw-report-library-boot/adc-da-sys/target/classes/mybatis/mapper/sys/mysql/UserEOMapper.xml
T
2022-08-31 14:06:07 +08:00

165 lines
6.3 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.adc.da.sys.dao.mysql.UserEODao">
<select id="list" parameterType="string" resultType="map">
select * from(select t1.USID,t1.ACCOUNT,t1.USNAME,t1.CELLPHONE_NUMBER,t1.EMAIL,t1.ISUSE,t1.DEPARTMENT,t3.NAME ROLENAME,t3.id ROLEID,
date_format(t1.UPDATE_TIME,'%Y-%m-%d %H:%i:%S')CREATEDATE from TS_USER t1
left join TR_USER_ROLE t2 on t1.USID=t2.USER_ID
left JOIN TS_ROLE t3 on t2.ROLE_ID=t3.ID
where t1.del_flag='0'
<if test="account !='' and account !=null">
and t1.ACCOUNT like "%"#{account}"%"
</if>
<if test="roleName !='' and roleName !=null">
and t3.NAME like "%"#{roleName}"%"
</if>
ORDER BY t1.UPDATE_TIME DESC)tt
</select>
<select id="getUserPage" resultType="com.adc.da.sys.vo.ddm.DdmUserVO">
select t1.USID userId,t1.ACCOUNT userAccount,t1.USNAME userName,t1.CELLPHONE_NUMBER,t1.EMAIL,t1.ISUSE,t1.DEPARTMENT,
date_format(t1.UPDATE_TIME,'%Y-%m-%d %H:%i:%S')CREATEDATE from TS_USER t1
where t1.del_flag='0'
<if test="userAccount !='' and userAccount !=null">
and t1.ACCOUNT like "%"#{userAccount}"%"
</if>
<if test="userName !='' and userName !=null">
and t1.USNAME like "%"#{userName}"%"
</if>
ORDER BY t1.UPDATE_TIME DESC
</select>
<select id="getUserCount" resultType="java.lang.Long">
select count(*) from TS_USER t1
where t1.del_flag='0'
<if test="userAccount !='' and userAccount !=null">
and t1.ACCOUNT like "%"#{userAccount}"%"
</if>
<if test="userName !='' and userName !=null">
and t1.USNAME like "%"#{userName}"%"
</if>
</select>
<!-- Result Map -->
<resultMap id="BaseResultMap" type="com.adc.da.sys.entity.UserEO">
<id column="usid" property="usid"/>
<result column="account" property="account"/>
<result column="del_flag" property="delFlag"/>
<result column="password" property="password"/>
<result column="CELLPHONE_NUMBER" property="cellPhoneNumber"/>
<result column="EMAIL" property="email"/>
<result column="CREATE_TIME" property="createTime"/>
</resultMap>
<resultMap id="UserRoleMap" extends="BaseResultMap" type="com.adc.da.sys.entity.UserEO">
<result column="department" property="department"></result>
<result column="usname" property="usname"></result>
<result column="isuse" property="isUse"></result>
<collection property = "roleIdList" ofType="string">
<id column="id" />
</collection>
<collection property="roleEOList" ofType="com.adc.da.sys.entity.RoleEO">
<id column="id" property="id"/>
<result column="data_scope" property="dataScope"/>
<result column="r_delFlag" property="delFlag"/>
<result column="is_default" property="isDefault"/>
<result column="name" property="name"/>
<result column="remarks" property="remarks"/>
</collection>
</resultMap>
<!---->
<sql id="User_Role_List">
u.*, r.id as id,
r.data_scope as dataScope,
r.del_flag as r_delFlag,
r.is_default as isDefault,
r.name as name,
r.remarks as remarks
</sql>
<!--获取用户角色信息-->
<select id="getUserWithRoles" resultMap="UserRoleMap" parameterType="java.lang.String">
select
<include refid="User_Role_List"/>
from TS_USER u
left join TR_USER_ROLE ur on u.usid = ur.user_id
left join TS_ROLE r on ur.role_id = r.id
where u.usid = #{id}
</select>
<!-- TS_USER table all fields -->
<sql id="Base_Column_List">
distinct(usid), account, del_flag, password,CELLPHONE_NUMBER,
EMAIL,CREATE_TIME
</sql>
<!-- 根据account获取未逻辑删除的UserEO -->
<select id="getUserEOByAccountNotDeleted" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from TS_USER where account = #{account} and del_flag != 1 and isuse=1
</select>
<insert id="insertUserBatch" parameterType="list">
insert into TS_USER(USID,ACCOUNT,DEL_FLAG,PASSWORD,USNAME,CELLPHONE_NUMBER,EMAIL,CREATE_TIME,UPDATE_TIME,ISUSE,DEPARTMENT,ISSELF) values
<foreach collection="userEOList" item="user" separator=",">
(#{user.usid},#{user.account},#{user.delFlag},#{user.password},#{user.usname},#{user.cellPhoneNumber},#{user.email},#{user.createTime},#{user.updateTime},#{user.isUse},#{user.department},#{user.isSelf})
</foreach>
</insert>
<select id="getDdmUserEOByAccountNotDeleted" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from TS_USER where account = #{account} and del_flag != 1
</select>
<select id="getUserByMail" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from TS_USER
WHERE EMAIL in
<foreach collection="mailList" item="mail" open="(" separator="," close=")">
#{mail}
</foreach>
</select>
<select id="allList" resultType="java.util.Map">
select * from(select t1.USID,t1.ACCOUNT,t1.USNAME,t1.CELLPHONE_NUMBER,t1.EMAIL,t1.ISUSE,t1.DEPARTMENT,t3.NAME ROLENAME,t3.id ROLEID,
date_format(t1.UPDATE_TIME,'%Y-%m-%d %H:%i:%S')CREATEDATE from TS_USER t1
left join TR_USER_ROLE t2 on t1.USID=t2.USER_ID
left JOIN TS_ROLE t3 on t2.ROLE_ID=t3.ID
where t1.del_flag='0'
<if test="account !='' and account !=null">
and t1.ACCOUNT like "%"#{account}"%"
</if>
<if test="roleName !='' and roleName !=null">
and t3.NAME like "%"#{roleName}"%"
</if>
ORDER BY t1.UPDATE_TIME DESC)tt
</select>
<select id="getUserByAccount" resultType="com.adc.da.sys.entity.UserEO">
select
ACCOUNT,USNAME,DEPARTMENT
from TS_USER
WHERE ACCOUNT in
<foreach collection="accountList" item="account" open="(" separator="," close=")">
#{account}
</foreach>
</select>
</mapper>