wl_management/src/main/resources/mapper/flow/StaffRoleDepartmentMapper.xml
2020-09-29 16:53:44 +08:00

116 lines
4.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.lz.modules.flow.dao.StaffRoleDepartmentMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.lz.modules.flow.entity.StaffRoleDepartment">
<id column="id" property="id"/>
<result column="is_delete" property="isDelete"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="staff_role_id" property="staffRoleId"/>
<result column="department_id" property="departmentId"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id AS id, is_delete AS isDelete, gmt_create AS gmtCreate, gmt_modified AS gmtModified, staff_role_id AS staffRoleId, department_id AS departmentId
</sql>
<select id="selectStaffRoleDepartmentById" resultType="StaffRoleDepartment" >
select * from lz_staff_role_department where id=#{id} and is_delete = 0 limit 1
</select>
<insert id="insertStaffRoleDepartment" parameterType="StaffRoleDepartment" useGeneratedKeys="true" keyProperty="id" >
insert into lz_staff_role_department(
<if test="staffRoleId != null">staff_role_id, </if>
<if test="departmentId != null">department_id, </if>
is_delete,
gmt_create,
gmt_modified
)values(
<if test="staffRoleId != null">#{ staffRoleId}, </if>
<if test="departmentId != null">#{ departmentId}, </if>
0,
now(),
now()
)
</insert>
<update id="updateStaffRoleDepartmentById" parameterType="StaffRoleDepartment" >
update
lz_staff_role_department
<trim prefix="set" suffixOverrides=",">
<if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="gmtCreate != null">gmt_create = #{gmtCreate},</if>
<if test="staffRoleId != null">staff_role_id = #{staffRoleId},</if>
<if test="departmentId != null">department_id = #{departmentId}</if>
</trim>
,gmt_modified = now()
where id = #{id}
</update>
<update id="updateCoverStaffRoleDepartmentById" parameterType="StaffRoleDepartment" >
update
lz_staff_role_department
set
is_delete = #{isDelete},
gmt_create = #{gmtCreate},
staff_role_id = #{staffRoleId},
department_id = #{departmentId}
,gmt_modified = now()
where id = #{id}
</update>
<update id="deleteStaffRoleDepartmentById" parameterType="java.lang.Long">
update lz_staff_role_department set is_delete = 1 where id=#{id} limit 1
</update>
<select id="selectStaffRoleDepartmentByStaffRoleId" resultType="com.lz.modules.flow.entity.StaffRoleDepartment">
select * from lz_staff_role_department where staff_role_id=#{staffRoleId} and is_delete = 0
</select>
<select id="selectStaffRoleDepartmentByDepartmentId"
resultType="com.lz.modules.flow.entity.StaffRoleDepartment">
select * from lz_staff_role_department where department_id=#{departmentId} and is_delete = 0
</select>
<select id="selectStaffRoleDepartmentByDepartmentIdRoleIds" resultType="com.lz.modules.flow.entity.StaffRoleDepartment">
select * from lz_staff_role_department where department_id=#{departmentId} and is_delete = 0
and staff_role_id in
<foreach collection="ids" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</select>
<delete id="deleteStaffRoleDepartment">
delete from lz_staff_role_department where id = #{id}
</delete>
<select id="selectStaffRoleDepartmentByStaffRoleIdDepartments"
resultType="com.lz.modules.flow.entity.StaffRoleDepartment">
select * from lz_staff_role_department where staff_role_id=#{staffRoleId} and is_delete = 0
and department_id in
<foreach collection="departments" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
</select>
</mapper>