<?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.electricpowergeneration.mapper.TElectricPowerGenerationMapper">
    
    <resultMap type="TElectricPowerGeneration" id="TElectricPowerGenerationResult">
        <result property="id"    column="id"    />
        <result property="dataTime"    column="data_time"    />
        <result property="type"    column="type"    />
        <result property="num"    column="num"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
    </resultMap>

    <sql id="selectTElectricPowerGenerationVo">
        select id, data_time, type, num, create_time, create_by from t_electric_power_generation
    </sql>

    <select id="selectTElectricPowerGenerationList" parameterType="TElectricPowerGeneration" resultMap="TElectricPowerGenerationResult">
        <include refid="selectTElectricPowerGenerationVo"/>
        <where>  
            <if test="dataTime != null  and dataTime != ''"> and data_time = #{dataTime}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="num != null "> and num = #{num}</if>
        </where>
    </select>
    
    <select id="selectTElectricPowerGenerationById" parameterType="Long" resultMap="TElectricPowerGenerationResult">
        <include refid="selectTElectricPowerGenerationVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTElectricPowerGeneration" parameterType="TElectricPowerGeneration" useGeneratedKeys="true" keyProperty="id">
        insert into t_electric_power_generation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dataTime != null">data_time,</if>
            <if test="type != null">type,</if>
            <if test="num != null">num,</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="num != null">#{num},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
         </trim>
    </insert>

    <update id="updateTElectricPowerGeneration" parameterType="TElectricPowerGeneration">
        update t_electric_power_generation
        <trim prefix="SET" suffixOverrides=",">
            <if test="dataTime != null">data_time = #{dataTime},</if>
            <if test="type != null">type = #{type},</if>
            <if test="num != null">num = #{num},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTElectricPowerGenerationById" parameterType="Long">
        delete from t_electric_power_generation where id = #{id}
    </delete>

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

</mapper>