LibGeoLocationMapper.xml
2.69 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?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.laowu.mapper.LibGeoLocationMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.laowu.model.LibGeoLocationDO">
<id column="id" property="id" />
<result column="create_date" property="createDate" />
<result column="update_date" property="updateDate" />
<result column="delete_date" property="deleteDate" />
<result column="province" property="province" />
<result column="city" property="city" />
<result column="town" property="town" />
<result column="village" property="village" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
create_date,
update_date,
delete_date,
id, province, city, town, village
</sql>
<select id="provinces" resultType="string">
SELECT DISTINCT
t.province
FROM
lib_geo_location t
WHERE
t.delete_date IS NULL
AND t.province IS NOT NULL
order by t.order_no
</select>
<select id="cities" resultType="string">
SELECT DISTINCT
t.city
FROM
lib_geo_location t
WHERE
t.delete_date IS NULL
AND t.city IS NOT NULL
and t.province =#{province}
order by t.order_no
</select>
<select id="county" resultType="string">
SELECT DISTINCT
t.county
FROM
lib_geo_location t
WHERE
t.delete_date IS NULL
AND t.county IS NOT NULL
AND t.province = #{province}
AND t.city = #{city}
order by t.order_no
</select>
<select id="geo" resultType="com.laowu.vo.geo.GeoVO">
SELECT
t1.id,
t1.province,
t1.city,
t1.county,
t1.town,
count(*) as cnt
FROM
lib_geo_location t1
WHERE
t1.delete_date IS NULL
<if test="province != null and province != ''">
AND t1.province = #{province}
</if>
<if test="city != null and city != ''">
AND t1.city = #{city}
</if>
<if test="county != null and county != ''">
AND t1.county = #{county}
</if>
<if test="town != null and town != ''">
AND ( t1.town LIKE concat('%', #{town}, '%') OR t1.village LIKE concat('%', #{town}, '%') )
</if>
GROUP BY t1.town
</select>
</mapper>