<?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.landtool.lanbase.modules.org.dao.OrgUserDao">
|
|
<!-- 可根据自己的需求,是否要使用 -->
|
<resultMap type="com.landtool.lanbase.modules.org.entity.OrgUser" id="userMap">
|
<result property="userid" column="USERID"/>
|
<result property="loginname" column="LOGINNAME"/>
|
<result property="password" column="PASSWORD"/>
|
<result property="chinesename" column="CHINESENAME"/>
|
<result property="spellfirst" column="SPELLFIRST"/>
|
<result property="userstatus" column="USERSTATUS"/>
|
<result property="mobileno" column="MOBILENO"/>
|
<result property="isreceivemsg" column="ISRECEIVEMSG"/>
|
<result property="officetel" column="OFFICETEL"/>
|
<result property="email" column="EMAIL"/>
|
<result property="address" column="ADDRESS"/>
|
<result property="idcard" column="IDCARD"/>
|
<result property="nativeplace" column="NATIVEPLACE"/>
|
<result property="sex" column="SEX"/>
|
<result property="photourl" column="PHOTOURL"/>
|
<result property="education" column="EDUCATION"/>
|
<result property="speciality" column="SPECIALITY"/>
|
<result property="jobtitle" column="JOBTITLE"/>
|
<result property="joblevel" column="JOBLEVEL"/>
|
<result property="rcreateuser" column="RCREATEUSER"/>
|
<result property="rcreatedate" column="RCREATEDATE"/>
|
<result property="rlasteditdate" column="RLASTEDITDATE"/>
|
<result property="remark" column="REMARK"/>
|
<!-- <result property="salt" column="SALT"/> -->
|
<result property="systemName" column="SYSTEMNAME"/>
|
<result property="certificateurl" column="CERTIFICATEURL"/>
|
</resultMap>
|
|
<resultMap type="com.landtool.lanbase.modules.org.entity.OrgUserJoinUnit" id="UserJoinUnit">
|
<id property="userid" column="USERID"/>
|
<result property="loginname" column="LOGINNAME"/>
|
<result property="password" column="PASSWORD"/>
|
<result property="chinesename" column="CHINESENAME"/>
|
<result property="spellfirst" column="SPELLFIRST"/>
|
<result property="userstatus" column="USERSTATUS"/>
|
<result property="mobileno" column="MOBILENO"/>
|
<result property="isreceivemsg" column="ISRECEIVEMSG"/>
|
<result property="officetel" column="OFFICETEL"/>
|
<result property="email" column="EMAIL"/>
|
<result property="address" column="ADDRESS"/>
|
<result property="idcard" column="IDCARD"/>
|
<result property="nativeplace" column="NATIVEPLACE"/>
|
<result property="sex" column="SEX"/>
|
<result property="photourl" column="PHOTOURL"/>
|
<result property="education" column="EDUCATION"/>
|
<result property="speciality" column="SPECIALITY"/>
|
<result property="jobtitle" column="JOBTITLE"/>
|
<result property="joblevel" column="JOBLEVEL"/>
|
<result property="rcreateuser" column="RCREATEUSER"/>
|
<result property="rcreatedate" column="RCREATEDATE"/>
|
<result property="rlasteditdate" column="RLASTEDITDATE"/>
|
<result property="remark" column="REMARK"/>
|
<!-- <result property="salt" column="SALT"/> -->
|
<result property="certificateurl" column="CERTIFICATEURL"/>
|
<collection property="orguserunits" ofType="com.landtool.lanbase.modules.org.entity.OrgUserunit" resultMap="com.landtool.lanbase.modules.org.dao.OrgUserunitDao.userunitMap"/>
|
<collection property="orgusergroup" ofType="com.landtool.lanbase.modules.org.entity.OrgUserGroup" resultMap="com.landtool.lanbase.modules.org.dao.OrgUserGroupDao.usergroupMap"/>
|
|
</resultMap >
|
|
<resultMap type="com.landtool.lanbase.modules.org.entity.OrgUserWithUnitCell" id="userUnitCell">
|
<result property="userid" column="USERID"/>
|
<result property="loginname" column="LOGINNAME"/>
|
<result property="chinesename" column="CHINESENAME"/>
|
<result property="userstatus" column="USERSTATUS"/>
|
<result property="mobileno" column="MOBILENO"/>
|
<result property="isreceivemsg" column="ISRECEIVEMSG"/>
|
<result property="rcreateuser" column="RCREATEUSER"/>
|
<result property="rcreatedate" column="RCREATEDATE"/>
|
<result property="unitnames" column="UNITNAMES"/>
|
<result property="joblevel" column="JOBLEVEL"/>
|
</resultMap>
|
|
<sql id="userColumns">
|
ou.USERID,ou.LOGINNAME,ou.PASSWORD,ou.CHINESENAME,ou.SPELLFIRST,ou.USERSTATUS,ou.MOBILENO,ou.ISRECEIVEMSG,
|
ou.OFFICETEL,ou.EMAIL,ou.ADDRESS,ou.IDCARD,ou.NATIVEPLACE,ou.SEX,ou.PHOTOURL,ou.certificateurl,
|
ou.EDUCATION,ou.SPECIALITY,ou.JOBTITLE,ou.JOBLEVEL,ou.RCREATEUSER,ou.RCREATEDATE,ou.RLASTEDITDATE,ou.REMARK
|
<!-- ou.SALT -->
|
</sql>
|
|
<sql id="userUnitColumns">
|
ou2.unitid,ou2.posname,ou2.workseasdate,ou2.worktype,ou2.workstartdate,ou2.workenddate
|
</sql>
|
|
<sql id="userGroupColumns">
|
ou3.userId,ou3.groupId,ou3.createUnitId,ou3.rCreateDate,ou3.rCreateUser
|
</sql>
|
|
<select id="queryObject" resultType="com.landtool.lanbase.modules.org.entity.OrgUser">
|
select * from ORG_USER where USERID = #{value}
|
</select>
|
|
<select id="queryList" resultType="com.landtool.lanbase.modules.org.entity.OrgUser">
|
SELECT *
|
FROM(
|
SELECT ROW_NUMBER() OVER(ORDER BY B.userid) AS rownumber,B.*
|
FROM (
|
select * from ORG_USER us
|
<where>
|
<if test="loginname != null and loginname != ''">
|
AND us.LOGINNAME LIKE ('%' || #{loginname} || '%')
|
</if>
|
<if test="userstatus != null and userstatus != ''">
|
AND cast(us.USERSTATUS as varchar) = #{userstatus}
|
</if>
|
<if test="chinesename != null and chinesename != ''">
|
AND us.CHINESENAME LIKE ('%' || #{chinesename} || '%')
|
</if>
|
<if test="unitname != null and unitname != ''">
|
AND exists(select ut.userid from ORG_USERUNIT ut JOIN ORG_UNIT un on un.unitid = ut.unitid where us.userid = ut.userid and (un.UNITNAME LIKE ('%' || #{unitname} || '%') or LOWER(un.spellfirst) LIKE ('%' || LOWER(#{unitname}) || '%'))
|
</if>
|
</where>
|
) B
|
) A
|
WHERE rownumber > #{lowerOffset} AND <![CDATA[ rownumber <= ${upperOffset} ]]>
|
</select>
|
|
<select id="queryTotal" resultType="int">
|
SELECT
|
COUNT(*)
|
FROM ORG_USER us
|
LEFT JOIN (
|
SELECT
|
ouu.USERID,
|
max(ou.UNITNAME) AS UNITNAMES,
|
max(ouu.RCREATEDATE) AS RCREATEDATE
|
FROM ORG_USERUNIT ouu
|
LEFT JOIN ORG_UNIT ou ON ouu.unitid=ou.unitid
|
GROUP BY ouu.USERID
|
)b ON us.USERID = b.USERID
|
<where>
|
<if test="loginname != null and loginname != ''">
|
AND us.LOGINNAME LIKE ('%' || #{loginname} || '%')
|
</if>
|
<if test="userstatus != null and userstatus != ''">
|
AND cast(us.USERSTATUS as varchar) = #{userstatus}
|
</if>
|
<if test="chinesename != null and chinesename != ''">
|
AND (us.CHINESENAME LIKE ('%' || #{chinesename} || '%') or us.LOGINNAME LIKE ('%' || #{chinesename} || '%') or LOWER(us.spellfirst) LIKE ('%' || LOWER(#{chinesename}) || '%'))
|
</if>
|
<if test="unitname != null and unitname != ''">
|
AND exists(select ut.userid from ORG_USERUNIT ut JOIN ORG_UNIT un on un.unitid = ut.unitid where us.userid = ut.userid and (un.UNITNAME LIKE ('%' || #{unitname} || '%') or LOWER(un.spellfirst) LIKE ('%' || LOWER(#{unitname}) || '%')))
|
</if>
|
</where>
|
</select>
|
|
<insert id="save" parameterType="com.landtool.lanbase.modules.org.entity.OrgUser">
|
insert into ORG_USER
|
(
|
LOGINNAME,
|
PASSWORD,
|
CHINESENAME,
|
SPELLFIRST,
|
USERSTATUS,
|
MOBILENO,
|
ISRECEIVEMSG,
|
OFFICETEL,
|
EMAIL,
|
ADDRESS,
|
IDCARD,
|
NATIVEPLACE,
|
SEX,
|
PHOTOURL,
|
EDUCATION,
|
SPECIALITY,
|
JOBTITLE,
|
JOBLEVEL,
|
RCREATEUSER,
|
RCREATEDATE,
|
RLASTEDITDATE,
|
REMARK,
|
certificateurl,
|
isfirstlogin
|
<if test="fromsys != null and fromsys !=''" >
|
,FROMSYS
|
</if>
|
|
<!-- SALT -->
|
)
|
values
|
(
|
#{loginname},
|
#{password},
|
#{chinesename},
|
#{spellfirst},
|
#{userstatus},
|
#{mobileno,jdbcType=VARCHAR},
|
#{isreceivemsg},
|
#{officetel,jdbcType=VARCHAR},
|
#{email,jdbcType=VARCHAR},
|
#{address,jdbcType=VARCHAR},
|
#{idcard,jdbcType=VARCHAR},
|
#{nativeplace,jdbcType=VARCHAR},
|
#{sex,jdbcType=NUMERIC},
|
#{photourl,jdbcType=VARCHAR},
|
#{education,jdbcType=VARCHAR},
|
#{speciality,jdbcType=VARCHAR},
|
#{jobtitle,jdbcType=BIGINT},
|
#{joblevel,jdbcType=VARCHAR},
|
#{rcreateuser},
|
#{rcreatedate},
|
#{rlasteditdate},
|
#{remark,jdbcType=VARCHAR},
|
#{certificateurl,jdbcType=VARCHAR},
|
#{isfirstlogin,jdbcType=BIGINT}
|
<if test="fromsys != null and fromsys !=''" >
|
,#{fromsys,jdbcType=VARCHAR}
|
</if>
|
<!-- #{salt,jdbcType=VARCHAR} -->
|
)
|
</insert>
|
|
<insert id="saveBatch" parameterType="java.util.List">
|
insert into ORG_USER
|
(
|
USERID,
|
LOGINNAME,
|
PASSWORD,
|
CHINESENAME,
|
SPELLFIRST,
|
USERSTATUS,
|
MOBILENO,
|
ISRECEIVEMSG,
|
OFFICETEL,
|
EMAIL,
|
ADDRESS,
|
IDCARD,
|
NATIVEPLACE,
|
SEX,
|
PHOTOURL,
|
EDUCATION,
|
SPECIALITY,
|
JOBTITLE,
|
JOBLEVEL,
|
RCREATEUSER,
|
RCREATEDATE,
|
RLASTEDITDATE,
|
REMARK,
|
certificateurl
|
<if test="fromsys != null and fromsys !=''" >
|
,FROMSYS
|
</if>
|
<!-- SALT -->
|
)
|
SELECT nextval('ORG_USER_SEQ') as USERID, a.* from(
|
<foreach item="item" collection="list" index="index" separator="union all" >
|
select
|
#{item.loginname},
|
#{item.password},
|
#{item.chinesename},
|
#{item.spellfirst},
|
#{item.userstatus},
|
#{item.mobileno,jdbcType=VARCHAR},
|
#{item.isreceivemsg},
|
#{item.officetel,jdbcType=VARCHAR},
|
#{item.email,jdbcType=VARCHAR},
|
#{item.address,jdbcType=VARCHAR},
|
#{item.idcard,jdbcType=VARCHAR},
|
#{item.nativeplace,jdbcType=VARCHAR},
|
#{item.sex,jdbcType=VARCHAR},
|
#{item.photourl,jdbcType=VARCHAR},
|
#{item.education,jdbcType=VARCHAR},
|
#{item.speciality,jdbcType=VARCHAR},
|
#{item.jobtitle,jdbcType=VARCHAR},
|
#{item.joblevel,jdbcType=VARCHAR},
|
#{item.rcreateuser},
|
#{item.rcreatedate},
|
#{item.rlasteditdate},
|
#{item.remark,jdbcType=VARCHAR},
|
#{item.certificateurl,jdbcType=VARCHAR}
|
<if test="fromsys != null and fromsys !=''" >
|
,#{item.fromsys,jdbcType=VARCHAR}
|
</if>
|
from dual
|
</foreach>)a
|
</insert>
|
|
<update id="update" parameterType="com.landtool.lanbase.modules.org.entity.OrgUser">
|
update ORG_USER
|
<set>
|
<if test="loginname != null">LOGINNAME = #{loginname}, </if>
|
<if test="password != null">PASSWORD = #{password}, </if>
|
<if test="chinesename != null">CHINESENAME = #{chinesename}, </if>
|
<if test="spellfirst != null">SPELLFIRST = #{spellfirst}, </if>
|
<if test="userstatus != null">USERSTATUS = #{userstatus}, </if>
|
<if test="mobileno != null">MOBILENO = #{mobileno}, </if>
|
<if test="isreceivemsg != null">ISRECEIVEMSG = #{isreceivemsg}, </if>
|
<if test="officetel != null">OFFICETEL = #{officetel}, </if>
|
<if test="email != null">EMAIL = #{email}, </if>
|
<if test="address != null">ADDRESS = #{address}, </if>
|
<if test="idcard != null">IDCARD = #{idcard}, </if>
|
<if test="nativeplace != null">NATIVEPLACE = #{nativeplace}, </if>
|
<if test="sex != null">SEX = #{sex}, </if>
|
<if test="photourl != null">PHOTOURL = #{photourl}, </if>
|
<if test="education != null">EDUCATION = #{education}, </if>
|
<if test="speciality != null">SPECIALITY = #{speciality}, </if>
|
<if test="jobtitle != null">JOBTITLE = #{jobtitle}, </if>
|
<if test="joblevel != null">JOBLEVEL = #{joblevel}, </if>
|
<if test="rcreateuser != null">RCREATEUSER = #{rcreateuser}, </if>
|
<if test="rcreatedate != null">RCREATEDATE = #{rcreatedate}, </if>
|
<if test="rlasteditdate != null">RLASTEDITDATE = #{rlasteditdate}, </if>
|
<if test="remark != null">REMARK = #{remark}, </if>
|
<if test="certificateurl != null">CERTIFICATEURL = #{certificateurl}</if>
|
<!-- <if test="salt != null">SALT = #{salt}</if> -->
|
</set>
|
where USERID = #{userid}
|
</update>
|
|
<update id="updateStatus" parameterType="com.landtool.lanbase.modules.org.entity.OrgUser">
|
update ORG_USER
|
<set>
|
<if test="loginname != null">LOGINNAME = #{loginname}, </if>
|
<if test="password != null">PASSWORD = #{password}, </if>
|
<if test="chinesename != null">CHINESENAME = #{chinesename}, </if>
|
<if test="spellfirst != null">SPELLFIRST = #{spellfirst}, </if>
|
<if test="userstatus != null">USERSTATUS = #{userstatus}, </if>
|
<if test="mobileno != null">MOBILENO = #{mobileno}, </if>
|
<if test="isreceivemsg != null">ISRECEIVEMSG = #{isreceivemsg}, </if>
|
<if test="officetel != null">OFFICETEL = #{officetel}, </if>
|
<if test="email != null">EMAIL = #{email}, </if>
|
<if test="address != null">ADDRESS = #{address}, </if>
|
<if test="idcard != null">IDCARD = #{idcard}, </if>
|
<if test="nativeplace != null">NATIVEPLACE = #{nativeplace}, </if>
|
<if test="sex != null">SEX = #{sex}, </if>
|
<if test="photourl != null">PHOTOURL = #{photourl}, </if>
|
<if test="education != null">EDUCATION = #{education}, </if>
|
<if test="speciality != null">SPECIALITY = #{speciality}, </if>
|
<if test="jobtitle != null">JOBTITLE = #{jobtitle}, </if>
|
<if test="joblevel != null">JOBLEVEL = #{joblevel}, </if>
|
<if test="rcreateuser != null">RCREATEUSER = #{rcreateuser}, </if>
|
<if test="rcreatedate != null">RCREATEDATE = #{rcreatedate}, </if>
|
<if test="rlasteditdate != null">RLASTEDITDATE = #{rlasteditdate}, </if>
|
<if test="remark != null">REMARK = #{remark}, </if>
|
<if test="certificateurl != null">CERTIFICATEURL = #{certificateurl}</if>
|
<!-- <if test="salt != null">SALT = #{salt}</if> -->
|
</set>
|
where USERID = #{userid}
|
</update>
|
|
|
|
<delete id="delete">
|
delete from ORG_USER where USERID = #{value}
|
</delete>
|
|
<delete id="deleteBatch">
|
delete from ORG_USER where USERID in
|
<foreach item="userid" collection="array" open="(" separator="," close=")">
|
#{userid}
|
</foreach>
|
</delete>
|
|
<select id="queryListForBareAPIwithUnit" resultType="com.landtool.lanbase.modules.org.entity.OrgUser">
|
SELECT
|
<include refid="userColumns"/>
|
FROM ORG_USER ou
|
LEFT JOIN ORG_USERUNIT ou2 ON ou.USERID = ou2.USERID
|
LEFT JOIN ORG_UNIT ou3 ON ou3.UNITID=ou2.UNITID
|
<if test="xzqhId != null">
|
LEFT JOIN ORG_UNITREGION ou4 ON ou3.UNITID = ou4.UNITID
|
LEFT JOIN ORG_REGION ox ON ou4.regionid = ox.regionid
|
</if>
|
WHERE 1=1
|
<if test="xzqhId != null"> AND ou4.regionid = #{xzqhId} </if>
|
<if test="unitId != null"> AND ou3.UNITID = #{unitId} </if>
|
</select>
|
|
<select id="queryListForBareAPIwithRole" resultType="com.landtool.lanbase.modules.org.entity.OrgUser">
|
SELECT
|
<include refid="userColumns"/>
|
FROM ORG_USER ou
|
LEFT JOIN ORG_USERGROUP oug ON ou.userid = oug.userid
|
LEFT JOIN ORG_GROUP og ON og.groupid = oug.groupid
|
LEFT JOIN SYS_ROLEGROUP srr ON srr.groupid = og.groupid
|
LEFT JOIN SYS_ROLE sr ON sr.ROLEID = srr.ROLEID
|
LEFT JOIN SYS_SYSTEMINFO ss ON ss.APPID = sr.APPID
|
WHERE 1=1
|
<if test="appId != null"> AND ss.APPID = #{appId} </if>
|
</select>
|
|
<select id="queryListByTime" resultType="com.landtool.lanbase.modules.org.entity.OrgUser">
|
SELECT
|
<include refid="userColumns"/>
|
FROM ORG_USER ou
|
WHERE ou.RLASTEDITDATE > #{time}
|
</select>
|
|
<select id="queryObjectJoinUnit" resultMap="UserJoinUnit">
|
SELECT
|
<include refid="userColumns"/>,
|
<include refid="userUnitColumns"/>,
|
<include refid="userGroupColumns"/>
|
FROM ORG_USER ou
|
LEFT JOIN ORG_USERUNIT ou2 ON ou2.USERID=ou.USERID
|
LEFT JOIN ORG_USERGROUP ou3 ON ou3.USERID=ou.USERID
|
WHERE ou.USERID = #{userId}
|
</select>
|
|
<select id="queryObjectJoinUnitByLoginname" resultMap="UserJoinUnit">
|
SELECT
|
<include refid="userColumns"/>,
|
<include refid="userUnitColumns"/>,
|
<include refid="userGroupColumns"/>
|
FROM ORG_USER ou
|
LEFT JOIN ORG_USERUNIT ou2 ON ou2.USERID=ou.USERID
|
LEFT JOIN ORG_USERGROUP ou3 ON ou3.USERID=ou.USERID
|
WHERE ou.loginname = #{loginname} limit 1
|
</select>
|
|
<select id="queryListWithUnitNames" resultMap="userUnitCell">
|
with RECURSIVE tab(unitid,RCREATEUSER) as ( select unitid,RCREATEUSER from ORG_UNIT where unitid = #{unitid} union all select b.unitid,b.RCREATEUSER from tab a, ORG_UNIT b where b.parentid = a.unitid )
|
select * from (
|
SELECT *
|
FROM(
|
SELECT ROW_NUMBER() OVER(ORDER BY rcreatedate DESC) AS rownumber,C.*
|
FROM (
|
|
SELECT
|
us.USERID,
|
us.LOGINNAME,
|
us.CHINESENAME,
|
us.USERSTATUS,
|
us.MOBILENO,
|
us.ISRECEIVEMSG,
|
us.RCREATEUSER,
|
us.RCREATEDATE,
|
b.UNITNAMES,
|
us.JOBLEVEL,
|
b.deptname
|
FROM ORG_USER us
|
LEFT JOIN (
|
SELECT
|
ouu.USERID,
|
max(ou.UNITNAME) AS UNITNAMES,
|
max(ou1.UNITNAME) as deptname,
|
max(ouu.RCREATEDATE) AS RCREATEDATE
|
FROM ORG_USERUNIT ouu
|
LEFT JOIN ORG_UNIT ou ON ouu.unitid=ou.unitid
|
LEFT JOIN ORG_UNIT ou1 ON ou1.unitid = ouu.deptid
|
where ouu.worktype = '1'
|
GROUP BY ouu.USERID
|
)b ON us.USERID = b.USERID
|
where 1 = 1
|
<if test="isadmin != 1">
|
AND (us.USERID =#{userid} or us.rcreateuser = #{userid} or exists(select ut.userid from ORG_USERUNIT ut
|
where us.userid = ut.userid
|
and ut.unitid in (select unitid from tab)))
|
</if>
|
<if test="loginname != null and loginname != ''">
|
AND us.LOGINNAME LIKE ('%' || #{loginname} || '%')
|
</if>
|
<if test="userstatus != null and userstatus != ''">
|
AND cast(us.USERSTATUS as varchar) = #{userstatus}
|
</if>
|
<if test="chinesename != null and chinesename != ''">
|
AND (us.CHINESENAME LIKE ('%' || #{chinesename} || '%') or us.LOGINNAME LIKE ('%' || #{chinesename} || '%') or LOWER(us.spellfirst) LIKE ('%' || LOWER(#{chinesename}) || '%'))
|
</if>
|
<if test="unitname != null and unitname != ''">
|
AND exists(select ut.userid from ORG_USERUNIT ut JOIN ORG_UNIT un on un.unitid = ut.unitid where us.userid = ut.userid and (un.UNITNAME LIKE ('%' || #{unitname} || '%') or LOWER(un.spellfirst) LIKE ('%' || LOWER(#{unitname}) || '%') ) )
|
</if>
|
|
) C
|
) A
|
WHERE rownumber > #{lowerOffset} AND <![CDATA[ rownumber <= ${upperOffset} ]]>
|
)a order by
|
<choose>
|
<when test="sidx != null and sidx != ''">
|
${sidx} ${order}
|
</when>
|
<otherwise>
|
rcreatedate DESC
|
</otherwise>
|
</choose>
|
</select>
|
|
<select id="queryTotalWithUnitNames" resultType="int">
|
with RECURSIVE tab(unitid,RCREATEUSER) as ( select unitid,RCREATEUSER from ORG_UNIT where unitid = #{unitid} union all select b.unitid,b.RCREATEUSER from tab a, ORG_UNIT b where b.parentid = a.unitid )
|
SELECT count(*)
|
FROM(
|
SELECT ROW_NUMBER() OVER(ORDER BY C.userid) AS rownumber,C.*
|
FROM (
|
|
SELECT
|
us.USERID,
|
us.LOGINNAME,
|
us.CHINESENAME,
|
us.USERSTATUS,
|
us.MOBILENO,
|
us.ISRECEIVEMSG,
|
us.RCREATEUSER,
|
us.RCREATEDATE,
|
b.UNITNAMES,
|
us.JOBLEVEL
|
FROM ORG_USER us
|
LEFT JOIN (
|
SELECT
|
ouu.USERID,
|
max(ou.UNITNAME) AS UNITNAMES,
|
max(ouu.RCREATEDATE) AS RCREATEDATE
|
FROM ORG_USERUNIT ouu
|
LEFT JOIN ORG_UNIT ou ON ouu.unitid=ou.unitid
|
GROUP BY ouu.USERID
|
)b ON us.USERID = b.USERID
|
where 1 = 1
|
<if test="isadmin != 1">
|
AND (us.USERID =#{userid} or us.rcreateuser = #{userid} or exists(select ut.userid from ORG_USERUNIT ut
|
where us.userid = ut.userid
|
and ut.unitid in (select unitid from tab)))
|
</if>
|
<if test="loginname != null and loginname != ''">
|
AND us.LOGINNAME LIKE ('%' || #{loginname} || '%')
|
</if>
|
<if test="userstatus != null and userstatus != ''">
|
AND cast(us.USERSTATUS as varchar) = #{userstatus}
|
</if>
|
<if test="chinesename != null and chinesename != ''">
|
AND (us.CHINESENAME LIKE ('%' || #{chinesename} || '%') or us.LOGINNAME LIKE ('%' || #{chinesename} || '%') or LOWER(us.spellfirst) LIKE ('%' || LOWER(#{chinesename}) || '%'))
|
</if>
|
<if test="unitname != null and unitname != ''">
|
AND exists(select ut.userid from ORG_USERUNIT ut JOIN ORG_UNIT un on un.unitid = ut.unitid where us.userid = ut.userid and (un.UNITNAME LIKE ('%' || #{unitname} || '%') or LOWER(un.spellfirst) LIKE ('%' || LOWER(#{unitname}) || '%')))
|
</if>
|
|
) C
|
) A
|
</select>
|
|
<select id="queryByUserName" resultType="com.landtool.lanbase.modules.org.entity.OrgUser" >
|
select * from ORG_USER where LOGINNAME = #{value}
|
</select>
|
|
<select id="queryObjectJoinUnitByChineseName" resultMap="UserJoinUnit">
|
select * from ORG_USER where chinesename= #{value}
|
</select>
|
|
<select id="queryUserWithSEQ" resultType="int">
|
SELECT currval('ORG_USER_SEQ') FROM DUAL
|
</select>
|
|
<select id="findUserByWord" resultType="com.landtool.lanbase.modules.org.entity.OrgUser">
|
select userid,chinesename from ORG_USER
|
<where>
|
<if test="keyWord != null and keyWord != ''">
|
LOGINNAME LIKE ('%' || #{keyWord} || '%')
|
or CHINESENAME LIKE ('%' || #{keyWord} || '%')
|
or LOWER(SPELLFIRST) LIKE ('%' || LOWER(#{keyWord}) || '%')
|
</if>
|
</where>
|
</select>
|
|
<update id="updateStatusByUserId" parameterType="com.landtool.lanbase.modules.org.entity.OrgUser">
|
update ORG_USER
|
<set>
|
<if test="userStatus != null">USERSTATUS = #{userStatus},RLASTEDITDATE=now()</if>
|
</set>
|
where USERID = #{userId}
|
</update>
|
|
<update id="updatePassword" parameterType="com.landtool.lanbase.modules.org.entity.OrgUser">
|
UPDATE ORG_USER SET password = #{newPassword}
|
WHERE USERID = #{userId} AND PASSWORD = #{password}
|
</update>
|
|
<!-- 查询用户的所有菜单ID -->
|
<select id="queryAllMenuId" resultType="long">
|
select distinct rm.menu_id from SYS_USER_ROLE ur
|
LEFT JOIN SYS_ROLE_MENU rm on ur.role_id = rm.role_id
|
where ur.user_id = #{userId}
|
</select>
|
|
<select id="querySpellFirst" parameterType="java.lang.Integer" resultType="java.lang.String">
|
<!-- alert 数据库中存在大小写的拼音,导致首字母重复 -->
|
select UPPER(spellfirst) as spellfirst from
|
(
|
select UPPER(SUBSTR(spellfirst,1,1)) as spellfirst from ORG_USER
|
where userid not in(#{userid}) and userstatus = 0 and userstatus is not null group by UPPER(SUBSTR(spellfirst,1,1))
|
)a order by a.spellfirst
|
|
<!--select UPPER(spellfirst) as spellfirst from
|
(
|
select SUBSTR(spellfirst,1,1) as spellfirst from ORG_USER
|
where userid not in(#{userid}) and userstatus = 0 and userstatus is not null group by SUBSTR(spellfirst,1,1)
|
)a order by a.spellfirst -->
|
</select>
|
|
<select id="queryListOrderByType" resultType="com.landtool.lanbase.modules.org.entity.OrgUser" >
|
select * from ORG_USER a
|
<if test="unitspellfirst != null and unitspellfirst != ''">
|
left join ORG_USERUNIT b on a.userid = b.userid
|
left join ORG_UNIT c on b.unitid = c.unitid
|
</if>
|
<if test="rolename != null and rolename != ''">
|
left join ORG_USERGROUP b on a.userid = b.userid
|
left join SYS_ROLEGROUP c on b.groupid = c.groupid
|
left join SYS_ROLE d on c.roleid = d.roleid
|
</if>
|
where 1 = 1 and a.userid not in(#{userid}) and a.userstatus = 0
|
<if test="spellfirst != null and spellfirst != ''">
|
AND a.spellfirst LIKE ('' || #{spellfirst} || '%')
|
</if>
|
<choose>
|
<when test="unitspellfirst != null and unitspellfirst == '-1'">
|
AND c.unitid is null order by a.spellfirst
|
</when>
|
<when test="unitspellfirst != null and unitspellfirst != ''">
|
AND c.unitid = #{unitspellfirst}
|
</when>
|
</choose>
|
<choose>
|
<when test="rolename != null and rolename == '-1'">
|
AND d.rolename is null order by a.spellfirst
|
</when>
|
<when test="rolename != null and rolename != ''">
|
AND d.rolename is not null AND d.rolename = #{rolename}
|
</when>
|
</choose>
|
</select>
|
|
<select id="queryUserUnitSpellFirst" parameterType="java.lang.Integer" resultType="java.lang.String">
|
select d.unitname from(
|
select distinct SUBSTR(c.spellfirst,1,1) as spellfirst,
|
to_char(c.unitid)||'_'||c.unitname as unitname
|
from ORG_USER a
|
left join ORG_USERUNIT b on a.userid = b.userid
|
left join ORG_UNIT c on b.unitid = c.unitid
|
where a.userid not in(#{userid}) and a.userstatus = 0 and c.unitid is not null
|
) d order by d.spellfirst
|
</select>
|
|
<select id="queryUserRoleName" parameterType="java.lang.Integer" resultType="java.lang.String">
|
select rolename from ORG_USER a
|
left join ORG_USERGROUP b on a.userid = b.userid
|
left join SYS_ROLEGROUP c on b.groupid = c.groupid
|
left join SYS_ROLE d on c.roleid = d.roleid
|
where a.userid not in(#{userid}) and a.userstatus = 0 group by d.rolename order by d.rolename
|
</select>
|
|
<select id="queryAllList" resultType="com.landtool.lanbase.modules.org.entity.OrgUser">
|
select userid,chinesename from ORG_USER where userstatus = 0
|
</select>
|
|
<select id="queryByLoginname" resultType="java.lang.Integer" parameterType="java.lang.String">
|
SELECT COUNT(*) from ORG_USER where loginname = #{loginname}
|
</select>
|
|
<select id="queryUserResCatalog" resultType="java.lang.Integer" parameterType="java.lang.String">
|
SELECT * FROM ROLE_CATALOGID_REL c WHERE ROLEID IN
|
(
|
SELECT b.ROLEID FROM ORG_USERGROUP a LEFT JOIN SYS_ROLEGROUP b ON a.GROUPID=b.GROUPID
|
WHERE a.USERID=4
|
) AND c.STATUS=1
|
</select>
|
|
</mapper>
|