ElectricFenceMapper.xml
6.92 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?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="cn.com.glsx.admin.modules.mapper.ElectricFenceMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.admin.modules.entity.ElectricFence">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="fence_name" jdbcType="VARCHAR" property="fenceName"/>
<result column="biz_fence_type" jdbcType="TINYINT" property="bizFenceType"/>
<result column="location_type" jdbcType="TINYINT" property="locationType"/>
<result column="shape_type" jdbcType="TINYINT" property="shapeType"/>
<result column="radius" jdbcType="INTEGER" property="radius"/>
<result column="trigger_type" jdbcType="TINYINT" property="triggerType"/>
<result column="time_type" jdbcType="TINYINT" property="timeType"/>
<result column="start_time" jdbcType="DATE" property="startTime"/>
<result column="end_time" jdbcType="DATE" property="endTime"/>
<result column="enable_status" jdbcType="TINYINT" property="enableStatus"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="area_code" jdbcType="VARCHAR" property="areaCode"/>
<result column="area_text" jdbcType="VARCHAR" property="areaText"/>
<result column="analysis_address" jdbcType="VARCHAR" property="analysisAddress"/>
<result column="tel_numbers" jdbcType="VARCHAR" property="telNumbers"/>
<result column="record" jdbcType="VARCHAR" property="record"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="cn.com.glsx.admin.modules.entity.ElectricFence">
<!--
WARNING - @mbg.generated
-->
<result column="lnglat" jdbcType="LONGVARCHAR" property="lnglat"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, fence_name, biz_fence_type, location_type, shape_type, radius,
trigger_type, time_type, start_time, end_time, `enable_status`, remark, area_code, area_text,
record, analysis_address, tel_numbers, del_flag, created_date, created_by,
updated_date, updated_by
</sql>
<sql id="Blob_Column_List">
<!--
WARNING - @mbg.generated
-->
lnglat
</sql>
<select id="selectById" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>,
<include refid="Blob_Column_List"/>
from t_electric_fence
where del_flag = 0
and id = #{id}
</select>
<select id="selectByUserIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>,
<include refid="Blob_Column_List"/>
from t_electric_fence
where del_flag = 0
and created_by in
<foreach collection="userIds" separator="," open="(" close=")" item="userId">
#{userId}
</foreach>
</select>
<select id="selectByFenceNameAndBizType" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_electric_fence
where del_flag = 0
and fence_name = #{fenceName}
and biz_fence_type = #{bizFenceType}
limit 1
</select>
<select id="selectAllNotDel" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>,
<include refid="Blob_Column_List"/>
from t_electric_fence
where del_flag = 0
</select>
<select id="selectAllNotSync" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>,
<include refid="Blob_Column_List"/>
from t_electric_fence
where del_flag = 0
and sync_flag = 0
</select>
<update id="updateSyncFlagById">
update t_electric_fence
set sync_flag = 1
where id = #{id}
</update>
<select id="search" resultType="cn.com.glsx.admin.modules.model.ElectricFenceDTO">
select tef.id fenceId,
tef.fence_name fenceName,
tu.username shopName,
tu.account shopCode,
ttds.shop_level shopLevel,
tef.created_date createdDate,
tef.created_by createdBy,
tef.biz_fence_type as bizFenceType,
ta.status approvalStatus,
ta.remark approvalRemark
from t_electric_fence tef
left join t_user tu on tu.id = tef.created_by
left join t_trial_drive_shop ttds on ttds.created_by = tu.id and ttds.del_flag = 0
left join t_electric_fence_copy tefc on tefc.fence_id = tef.id
left join (select * from t_approval where id in (select MAX(id) from t_approval group by biz_id,biz_type)) ta on
ta.biz_id = tefc.id and ta.biz_type = 1
where tef.del_flag = 0
and tef.biz_fence_type = 12
<if test="term != null and term !=''">
and (
tu.username like CONCAT('%',#{term},'%')
or
tu.account like CONCAT('%',#{term},'%')
or
tef.fence_name like CONCAT('%',#{term},'%')
)
</if>
order by tef.id desc
</select>
<select id="export" resultType="cn.com.glsx.admin.modules.model.export.ElectricFenceExport">
select tef.id fenceId,
tef.fence_name fenceName,
tu.username shopName,
tu.account shopCode,
ttds.shop_level shopLevel,
tef.created_date createdDate,
tef.created_by createdBy,
tef.biz_fence_type bizFenceType,
ta.status approvalStatus,
ta.remark approvalRemark
from t_electric_fence tef
left join t_user tu on tu.id = tef.created_by
left join t_trial_drive_shop ttds on ttds.created_by = tu.id
left join t_electric_fence_copy tefc on tefc.fence_id = tef.id
left join (select * from t_approval where id in (select MAX(id) from t_approval group by biz_id,biz_type)) ta on
ta.biz_id = tefc.id and ta.biz_type = 1
where tef.del_flag = 0 and ttds.del_flag = 0
and tef.biz_fence_type = 12
<if test="term != null and term !=''">
and (
tu.username like CONCAT('%',#{term},'%')
or
tu.account like CONCAT('%',#{term},'%')
or
tef.fence_name like CONCAT('%',#{term},'%')
)
</if>
order by tef.id desc
</select>
<update id="logicDeleteById">
update t_electric_fence
set del_flag = -1
where id = #{id}
</update>
</mapper>