119 lines
2.7 KiB
XML
119 lines
2.7 KiB
XML
|
<?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.jeeplus.ccqnsoft.weather.dao.WeatherDao">
|
||
|
|
||
|
<sql id="weatherColumns">
|
||
|
a.id AS "id",
|
||
|
a.temperature_max AS "temperatureMax",
|
||
|
a.temperature_min AS "temperatureMin",
|
||
|
a.create_date AS "createDate",
|
||
|
a.update_date AS "updateDate"
|
||
|
</sql>
|
||
|
|
||
|
<sql id="weatherJoins">
|
||
|
</sql>
|
||
|
|
||
|
|
||
|
<select id="get" resultType="Weather" >
|
||
|
SELECT
|
||
|
<include refid="weatherColumns"/>
|
||
|
FROM tqd_weather a
|
||
|
<include refid="weatherJoins"/>
|
||
|
WHERE a.id = #{id}
|
||
|
</select>
|
||
|
|
||
|
<select id="getByToday" resultType="Weather" >
|
||
|
SELECT
|
||
|
<include refid="weatherColumns"/>
|
||
|
FROM tqd_weather a
|
||
|
<include refid="weatherJoins"/>
|
||
|
WHERE
|
||
|
<if test="createDate != null and createDate != ''">
|
||
|
DATE_FORMAT(a.create_date,'%j') = DATE_FORMAT(#{createDate},'%j')
|
||
|
</if>
|
||
|
limit 1
|
||
|
</select>
|
||
|
|
||
|
<select id="findList" resultType="Weather" >
|
||
|
SELECT
|
||
|
<include refid="weatherColumns"/>
|
||
|
FROM tqd_weather a
|
||
|
<include refid="weatherJoins"/>
|
||
|
<where>
|
||
|
<if test="createDate != null and createDate != ''">
|
||
|
DATE_FORMAT(a.create_date,'%j') >= (DATE_FORMAT(#{createDate},'%j') -30)
|
||
|
</if>
|
||
|
</where>
|
||
|
<choose>
|
||
|
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
||
|
ORDER BY ${page.orderBy}
|
||
|
</when>
|
||
|
<otherwise>
|
||
|
ORDER BY a.create_date
|
||
|
</otherwise>
|
||
|
</choose>
|
||
|
</select>
|
||
|
|
||
|
<select id="findAllList" resultType="Weather" >
|
||
|
SELECT
|
||
|
<include refid="weatherColumns"/>
|
||
|
FROM tqd_weather a
|
||
|
<include refid="weatherJoins"/>
|
||
|
<where>
|
||
|
|
||
|
</where>
|
||
|
<choose>
|
||
|
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
||
|
ORDER BY ${page.orderBy}
|
||
|
</when>
|
||
|
<otherwise>
|
||
|
ORDER BY a.update_date DESC
|
||
|
</otherwise>
|
||
|
</choose>
|
||
|
</select>
|
||
|
|
||
|
<insert id="insert">
|
||
|
INSERT INTO tqd_weather (
|
||
|
id,
|
||
|
temperature_max,
|
||
|
temperature_min,
|
||
|
create_date,
|
||
|
update_date
|
||
|
) VALUES (
|
||
|
#{id},
|
||
|
#{temperatureMax},
|
||
|
#{temperatureMin},
|
||
|
#{createDate},
|
||
|
#{updateDate}
|
||
|
)
|
||
|
</insert>
|
||
|
|
||
|
<update id="update">
|
||
|
UPDATE tqd_weather SET
|
||
|
temperature_max = #{temperatureMax},
|
||
|
temperature_min = #{temperatureMin},
|
||
|
update_date = #{updateDate}
|
||
|
WHERE id = #{id}
|
||
|
</update>
|
||
|
|
||
|
|
||
|
<!--物理删除-->
|
||
|
<update id="delete">
|
||
|
DELETE FROM tqd_weather
|
||
|
WHERE id = #{id}
|
||
|
</update>
|
||
|
|
||
|
<!--逻辑删除-->
|
||
|
<update id="deleteByLogic">
|
||
|
UPDATE tqd_weather SET
|
||
|
del_flag = #{DEL_FLAG_DELETE}
|
||
|
WHERE id = #{id}
|
||
|
</update>
|
||
|
|
||
|
|
||
|
<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
|
||
|
<select id="findUniqueByProperty" resultType="Weather" statementType="STATEMENT">
|
||
|
select * FROM tqd_weather where ${propertyName} = '${value}'
|
||
|
</select>
|
||
|
|
||
|
</mapper>
|