<?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.reportTax.mapper.BizFinancialReportTaxDetailReportNonZeroMapper">
    <!-- 基础的返回map 多表复杂的 自行组合 -->
    <resultMap id="BaseResultMap" type="cn.ezhizao.project.business.reportTax.domain.BizFinancialReportTaxDetailReportNonZero">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="id" jdbcType="BIGINT" property="id"/>
        <result column="financial_report_tex_id" jdbcType="BIGINT" property="financialReportTexId"/>
        <result column="financial_report_tex_detail_id" jdbcType="BIGINT" property="financialReportTexDetailId"/>
        <result column="raw_file_name" jdbcType="CHAR" property="rawFileName"/>
        <result column="file_name" jdbcType="CHAR" property="fileName"/>
        <result column="file_url" jdbcType="CHAR" property="fileUrl"/>
        <result column="file_size" jdbcType="CHAR" property="fileSize"/>
        <result column="file_type" jdbcType="CHAR" property="fileType"/>
        <result column="remark" jdbcType="VARCHAR" property="remark"/>
        <result column="sort" jdbcType="INTEGER" property="sort"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="creator_id" jdbcType="BIGINT" property="creatorId"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="updater_id" jdbcType="BIGINT" property="updaterId"/>
        <result column="deleted" jdbcType="TINYINT" property="deleted"/>
        <result column="version" jdbcType="INTEGER" property="version"/>
        <result column="tenant_id" jdbcType="BIGINT" property="tenantId"/>
    </resultMap>

    <!--带条件的List查询-->
    <select id="getList" resultMap="BaseResultMap">
        <include refid="getListSql"/>
        <if test="start != null and size != null">
            limit #{start,jdbcType=INTEGER},#{size,jdbcType=INTEGER}
        </if>
    </select>

    <select id="getListId" resultMap="BaseResultMap">
        SELECT * FROM biz_financial_report_tax_detail_report
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
        deleted = 0 AND
        <if test="id != null  ">
        id = #{id} AND
        </if>
        </trim>
    </select>

    <!--带条件的List查询 数据总条数-->
    <select id="getTotal" resultType="java.lang.Integer">
        SELECT COUNT(1) FROM (<include refid="getListSql"/>) AS C
    </select>

    <sql id="getListSql">
        SELECT * FROM biz_financial_report_tax_detail_report
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            deleted = 0 AND
            <if test="id != null  ">
                id = #{id} AND
            </if>
            <if test="financialReportTexId != null  ">
                financial_report_tex_id = #{financialReportTexId} AND
            </if>
            <if test="financialReportTexDetailId != null  ">
                financial_report_tex_detail_id = #{financialReportTexDetailId} AND
            </if>
            <if test="rawFileName != null  and rawFileName != '' ">
                raw_file_name = #{rawFileName} AND
            </if>
            <if test="fileName != null  and fileName != '' ">
                file_name = #{fileName} AND
            </if>
            <if test="fileUrl != null  and fileUrl != '' ">
                file_url = #{fileUrl} AND
            </if>
            <if test="fileSize != null  and fileSize != '' ">
                file_size = #{fileSize} AND
            </if>
            <if test="fileType != null  and fileType != '' ">
                file_type = #{fileType} AND
            </if>
            <if test="remark != null  and remark != '' ">
                remark = #{remark} AND
            </if>
            <if test="sort != null  ">
                sort = #{sort} AND
            </if>
            <if test="createTime != null  ">
                create_time = #{createTime} AND
            </if>
            <if test="creatorId != null  ">
                creator_id = #{creatorId} AND
            </if>
            <if test="updateTime != null  ">
                update_time = #{updateTime} AND
            </if>
            <if test="updaterId != null  ">
                updater_id = #{updaterId} AND
            </if>
            <if test="deleted != null  ">
                deleted = #{deleted} AND
            </if>
            <if test="version != null  ">
                version = #{version} AND
            </if>
            <if test="tenantId != null  ">
                tenant_id = #{tenantId} AND
            </if>
            ORDER BY  create_time DESC
        </trim>
    </sql>

    <delete id="physicallyDelete">
        DELETE FROM
        biz_financial_report_tax_detail_report
        where financial_report_tax_detail_id = #{financialReportTaxDetailId}
    </delete>
</mapper>
