<?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="com.ztmap.project.zhny.electricpowerquota.mapper.TElectricPowerQuotaMapper">
    
    <resultMap type="TElectricPowerQuota" id="TElectricPowerQuotaResult">
        <result property="id"    column="id"    />
        <result property="dataTime"    column="data_time"    />
        <result property="type"    column="type"    />
        <result property="nbqsrDl"    column="nbqsr_dl"    />
        <result property="nbqzhXl"    column="nbqzh_xl"    />
        <result property="gdzhXl"    column="gdzh_xl"    />
        <result property="dzxnb"    column="dzxnb"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
    </resultMap>

    <sql id="selectTElectricPowerQuotaVo">
        select id, data_time, type, nbqsr_dl, nbqzh_xl, gdzh_xl, dzxnb, create_time, create_by from t_electric_power_quota
    </sql>

    <select id="selectTElectricPowerQuotaList" parameterType="TElectricPowerQuota" resultMap="TElectricPowerQuotaResult">
        <include refid="selectTElectricPowerQuotaVo"/>
        <where>  
            <if test="dataTime != null  and dataTime != ''"> and data_time = #{dataTime}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="nbqsrDl != null "> and nbqsr_dl = #{nbqsrDl}</if>
            <if test="nbqzhXl != null "> and nbqzh_xl = #{nbqzhXl}</if>
            <if test="gdzhXl != null "> and gdzh_xl = #{gdzhXl}</if>
            <if test="dzxnb != null "> and dzxnb = #{dzxnb}</if>
        </where>
    </select>
    
    <select id="selectTElectricPowerQuotaById" parameterType="Long" resultMap="TElectricPowerQuotaResult">
        <include refid="selectTElectricPowerQuotaVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTElectricPowerQuota" parameterType="TElectricPowerQuota" useGeneratedKeys="true" keyProperty="id">
        insert into t_electric_power_quota
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dataTime != null">data_time,</if>
            <if test="type != null">type,</if>
            <if test="nbqsrDl != null">nbqsr_dl,</if>
            <if test="nbqzhXl != null">nbqzh_xl,</if>
            <if test="gdzhXl != null">gdzh_xl,</if>
            <if test="dzxnb != null">dzxnb,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="dataTime != null">#{dataTime},</if>
            <if test="type != null">#{type},</if>
            <if test="nbqsrDl != null">#{nbqsrDl},</if>
            <if test="nbqzhXl != null">#{nbqzhXl},</if>
            <if test="gdzhXl != null">#{gdzhXl},</if>
            <if test="dzxnb != null">#{dzxnb},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
         </trim>
    </insert>

    <update id="updateTElectricPowerQuota" parameterType="TElectricPowerQuota">
        update t_electric_power_quota
        <trim prefix="SET" suffixOverrides=",">
            <if test="dataTime != null">data_time = #{dataTime},</if>
            <if test="type != null">type = #{type},</if>
            <if test="nbqsrDl != null">nbqsr_dl = #{nbqsrDl},</if>
            <if test="nbqzhXl != null">nbqzh_xl = #{nbqzhXl},</if>
            <if test="gdzhXl != null">gdzh_xl = #{gdzhXl},</if>
            <if test="dzxnb != null">dzxnb = #{dzxnb},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTElectricPowerQuotaById" parameterType="Long">
        delete from t_electric_power_quota where id = #{id}
    </delete>

    <delete id="deleteTElectricPowerQuotaByIds" parameterType="String">
        delete from t_electric_power_quota where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>