<?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.entrustExamine.mapper.BizEntrustExamineMapper">

    <resultMap type="cn.ezhizao.project.business.entrustExamine.domain.BizEntrustExamine" id="BizEntrustExamineResult">
        <id column="id" property="id"/>
    </resultMap>


    <select id="getList" parameterType="BizEntrustExamine" resultMap="BizEntrustExamineResult">
        SELECT
        t2.NAME as companyName,
        t2.social_credit_code,
        t3.name as taskName,
        t1.current_period,
        t1.create_time,
        t4.account_name as fromTenant,
        t1.cancel_reason,
        t1.id,
        t1.work_order_id,
        t1.`status`,
        t1.next_flag
        FROM
        biz_entrust_examine t1
        LEFT JOIN biz_company t2 ON t1.company_id = t2.id
        LEFT JOIN biz_task_type t3 ON t1.task_type_id = t3.id
        LEFT JOIN biz_tenant t4 on t4.id = t1.entrust_come
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            t1.deleted = 0 and t1.entrust_id = #{entrustId}
            <if test="currentPeriod != null  and currentPeriod != ''">AND t1.current_period LIKE CONCAT('%',#{currentPeriod},'%')</if>
            <if test="entrustComeName != null  and entrustComeName != ''">AND t4.account_name LIKE CONCAT('%',#{entrustComeName},'%') </if>
            <if test="status != null ">AND t1.status = #{status}</if>
            <if test="companyName!= null and companyName != ''">AND t2.NAME LIKE CONCAT('%',#{companyName},'%')</if>
            <if test="dateFilter!= null and dateFilter.size() ">
                AND (
                DATE_FORMAT(t1.create_time,'%Y-%m-%d') &gt;= #{dateFilter[0]}
                AND
                DATE_FORMAT(t1.create_time,'%Y-%m-%d') &lt;= #{dateFilter[1]}
                )
            </if>
        </trim>
        order by t1.create_time desc
    </select>

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