<?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.financialBase.mapper.BizArchiveReceiveTicketFinishedMapper">
    <!-- 基础的返回map 多表复杂的 自行组合 -->
    <resultMap id="BaseResultMap" type="cn.ezhizao.project.business.financialBase.domain.BizArchiveReceiveTicketFinished">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="id" jdbcType="BIGINT" property="id"/>
        <result column="year" jdbcType="CHAR" property="year"/>
        <result column="month" jdbcType="CHAR" property="month"/>
        <result column="is_finished" jdbcType="TINYINT" property="isFinished"/>
    </resultMap>

    <!--带条件的List查询-->
    <select id="getList" resultMap="BaseResultMap">
        <include refid="getListSql"/>
    </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_archive_receive_ticket_finished
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            deleted = 0 AND
            <if test="id != null  ">
                id = #{id} AND
            </if>
            <if test="year != null  and year != '' ">
                year = #{year} AND
            </if>
            <if test="month != null  and month != '' ">
                month = #{month} AND
            </if>
            <if test="isFinished != null  ">
                is_finished = #{isFinished} AND
            </if>
            <if test="companyId != null">
                company_id = #{companyId} AND
            </if>
        </trim>
    </sql>

    <!-- 工业大学科研管理系统 导出数据用-->
    <select id="getOldData" resultMap="BaseResultMap">
        SELECT * FROM biz_archive_receive_ticket_finished
    </select>

    <delete id="clear" parameterType="java.lang.Long">
        DELETE FROM biz_archive_receive_ticket_finished WHERE id IS NULL;
    </delete>
    <!-- 工业大学科研管理系统 导出数据用-->
</mapper>
