<?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.WeatherForecastMapper">
    
    <resultMap type="WeatherForecast" id="WeatherForecastResult">
        <result property="terminalNumber"    column="terminal_number"    />
        <result property="dataTime"    column="data_time"    />
        <result property="content"    column="content"    />
    </resultMap>

    <sql id="selectWeatherForecastVo">
        select terminal_number, data_time, content from weather_forecast
    </sql>

    <select id="selectWeatherForecastList" parameterType="WeatherForecast" resultMap="WeatherForecastResult">
        <include refid="selectWeatherForecastVo"/>
        <where>
            <if test="terminalNumber != null ">and terminal_number = #{terminalNumber}</if>
            <if test="dataTime != null ">and data_time = #{dataTime}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
        </where>
    </select>
    
    <select id="selectWeatherForecastById" parameterType="WeatherForecast" resultMap="WeatherForecastResult">
        <include refid="selectWeatherForecastVo"/>
        where terminal_number = #{terminalNumber} and data_time = #{dataTime}
    </select>
        
    <insert id="insertWeatherForecast" parameterType="WeatherForecast">
        insert into weather_forecast
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="terminalNumber != null">terminal_number,</if>
            <if test="dataTime != null">data_time,</if>
            <if test="content != null">content,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="terminalNumber != null">#{terminalNumber},</if>
            <if test="dataTime != null">#{dataTime},</if>
            <if test="content != null">#{content},</if>
         </trim>
    </insert>

    <update id="updateWeatherForecast" parameterType="WeatherForecast">
        update weather_forecast
        <trim prefix="SET" suffixOverrides=",">
            <if test="content != null">content = #{content},</if>
        </trim>
        where terminal_number = #{terminalNumber} and data_time = #{dataTime}
    </update>
</mapper>