cjl
2023-08-22 58fdbd07beae496c4c3b0744efe86a7d82e382b7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?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.moral.api.mapper.CityAqiMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.moral.api.entity.CityAqi">
        <result column="city_code" property="cityCode"/>
        <result column="time" property="time"/>
        <result column="value" property="value"/>
    </resultMap>
    <select id="listCity" resultMap="BaseResultMap">
        SELECT
            time,value ->> '$.AQI' as value
        FROM
            `city_aqi`
        WHERE
            time >= DATE_SUB( date_format(NOW(),'%Y-%m-%d %H'), INTERVAL 1 DAY )
          AND city_code = #{cityCode}
        ORDER BY
            time
    </select>
</mapper>