<?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.order.mapper.BizArchiveInputDetailMapper">

    <resultMap type="cn.ezhizao.project.business.order.domain.BizArchiveInputDetail" id="BizArchiveInputDetailResult">
        <id column="id" property="id"/>
    </resultMap>


    <select id="getList" parameterType="BizArchiveInputDetail" resultMap="BizArchiveInputDetailResult">
        SELECT t1.*, t2.name as task_type_name, t2.pay_address
        FROM biz_archive_input_detail t1
        left join biz_task_type t2 on t2.id = t1.task_type_id
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            t1.deleted = 0
            <if test="companyId != null "> AND t1.company_id = #{companyId}</if>
            <if test="contractId != null "> AND t1.contract_id = #{contractId}</if>
            <if test="serviceNum != null "> AND t1.service_num = #{serviceNum}</if>
            <if test="price != null "> AND t1.price = #{price}</if>
            <if test="amount != null "> AND t1.amount = #{amount}</if>
        </trim>
    </select>
    <select id="getDetail" parameterType="BizArchiveInputDetail" resultMap="BizArchiveInputDetailResult">
        SELECT *
        FROM biz_archive_input_detail
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            deleted = 0
            <if test="contractId != null "> AND contract_id = #{contractId}</if>
            <if test="taskTypeId != null "> AND task_type_id = #{taskTypeId}</if>
        </trim>

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