<?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.workOrder.mapper.BizWorkOrderRecordMapper">

    <resultMap type="cn.ezhizao.project.business.workOrder.domain.BizWorkOrderRecord" id="BizWorkOrderRecordResult">
        <id column="id" property="id"/>
    </resultMap>


    <select id="getList" parameterType="BizWorkOrderRecord" resultMap="BizWorkOrderRecordResult">
        SELECT t1.*, t2.name as company_name FROM biz_work_order_record t1 left join biz_company t2 on t2.id = t1.company_id
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            t1.deleted = 0
            <if test="id != null "> AND t1.id = #{id}</if>
            <if test="year != null  and year != ''"> AND t1.year = #{year}</if>
            <if test="month != null  and month != ''"> AND t1.month = #{month}</if>
            <if test="workOrderId != null "> AND t1.work_order_id = #{workOrderId}</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>
            <if test="status != null "> AND t1.status = #{status}</if>
            <if test="statusDescript != null  and statusDescript != ''"> AND t1.status_descript = #{statusDescript}</if>
            <if test="tenantId != null "> AND t1.tenant_id = #{tenantId}</if>
            <if test="companyId != null "> AND t1.company_id = #{companyId}</if>
        </trim>
    </select>

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