<?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.xzzn.ems.mapper.EmsSiteWeatherDayMapper">

    <update id="updateWeatherDesc">
        update ems_site_weather_day
        set weather_desc = #{weatherDesc},
            weather_code = #{weatherCode},
            update_time = now()
        where site_id = #{siteId}
          and calendar_date = #{calendarDate}
    </update>

    <select id="selectCountBySiteAndDate" resultType="int">
        select count(1)
        from ems_site_weather_day
        where site_id = #{siteId}
          and calendar_date = #{calendarDate}
    </select>

    <insert id="insertSiteWeatherDay">
        insert into ems_site_weather_day(site_id, calendar_date, weather_desc, weather_code, source, create_time, update_time)
        values (#{siteId}, #{calendarDate}, #{weatherDesc}, #{weatherCode}, #{source}, now(), now())
    </insert>

</mapper>
