<?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.OrgUserunitDao">
|
|
<!-- 可根据自己的需求,是否要使用 -->
|
<resultMap type="com.landtool.lanbase.modules.org.entity.OrgUserunit" id="userunitMap">
|
<result property="userid" column="USERID"/>
|
<result property="unitid" column="UNITID"/>
|
<result property="rorder" column="RORDER"/>
|
<result property="posname" column="POSNAME"/>
|
<result property="workseasdate" column="WORKSEASDATE"/>
|
<result property="worktype" column="WORKTYPE"/>
|
<result property="workstartdate" column="WORKSTARTDATE"/>
|
<result property="workenddate" column="WORKENDDATE"/>
|
<result property="rcreateuser" column="RCREATEUSER"/>
|
<result property="rcreatedate" column="RCREATEDATE"/>
|
<result property="rlasteditdate" column="RLASTEDITDATE"/>
|
<result property="deptid" column="DEPTID"/>
|
</resultMap>
|
|
<select id="queryObject" resultType="com.landtool.lanbase.modules.org.entity.OrgUserunit">
|
select * from ORG_USERUNIT where USERID = #{value}
|
</select>
|
|
<select id="queryObjectByUnitid" resultType="com.landtool.lanbase.modules.org.entity.OrgUserunit" parameterType="com.landtool.lanbase.modules.org.entity.OrgUserunit">
|
select * from ORG_USERUNIT ut
|
left join ORG_UNIT un on ut.unitid= un.unitid
|
left join ORG_USER us on ut.userid = us.userid
|
<where>
|
ut.USERID = #{userid} and ut.UNITID = #{unitid}
|
<if test="deptid != null">
|
and ut.deptid=#{deptid}
|
</if>
|
<if test="deptid == null">
|
and ut.deptid is null
|
</if>
|
</where>
|
</select>
|
|
<select id="querUserunitJoinUserList" resultType="com.landtool.lanbase.modules.org.entity.OrgUserunitJoinUser">
|
SELECT *
|
FROM(
|
SELECT ROW_NUMBER() OVER(ORDER BY B.userid) AS rownumber,B.*
|
FROM (
|
select A.*,C.unitname,B.CHINESENAME as username,D.unitname as deptname from ORG_USERUNIT A
|
left join ORG_USER B on A.userid = B.userid
|
left join ORG_UNIT C on A.unitid = C.unitid
|
left join ORG_UNIT D on A.deptid = D.unitid
|
<where>
|
<if test="userid != null and userid != ''">
|
AND A.userid = #{userid}
|
</if>
|
</where>
|
) B
|
) A
|
WHERE rownumber > #{lowerOffset} AND <![CDATA[ rownumber <= ${upperOffset} ]]>
|
|
</select>
|
|
<select id="queryTotal" resultType="int">
|
select count(*) from ORG_USERUNIT
|
<where>
|
<if test="userid != null and userid != ''">
|
AND userid = #{userid}
|
</if>
|
</where>
|
</select>
|
|
<insert id="saveUserunitJoinUser" parameterType="com.landtool.lanbase.modules.org.entity.OrgUserunitJoinUser">
|
insert into ORG_USERUNIT
|
(
|
USERID,
|
UNITID,
|
RORDER,
|
POSNAME,
|
WORKSEASDATE,
|
WORKTYPE,
|
WORKSTARTDATE,
|
WORKENDDATE,
|
RCREATEUSER,
|
RCREATEDATE,
|
RLASTEDITDATE,
|
DEPTID
|
)
|
values
|
(
|
#{userid},
|
#{unitid},
|
#{rorder,jdbcType=VARCHAR},
|
#{posname,jdbcType=VARCHAR},
|
#{workseasdate,jdbcType=DATE},
|
#{worktype,jdbcType=VARCHAR},
|
#{workstartdate,jdbcType=DATE},
|
#{workenddate,jdbcType=DATE},
|
#{rcreateuser},
|
#{rcreatedate},
|
#{rlasteditdate},
|
#{deptid,jdbcType=INTEGER}
|
)
|
</insert>
|
|
<update id="updateUserunitJoinUser" parameterType="com.landtool.lanbase.modules.org.entity.OrgUserunitJoinUser">
|
update ORG_USERUNIT
|
<set>
|
<if test="unitid != null">UNITID = #{unitid}, </if>
|
<if test="rorder != null">RORDER = #{rorder}, </if>
|
<if test="posname != null">POSNAME = #{posname}, </if>
|
<if test="workseasdate != null">WORKSEASDATE = #{workseasdate}, </if>
|
<if test="workseasdate == null">WORKSEASDATE = null, </if>
|
<if test="worktype != null">WORKTYPE = #{worktype}, </if>
|
<if test="workstartdate != null">WORKSTARTDATE = #{workstartdate}, </if>
|
<if test="workstartdate == null">WORKSTARTDATE = null, </if>
|
<if test="workenddate != null">WORKENDDATE = #{workenddate}, </if>
|
<if test="workenddate == null">WORKENDDATE = null, </if>
|
<if test="rcreateuser != null">RCREATEUSER = #{rcreateuser}, </if>
|
<if test="rcreatedate != null">RCREATEDATE = #{rcreatedate}, </if>
|
<if test="rlasteditdate != null">RLASTEDITDATE = #{rlasteditdate},</if>
|
<if test="deptid != null">DEPTID = #{deptid}</if>
|
</set>
|
where USERID = #{userid} and UNITID = #{oldunitid}
|
<if test="olddeptid != null">
|
and deptid=#{olddeptid}
|
</if>
|
<if test="olddeptid == null">
|
and deptid is null
|
</if>
|
</update>
|
|
<delete id="delete" parameterType="com.landtool.lanbase.modules.org.entity.OrgUserunit">
|
delete from ORG_USERUNIT where USERID = #{userid} and unitid = #{unitid}
|
<if test="deptid != null">
|
and deptid=#{deptid}
|
</if>
|
<if test="deptid == null">
|
and deptid is null
|
</if>
|
</delete>
|
|
<delete id="deleteBatch">
|
delete from ORG_USERUNIT where USERID in
|
<foreach item="userid" collection="array" open="(" separator="," close=")">
|
#{userid}
|
</foreach>
|
</delete>
|
|
<delete id="deleteBatchByUserIdAndUnitIds">
|
DELETE FROM ORG_USERUNIT
|
WHERE 1=1
|
AND userid = #{userid}
|
AND unitid in
|
<foreach item="unitid" collection="unitids" open="(" separator="," close=")">
|
#{unitid}
|
</foreach>
|
</delete>
|
|
<select id="isExitUserunit" resultType="int" parameterType="com.landtool.lanbase.modules.org.entity.OrgUserunitJoinUser">
|
select count(*) from ORG_USERUNIT
|
<where>
|
USERID = #{userid} and UNITID = #{unitid}
|
<if test="deptid != null">
|
and deptid=#{deptid}
|
</if>
|
<if test="deptid == null">
|
and deptid is null
|
</if>
|
</where>
|
</select>
|
|
<select id="isWorking" resultType="com.landtool.lanbase.modules.org.entity.OrgUserunit">
|
SELECT * from ORG_USERUNIT ouu where ouu.worktype = 1 and ouu.userid = #{userid}
|
</select>
|
</mapper>
|