<?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="cn.ezhizao.project.business.entrust.mapper.BizEntrustMapper">

    <resultMap type="cn.ezhizao.project.business.entrust.domain.BizEntrust" id="BizEntrustResult">
        <id column="id" property="id"/>
    </resultMap>


    <select id="getList" parameterType="BizEntrust" resultMap="BizEntrustResult">
        SELECT t1.*, t2.account_name as to_account_name FROM biz_entrust t1 left join biz_tenant t2 on t2.id = t1.to_tenant_id
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            t1.deleted = 0
            <if test="isStop != null "> AND t1.is_stop = #{isStop}</if>
            <if test="currentYear != null and currentYear != ''"> AND date_format(t1.current_month,'%Y') = #{currentYear}</if>
            <if test="workOrderIds != null and workOrderIds.size() > 0">
                AND t1.work_order_id IN
                <foreach collection="workOrderIds" index="index" item="item" separator="," open="(" close=")">
                    #{item,jdbcType=BIGINT}
                </foreach>
            </if>
        </trim>
    </select>

    <delete id="physicalDelete">
        DELETE FROM biz_entrust
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            <if test="id != null">
                id = #{id} AND
            </if>
       <!-- 删除条件为其他外键可以在这里加 -->
        </trim>
    </delete>
</mapper>
