<?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.ruoyi.predict.mapper.PlanpowerDistributionMapper">
    
    <resultMap type="PlanpowerDistribution" id="PlanpowerDistributionResult">
        <result property="stationNumber"    column="station_number"    />
        <result property="type"    column="type"    />
    </resultMap>

    <sql id="selectPlanpowerDistributionVo">
        select station_number, type from planpower_distribution
    </sql>

    <select id="selectPlanpowerDistributionList" parameterType="PlanpowerDistribution" resultMap="PlanpowerDistributionResult">
        <include refid="selectPlanpowerDistributionVo"/>
        <where>  
            <if test="stationNumber != null "> and station_number = #{stationNumber}</if>
            <if test="type != null "> and type = #{type}</if>
        </where>
    </select>
    
    <select id="selectPlanpowerDistributionById" parameterType="Long" resultMap="PlanpowerDistributionResult">
        <include refid="selectPlanpowerDistributionVo"/>
        where station_number = #{stationNumber}
    </select>

    <insert id="insertPlanpowerDistribution" parameterType="PlanpowerDistribution">
        insert into planpower_distribution
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="stationNumber != null">station_number,</if>
            <if test="type != null">type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="stationNumber != null">#{stationNumber},</if>
            <if test="type != null">#{type},</if>
         </trim>
    </insert>

    <update id="updatePlanpowerDistribution" parameterType="PlanpowerDistribution">
        update planpower_distribution
        <trim prefix="SET" suffixOverrides=",">
            <if test="type != null">type = #{type},</if>
        </trim>
        where station_number = #{stationNumber}
    </update>

    <delete id="deletePlanpowerDistributionById" parameterType="Long">
        delete from planpower_distribution where station_number = #{stationNumber}
    </delete>

</mapper>