<?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.BizFinancialDictionaryMapper">
    <!-- 基础的返回map 多表复杂的 自行组合 -->
    <resultMap id="BaseResultMap" type="cn.ezhizao.project.business.financialBase.domain.BizFinancialDictionary">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="id" jdbcType="BIGINT" property="id"/>
        <result column="name" jdbcType="CHAR" property="name"/>
        <result column="type" jdbcType="TINYINT" property="type"/>
        <result column="remark" jdbcType="CHAR" property="remark"/>
        <result column="tenant_id" jdbcType="BIGINT" property="tenantId"/>
        <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="BIT" property="deleted"/>
        <result column="version" jdbcType="INTEGER" property="version"/>
    </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_financial_dictionary
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            deleted = 0 AND
            <if test="id != null  ">
                id = #{id} AND
            </if>
            <if test="name != null  and name != '' ">
                name = #{name} AND
            </if>
            <if test="type != null  ">
                type = #{type} AND
            </if>
            <if test="remark != null  and remark != '' ">
                remark = #{remark} AND
            </if>
            <if test="tenantId != null  ">
                tenant_id = #{tenantId} 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>
        </trim>
    </sql>

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

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