DataDistrictDao.xml
2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?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.diligrp.assistant.data.dao.DataDistrictDao">
<resultMap id="DataDistrictMap" type="com.diligrp.assistant.data.model.DataDistrict">
<id column="id" property="id"/>
<result column="parent_id" property="parentId"/>
<result column="name" property="name"/>
<result column="short_name" property="shortName"/>
<result column="level" property="level"/>
<result column="full_name" property="fullName"/>
<result column="area_code" property="areaCode"/>
<result column="py_code" property="pyCode"/>
<result column="short_py" property="shortPy"/>
<result column="path" property="path"/>
<result column="path_name" property="pathName"/>
<result column="longitude" property="longitude"/>
<result column="latitude" property="latitude"/>
<result column="state" property="state"/>
<result column="created_time" property="createdTime"/>
</resultMap>
<select id="findDataDistrictById" parameterType="long" resultMap="DataDistrictMap">
SELECT * FROM data_district WHERE id = #{id} AND state > 0
</select>
<select id="findParentDistrictById" parameterType="long" resultMap="DataDistrictMap">
SELECT
parent.*
FROM data_district self
INNER JOIN data_district parent ON self.parent_id = parent.id
WHERE self.id = #{id} AND self.state > 0
</select>
<select id="findDataDistrictsByIds" resultMap="DataDistrictMap">
SELECT * FROM data_district WHERE id IN
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
AND state > 0 ORDER BY level DESC, id
</select>
<select id="listChildrenById" parameterType="com.diligrp.assistant.data.domain.DistrictPageQuery" resultMap="DataDistrictMap">
SELECT * FROM data_district WHERE parent_Id = #{id} AND state > 0
ORDER BY ID LIMIT #{start}, #{limit}
</select>
<select id="listDataDistrictsByLevel" parameterType="com.diligrp.assistant.data.domain.DistrictPageQuery" resultMap="DataDistrictMap">
SELECT * FROM data_district WHERE level = #{level} AND state > 0
ORDER BY ID LIMIT #{start}, #{limit}
</select>
<select id="listDataDistrictsByDistance" parameterType="com.diligrp.assistant.data.domain.DistrictPageQuery" resultMap="DataDistrictMap">
SELECT * FROM data_district
WHERE longitude IS NOT NULL AND latitude IS NOT NULL AND state > 0
ORDER BY ST_Distance(ST_GeomFromText('POINT(${longitude} ${latitude})'), ST_GeomFromText(CONCAT('POINT(', longitude, ' ', latitude, ')')))
LIMIT #{start}, #{limit}
</select>
</mapper>