TbAreaBlockSmapper.xml
4.77 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
132
<?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.TbAreaBlockSmapper">
<resultMap id="BaseResultMap" type="com.zteits.sys.domain.TbAreaBlock">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="area_code" property="areaCode" jdbcType="BIGINT"/>
<result column="area_name" property="areaName" jdbcType="VARCHAR"/>
<result column="area_type" property="areaType" jdbcType="INTEGER"/>
<result column="parent_id" property="parentId" jdbcType="BIGINT"/>
<result column="org_id" property="orgId" jdbcType="BIGINT"/>
<result column="data_state" property="dataState" jdbcType="INTEGER"/>
<result column="create_empid" property="createEmpid" jdbcType="VARCHAR"/>
<result column="create_date" property="createDate" jdbcType="TIMESTAMP"/>
<result column="modfiy_empid" property="modfiyEmpid" jdbcType="VARCHAR"/>
<result column="modfiy_date" property="modfiyDate" jdbcType="TIMESTAMP"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id, area_code, area_name, area_type, parent_id, org_id, data_state, create_empid,
create_date, modfiy_empid, modfiy_date, remark
</sql>
<!--查询块信息-->
<select id="queryTbAreaBlock" parameterType="com.zteits.sys.domain.TbAreaBlock" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tb_area_block
where 1=1
<if test="areaCode != null">
and area_code=#{areaCode,jdbcType="BIGINT"}
</if>
<if test="areaName != null and areaName !=''">
and area_name=#{areaName,jdbcType=VARCHAR}
</if>
<if test="areaType != null">
and area_type=#{areaType,jdbcType=INTEGER}
</if>
<if test="parentId != null">
and parent_id=#{parentId,jdbcType=BIGINT}
</if>
<if test="parentAreaId != null">
and parent_area_id=#{parentAreaId,jdbcType=BIGINT}
</if>
<if test="orgId != null">
and org_id=#{orgId,jdbcType=BIGINT}
</if>
<if test="id != null">
and id=#{id,jdbcType=BIGINT}
</if>
<choose>
<when test="dataState != null">
and data_state = #{dataState,jdbcType=INTEGER}
</when>
<otherwise>
and data_state = 1
</otherwise>
</choose>
</select>
<select id="queryAreaBlockByAreaType" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tb_area_block
where area_type IN
<foreach collection="areaTypes" item="areaType" index="index" open="(" separator="," close=")">
#{areaType}
</foreach>
<if test="orgId != null and orgId !=-1">
and org_id= #{orgId}
</if>
and data_state = 1
</select>
<select id="queryAreaBlockByParentIdAndOrgId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tb_area_block
where parent_id =#{parentId}
and org_id= #{orgId}
and data_state = 1
</select>
<select id="queryAreaBlockByBlockId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tb_area_block
where id IN
<foreach collection="plBlockIds" item="plBlockId" index="index" open="(" separator="," close=")">
#{plBlockId}
</foreach>
and data_state = 1
</select>
<!-- 通过操作员ID+组织id查询块信息 -->
<select id="queryAreaBlockByOpIdAndOrgId" resultMap="BaseResultMap">
SELECT
c.id, c.area_code, c.area_name, c.area_type, c.parent_id, c.org_id, c.data_state
FROM
tb_area_block c
WHERE c.data_state=1
<if test="orgId != null and orgId !='' and orgId !='-1' ">
and c.org_id=#{orgId}
</if>
and c.area_type=#{areaType}
order by c.area_name
</select>
<!--检查块名称是否唯一-->
<select id="checkBlockNameUnique" parameterType="com.zteits.clouds.api.dto.sys.param.CheckBlockNameUniqueRequest" resultType="java.lang.Integer">
SELECT
count(1)
FROM
tb_area_block a
WHERE
a.data_state = 1
AND a.area_name=#{blockName}
</select>
<!-- 查询区域的下一级 -->
<select id="queryNextLowerLeverByIdForArea" parameterType="com.zteits.sys.domain.TbAreaBlock" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from tb_area_block
where data_state = 1
and parent_id=#{id}
</select>
</mapper>