TbAreaSMapper.xml
4.07 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?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.zteits.sys.mapper.smapper.TbAreaSMapper">
<resultMap id="BaseResultMap" type="com.zteits.sys.domain.TbArea">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="area_code" jdbcType="BIGINT" property="areaCode" />
<result column="area_name" jdbcType="VARCHAR" property="areaName" />
<result column="area_type" jdbcType="INTEGER" property="areaType" />
<result column="parent_id" jdbcType="BIGINT" property="parentId" />
<result column="data_state" jdbcType="INTEGER" property="dataState" />
<result column="sort_num" jdbcType="INTEGER" property="sortNum" />
<result column="car_number_head" jdbcType="VARCHAR" property="carNumberHead" />
</resultMap>
<sql id="Base_Column_List">
id, area_code, area_name, area_type, parent_id, data_state, car_number_head,sort_num
</sql>
<!-- 查询区域 -->
<select id="queryTbArea" parameterType="com.zteits.sys.domain.TbArea" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_area
<where>
<choose>
<when test="dataState != null">
data_state = #{dataState,jdbcType=INTEGER}
</when>
<otherwise>
data_state = 1
</otherwise>
</choose>
</where>
</select>
<!-- 查询区域的下一级 -->
<select id="queryNextLowerLeverById" parameterType="com.zteits.sys.domain.TbArea" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from tb_area
where data_state = 1
and parent_id=#{id}
</select>
<!-- 查询省份 langlw 2017-08-14-->
<select id="queryProvince" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from tb_area
where data_state = 1
and area_type=30
</select>
<!-- 根据地域类型查询所有地域-->
<select id="queryTbAreaByAreaType" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" />
from tb_area
WHERE data_state = 1
AND area_type IN
<foreach collection="areaTypes" item="areaType" index="index" open="(" close=")" separator=",">
#{areaType}
</foreach>
</select>
<select id="queryTbAreaByParentId" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" />
from tb_area
WHERE data_state = 1
AND parent_id = #{parentId}
</select>
<select id="queryTbAreaByIdList" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" />
from tb_area
WHERE data_state = 1
AND id in
<foreach collection="ids" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</select>
<!-- 查询区域 -->
<select id="queryTbAreaByTbArea" parameterType="com.zteits.sys.domain.TbArea" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_area
where data_state = 1
<if test="id != null">
and id= #{id}
</if>
</select>
<!-- 通过区域类型+父类Ids 查询省份或者地市或者区县 -->
<select id="queryAreaByParentIdAndAreaType" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_area
where data_state = 1
and parent_id in
<foreach collection="parentIds" item="parentId" index="index" open="(" close=")" separator=",">
#{parentId}
</foreach>
and area_type=#{areaType}
order by sort_num asc
</select>
<!-- 通过区域类型+父类Ids 查询省份或者地市或者区县 -->
<select id="queryAreaByIdsAndAreaType" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tb_area
where data_state = 1
and id in
<foreach collection="ids" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
and area_type=#{areaType}
order by sort_num asc
</select>
</mapper>