wl_management/src/main/resources/mapper/generator/DepartmentsStaffRelateDao.xml
2020-08-18 09:23:00 +08:00

66 lines
2.8 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.lz.modules.app.dao.DepartmentsStaffRelateDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.lz.modules.app.entity.DepartmentsStaffRelateEntity" id="departmentsStaffRelateMap">
<result property="id" column="id"/>
<result property="isDelete" column="is_delete"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="departmentId" column="department_id"/>
<result property="staffId" column="staff_id"/>
<result column="level" property="level"/>
<result column="is_leader" property="isLeader"/>
</resultMap>
<insert id="addDepartmentStaffRelateBatch">
INSERT INTO lz_departments_staff_relate(department_id, staff_id)
VALUES
<foreach collection="relates" item="relate" separator=",">
(#{relate.departmentId}, #{relate.staffId})
</foreach>
</insert>
<update id="deleteAllRelates">
update lz_departments_staff_relate set is_delete=1
</update>
<select id="getRelateInfoByStaffId" resultType="String">
select department_id from lz_departments_staff_relate where is_delete=0 and staff_id = #{staffId}
</select>
<select id="getRelateByStaffIdAndDepartmentId" resultType="java.lang.String">
select department_id from lz_departments_staff_relate where is_delete=0 and staff_id = #{staffId} and department_id=#{departmentId}
</select>
<update id="updateByStaffId">
update lz_departments_staff_relate set is_delete=0, update_time=now(), department_id=#{departmentId}, is_leader=#{staffId.isLeader} where is_delete=0 and staff_id = #{staffId.id}
</update>
<select id="selectByDepartmentIds" resultType="com.lz.modules.app.entity.DepartmentsStaffRelateEntity">
select * from lz_departments_staff_relate where is_delete=0 and department_id in
<foreach collection="departmentIds" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</select>
<select id="selectByStaffIds" resultType="com.lz.modules.app.entity.DepartmentsStaffRelateEntity">
select * from ( select * from lz_departments_staff_relate where is_delete=0 and staff_id in
<foreach collection="staffIds" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
order by level desc) t
group by staff_id
</select>
<select id="selectAll" resultType="com.lz.modules.app.entity.DepartmentsStaffRelateEntity">
select * from lz_departments_staff_relate
</select>
</mapper>