<?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.archiveTicket.mapper.BizArchiveReceiveTicketMapper">

    <resultMap type="cn.ezhizao.project.business.archiveTicket.domain.BizArchiveReceiveTicket"
               id="BizArchiveReceiveTicketResult">
        <id column="id" jdbcType="BIGINT" property="id"/>
    </resultMap>


    <select id="getList" parameterType="BizArchiveReceiveTicket" resultMap="BizArchiveReceiveTicketResult">
        SELECT t1.* FROM biz_archive_receive_ticket t1
        LEFT JOIN biz_company t2 ON t2.id = t2.id = t1.company_id
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            t1.deleted = 0
            <if test="companyId != null ">AND t1.company_id = #{companyId}</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="fileUrl != null  and fileUrl != ''">AND t1.file_url = #{fileUrl}</if>
            <if test="fileName != null  and fileName != ''">AND t1.file_name like concat('%', #{fileName}, '%')</if>
        </trim>
    </select>

    <delete id="physicalDelete">
        DELETE FROM biz_archive_receive_ticket
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            <if test="id != null">
                id = #{id} AND
            </if>
            <if test="companyId != null">
                company_id = #{companyId} AND
            </if>
            <if test="year != null  and year != ''">year = #{year} AND</if>
            <if test="month != null  and month != ''">month = #{month} AND</if>

            <!-- 删除条件为其他外键可以在这里加 -->
        </trim>
    </delete>
</mapper>
