<?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.WfLoadGrowMapper">

    <resultMap type="WfLoadGrow" id="WfLoadGrowResult">
        <result property="windplantNo" column="windplant_no"/>
        <result property="growTime" column="grow_time"/>
        <result property="load" column="load"/>
    </resultMap>

    <sql id="selectWfLoadGrowVo">
        select windplant_no, grow_time, load from wf_load_grow
    </sql>

    <select id="selectWfLoadGrowList" parameterType="WfLoadGrow" resultMap="WfLoadGrowResult">
        select
        wlg.*,
        win.name as "windplantName"
        from
        wf_load_grow wlg
        left join windplant win on win.windplant_no = wlg.windplant_no
        <where>
            <if test="windplantNo != null ">and wlg.windplant_no = #{windplantNo}</if>
            <if test="growTime != null ">and wlg.grow_time = #{growTime}</if>
            <if test="load != null ">and wlg.load = #{load}</if>
        </where>
        order by wlg.windplant_no asc
    </select>

    <select id="selectWfLoadGrowById" parameterType="Long" resultMap="WfLoadGrowResult">
        <include refid="selectWfLoadGrowVo"/>
        where windplant_no = #{windplantNo}
    </select>

    <select id="checkWindplantNoUnique" parameterType="Long" resultType="int">
        select count(1) from wf_load_grow where windplant_no = #{windplantNo} and rownum <![CDATA[ <= ]]> 1
    </select>

    <insert id="insertWfLoadGrow" parameterType="WfLoadGrow">
        insert into wf_load_grow
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="windplantNo != null">windplant_no,</if>
            <if test="growTime != null">grow_time,</if>
            <if test="load != null">load,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="windplantNo != null">#{windplantNo},</if>
            <if test="growTime != null">#{growTime},</if>
            <if test="load != null">#{load},</if>
        </trim>
    </insert>

    <update id="updateWfLoadGrow" parameterType="WfLoadGrow">
        update wf_load_grow
        <trim prefix="SET" suffixOverrides=",">
            <if test="growTime != null">grow_time = #{growTime},</if>
            <if test="load != null">load = #{load},</if>
        </trim>
        where windplant_no = #{windplantNo}
    </update>

    <delete id="deleteWfLoadGrowById" parameterType="Long">
        delete from wf_load_grow where windplant_no = #{windplantNo}
    </delete>

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

</mapper>