<?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.OrgUserAuthDao">
|
|
<!-- 可根据自己的需求,是否要使用 -->
|
<resultMap type="com.landtool.lanbase.modules.org.entity.OrgUserAuth" id="userauthMap">
|
<result property="authId" column="AUTHID"/>
|
<result property="userId" column="USERID"/>
|
<result property="authGrad" column="AUTHGRAD"/>
|
<result property="authUserId" column="AUTHUSERID"/>
|
<result property="rCreateUser" column="RCREATEUSER"/>
|
<result property="rCreateDate" column="RCREATEDATE"/>
|
<result property="rOrder" column="RORDER"/>
|
<result property="authResult" column="AUTHRESULT"/>
|
</resultMap>
|
|
<resultMap type="com.landtool.lanbase.modules.org.entity.OrgUserJoinAuth" id="UserJoinAuthMap">
|
<result property="userid" column="USERID"/>
|
<result property="loginname" column="LOGINNAME"/>
|
<result property="chinesename" column="CHINESENAME"/>
|
<result property="userstatus" column="USERSTATUS"/>
|
<result property="authId" column="AUTHID"></result>
|
<result property="authGrad" column="AUTHGRAD"/>
|
<result property="rCreateUser" column="RCREATEUSER"/>
|
<result property="rCreateDate" column="RCREATEDATE"/>
|
<result property="authResult" column="AUTHRESULT"/>
|
<result property="rCreateUserName" column="RCREATEUSERNAME"/>
|
<result property="rn" column="RN"/>
|
<result property="unitname" column="unitname"/>
|
</resultMap>
|
|
<select id="queryObject" resultType="com.landtool.lanbase.modules.org.entity.OrgUserAuth">
|
select * from ORG_USERAUTH where AUTHID = #{value}
|
</select>
|
|
<select id="queryList" resultType="com.landtool.lanbase.modules.org.entity.OrgUserAuth">
|
SELECT *
|
FROM(
|
SELECT ROW_NUMBER() OVER(ORDER BY B.authId) AS rownumber,B.*
|
FROM (
|
select * from ORG_USERAUTH
|
) B
|
) A
|
WHERE rownumber > #{lowerOffset} AND <![CDATA[ rownumber <= ${upperOffset} ]]>
|
</select>
|
|
<select id="queryOrgUserJoinAuthList" resultMap="UserJoinAuthMap">
|
select * from (
|
SELECT *
|
FROM(
|
SELECT ROW_NUMBER() OVER(ORDER BY B.userid) AS rownumber,B.*
|
FROM (
|
select distinct(o.userid),loginname,chinesename,userstatus,a.authGrad,a.authId,a.rCreateUser
|
,a.rCreateDate,a.authResult,a.rCreateUserName,o.spellfirst,d.unitname from ORG_USER o
|
left join (
|
select authId,userid,authGrad,rCreateUser,rCreateDate,authResult,chinesename rCreateUserName from
|
( select o.*,u.chinesename, row_number() over(partition by o.userid order by o.rCreateDate DESC) rn
|
from ORG_USERAUTH o left join ORG_USER u on o.rcreateuser = u.userid)tt where tt.rn=1
|
) a
|
on o.userid = a.userid
|
left join (
|
SELECT ouu.USERID,max(ou.UNITNAME) AS unitname,max(ou.spellfirst) AS spellfirst
|
FROM ORG_USERUNIT ouu
|
LEFT JOIN ORG_UNIT ou ON ouu.unitid=ou.unitid
|
where ouu.worktype = '1'
|
GROUP BY (ouu.USERID,ouu.rcreatedate)
|
order by ouu.rcreatedate desc
|
)d ON o.USERID = d.USERID
|
<where>
|
<if test="LoginName != null and LoginName!=''">
|
AND loginname LIKE ('%' || #{LoginName} || '%')
|
</if>
|
<if test="U_STATUS != null and U_STATUS!=''">
|
AND cast(userstatus as varchar) = #{U_STATUS}
|
</if>
|
<if test="U_CNAME != null and U_CNAME!=''">
|
AND (chinesename LIKE ('%' || #{U_CNAME} || '%') or loginname LIKE ('%' || #{U_CNAME} || '%') or LOWER(o.spellfirst) LIKE ('%' || LOWER(#{U_CNAME}) || '%') )
|
</if>
|
<if test="systemName != null and systemName != ''">
|
AND (d.UNITNAME LIKE ('%' || #{systemName} || '%') or LOWER(d.spellfirst) LIKE ('%' || LOWER(#{systemName}) || '%'))
|
</if>
|
</where>
|
|
) B
|
) A
|
WHERE rownumber > #{lowerOffset} AND <![CDATA[ rownumber <= ${upperOffset} ]]>
|
)a order by
|
<choose>
|
<when test="sidx != null and sidx != ''">
|
${sidx} ${order}
|
</when>
|
<otherwise>
|
userid
|
</otherwise>
|
</choose>
|
</select>
|
|
<select id="queryTotal" resultType="int">
|
select count(*) from ORG_USERAUTH
|
</select>
|
|
<select id="queryOrgUserJoinAuthTotal" resultType="int">
|
select count(distinct(o.userid)) from ORG_USER o
|
left join (
|
select authId,userid,authGrad,rCreateUser,rCreateDate,authResult
|
from( select o.*, row_number() over(partition by userid order by rCreateDate DESC) rn from ORG_USERAUTH o)tt
|
where tt.rn=1
|
) a on o.userid = a.userid
|
left join (
|
SELECT ouu.USERID,max(ou.UNITNAME) AS unitname,max(ou.spellfirst) AS spellfirst
|
FROM ORG_USERUNIT ouu
|
LEFT JOIN ORG_UNIT ou ON ouu.unitid=ou.unitid
|
where ouu.worktype = '1'
|
GROUP BY (ouu.USERID,ouu.rcreatedate)
|
order by ouu.rcreatedate desc
|
)d ON o.USERID = d.USERID
|
<where>
|
<if test="LoginName != null and LoginName!=''">
|
AND loginname LIKE ('%' || #{LoginName} || '%')
|
</if>
|
<if test="U_STATUS != null and U_STATUS!=''">
|
AND cast(userstatus as varchar) = #{U_STATUS}
|
</if>
|
<if test="U_CNAME != null and U_CNAME!=''">
|
AND (chinesename LIKE ('%' || #{U_CNAME} || '%') or loginname LIKE ('%' || #{U_CNAME} || '%') or LOWER(o.spellfirst) LIKE ('%' || LOWER(#{U_CNAME}) || '%') )
|
</if>
|
<if test="systemName != null and systemName != ''">
|
AND (d.UNITNAME LIKE ('%' || #{systemName} || '%') or LOWER(d.spellfirst) LIKE ('%' || LOWER(#{systemName}) || '%'))
|
</if>
|
</where>
|
</select>
|
|
<insert id="save" parameterType="com.landtool.lanbase.modules.org.entity.OrgUserAuth">
|
insert into ORG_USERAUTH
|
(
|
USERID,
|
AUTHGRAD,
|
AUTHUSERID,
|
RCREATEUSER,
|
RCREATEDATE,
|
RORDER,
|
AUTHRESULT
|
)
|
values
|
(
|
#{userId,jdbcType=BIGINT},
|
#{authGrad,jdbcType=BIGINT},
|
#{authUserId,jdbcType=BIGINT},
|
#{rCreateUser},
|
#{rCreateDate},
|
#{rOrder,jdbcType=VARCHAR},
|
#{authResult,jdbcType=BIGINT}
|
)
|
</insert>
|
|
<update id="update" parameterType="com.landtool.lanbase.modules.org.entity.OrgUserAuth">
|
update ORG_USERAUTH
|
<set>
|
<if test="userId != null">USERID = #{userId}, </if>
|
<if test="authGrad != null">AUTHGRAD = #{authGrad}, </if>
|
<if test="authUserId != null">AUTHUSERID = #{authUserId}, </if>
|
<if test="rCreateUser != null">RCREATEUSER = #{rCreateUser}, </if>
|
<if test="rCreateDate != null">RCREATEDATE = #{rCreateDate}, </if>
|
<if test="rOrder != null">RORDER = #{rOrder}, </if>
|
<if test="authResult != null">AUTHRESULT = #{authResult}</if>
|
</set>
|
where AUTHID = #{authId}
|
</update>
|
|
<delete id="delete">
|
delete from ORG_USERAUTH where AUTHID = #{value}
|
</delete>
|
|
<delete id="deleteBatch">
|
delete from ORG_USERAUTH where AUTHID in
|
<foreach item="authId" collection="array" open="(" separator="," close=")">
|
#{authId}
|
</foreach>
|
</delete>
|
|
<update id="updateAuthState" parameterType="com.landtool.lanbase.modules.org.entity.OrgUserAuth">
|
update ORG_USERAUTH
|
<set>
|
AUTHRESULT = #{authResult}
|
</set>
|
where AUTHID = #{authId}
|
</update>
|
</mapper>
|