IMCategoryMapper.xml
10.5 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?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.sibu.orderHelper.integral.web.dao.IMWebCategoryDao">
<select id="listImCategory" resultMap="IMAddCategory" useCache="true" statementType="PREPARED" parameterType="map">
SELECT
g.im_category_id, g.name, g.image_url, g.sort_index,g.type_id,g.category_type,g.remark,g.create_dt,g.update_dt,g.delete_flag,g.child_category_id,g.create_member_id
FROM
im_category g
WHERE
g.delete_flag = 1
ORDER BY g.sort_index ASC,g.`create_dt` DESC
limit ${pageNow}, ${pageSize}
</select>
<!-- 取出首页分类 -->
<select id="listShowImCategory" resultMap="listShowIMCategory" useCache="true">
SELECT
g.im_category_id, g.name, g.image_url, g.sort_index, g.type_id, g.category_type
FROM
im_category g
WHERE
g.delete_flag = 1 and (g.child_category_id IS NULL or g.child_category_id = '')
order by g.sort_index asc ,g.create_dt DESC
</select>
<resultMap type="IMAddCategoryBean" id="listShowIMCategory">
<result column="im_category_id" property="imCategoryId" />
<result column="name" property="name" />
<result column="image_url" property="imageUrl" />
<result column="sort_index" property="sortIndex" />
<result column="type_id" property="typeId" />
<result column="category_type" property="categoryType" />
<result column="service_charge_rate" property="serviceChargeRate" />
</resultMap>
<select id="countImCategory" resultType="int">
select count(1) from im_category where delete_flag = 1;
</select>
<select id="listParentImCategory" parameterType="String" resultMap="IMCategory" useCache="true">
SELECT
g.im_category_id, g.name, g.image_url, g.sort_index,g.category_type,g.type_id,g.remark,g.create_dt,g.update_dt,g.delete_flag,g.child_category_id,g.create_member_id
FROM
im_category g
WHERE
g.child_category_id IS NULL or g.child_category_id = '' and g.delete_flag = 1
ORDER BY g.sort_index ASC,g.create_dt DESC
</select>
<select id="listChildrenImCategory" parameterType="String" resultMap="childCategory" useCache="true">
SELECT
g.im_category_id, g.name, g.image_url, g.sort_index,g.type_id,g.category_type,g.remark,g.create_dt,g.update_dt,g.delete_flag,g.child_category_id,g.create_member_id,
child.im_category_id as c_im_category_id , child.name as c_name, child.image_url as c_image_url,
child.sort_index as c_sort_index,child.type_id as c_type_id,child.category_type as c_category_type,
child.remark as c_remark,child.create_dt as c_create_dt,child.update_dt as c_update_dt,
child.delete_flag c_delete_flag,child.child_category_id as c_child_category_id,child.create_member_id as c_create_member_id
FROM
im_category g left join im_category child
on g.im_category_id=child.child_category_id and child.delete_flag=1
WHERE
g.child_category_id = #{categoryId} and g.delete_flag = 1
order by g.sort_index asc,g.create_dt DESC ,child.sort_index asc,child.create_dt DESC
</select>
<select id="getSecondCategory" parameterType="String" resultMap="IMAddCategory">
SELECT im_category_id,type_id,category_type,NAME,sort_index,remark,create_member_id,delete_flag,child_category_id
FROM im_category cate1 WHERE cate1.im_category_id=
(SELECT cate2.child_category_id FROM im_category cate2
WHERE cate2.im_category_id=#{categoryId})
</select>
<select id="get" resultMap="IMAddCategory" parameterType="String">
SELECT
im_category_id,type_id,category_type,name,image_url,sort_index,remark,create_member_id,
create_dt,update_dt,delete_flag,child_category_id,service_charge_rate
FROM
im_category
WHERE
im_category_id=#{categoryId}
</select>
<select id="getFirstCategoryBeans" resultMap="IMAddCategory" parameterType="String">
SELECT im_category_id,category_type,name FROM
im_category
WHERE delete_flag=1 and name=#{name}
</select>
<select id="getSecondCategoryBeans" resultMap="IMAddCategory" parameterType="map">
SELECT im_category_id,category_type,name,child_category_id FROM
im_category
WHERE delete_flag=1 and name=#{name} AND child_category_id=#{firstCategoryId}
</select>
<select id="getCategoryBeans" resultMap="IMAddCategory" parameterType="map">
SELECT im_category_id,category_type,name,child_category_id FROM
im_category
WHERE delete_flag=1 and name=#{name} AND child_category_id=#{secondCategoryId}
</select>
<insert id="add" parameterType="IMAddCategoryBean">
insert into
im_category(im_category_id,category_type,name,image_url,sort_index,remark,create_member_id,create_dt,update_dt,delete_flag,
child_category_id,service_charge_rate)
values(
#{imCategoryId},
#{categoryType},
#{name},
#{imageUrl},
#{sortIndex},
#{remark},
#{createMemberId},
now(),
now(),
1,
#{childCategoryId},
#{serviceChargeRate}
)
</insert>
<update id="update" parameterType="IMAddCategoryBean">
UPDATE im_category SET
category_type=#{categoryType},
name=#{name},
image_url=#{imageUrl},
sort_index=#{sortIndex},
remark=#{remark},
update_dt=now(),
child_category_id=#{childCategoryId},
service_charge_rate=#{serviceChargeRate}
WHERE im_category_id=#{imCategoryId}
</update>
<update id="delete" parameterType="String" >
UPDATE im_category SET delete_flag=0
WHERE im_category_id=#{categoryId}
</update>
<resultMap type="IMCategoryBean" id="IMCategory">
<result column="im_category_id" property="imCategoryId" />
<result column="type_id" property="typeId" />
<result column="category_type" property="categoryType" />
<result column="name" property="name" />
<result column="image_url" property="imageUrl" />
<result column="sort_index" property="sortIndex" />
<result column="remark" property="remark" />
<result column="create_member_id" property="createMemberId" />
<result column="create_dt" property="createDt" />
<result column="update_dt" property="updateDt" />
<result column="delete_flag" property="deleteFlag" />
<result column="child_category_id" property="childCategoryId" />
</resultMap>
<resultMap type="com.sibu.orderHelper.integral.model.IMCategoryBean" id="IMAddCategory">
<result column="im_category_id" property="imCategoryId" />
<result column="type_id" property="typeId" />
<result column="category_type" property="categoryType" />
<result column="name" property="name" />
<result column="image_url" property="imageUrl" />
<result column="sort_index" property="sortIndex" />
<result column="remark" property="remark" />
<result column="create_member_id" property="createMemberId" />
<result column="create_dt" property="createDt" />
<result column="update_dt" property="updateDt" />
<result column="delete_flag" property="deleteFlag" />
<result column="child_category_id" property="childCategoryId" />
<result column="service_charge_rate" property="serviceChargeRate" />
</resultMap>
<!-- 一对多包含三级分类 -->
<resultMap type="IMAddCategoryBean" id="childCategory">
<result column="im_category_id" property="imCategoryId" />
<result column="type_id" property="typeId" />
<result column="category_type" property="categoryType" />
<result column="name" property="name" />
<result column="image_url" property="imageUrl" />
<result column="sort_index" property="sortIndex" />
<result column="remark" property="remark" />
<result column="create_member_id" property="createMemberId" />
<result column="create_dt" property="createDt" />
<result column="update_dt" property="updateDt" />
<result column="delete_flag" property="deleteFlag" />
<result column="child_category_id" property="childCategoryId" />
<collection property="childs" ofType="IMAddCategoryBean">
<result column="c_im_category_id" property="imCategoryId" />
<result column="c_type_id" property="typeId" />
<result column="c_category_type" property="categoryType" />
<result column="c_name" property="name" />
<result column="c_image_url" property="imageUrl" />
<result column="c_sort_index" property="sortIndex" />
<result column="c_remark" property="remark" />
<result column="c_create_member_id" property="createMemberId" />
<result column="c_create_dt" property="createDt" />
<result column="c_update_dt" property="updateDt" />
<result column="c_delete_flag" property="deleteFlag" />
<result column="c_child_category_id" property="childCategoryId" />
</collection>
</resultMap>
<select id="checkCategoryName" resultMap="IMAddCategory" parameterType="map">
SELECT im_category_id,category_type,name FROM im_category
WHERE delete_flag=1 and category_type=#{categoryType} and name=#{name}
</select>
<select id="listParentCategoryBySysUser" parameterType="String" resultMap="IMCategory" useCache="true">
SELECT
g.im_category_id, g.name, g.image_url, g.sort_index,g.category_type,g.type_id,g.remark,g.create_dt,g.update_dt,g.delete_flag,g.child_category_id,g.create_member_id
FROM
im_category g
WHERE
g.child_category_id IS NULL or g.child_category_id = '' and g.delete_flag = 1 AND category_type = 1
order by g.sort_index asc,g.create_dt DESC
</select>
<select id="listSellerCategory" parameterType="String" resultMap="IMCategory" useCache="true">
SELECT
g.im_category_id, g.name, g.image_url, g.sort_index,g.category_type,g.type_id,g.remark,g.create_dt,g.update_dt,g.delete_flag,g.child_category_id,g.create_member_id
FROM
im_category g
WHERE g.child_category_id IS NULL or g.child_category_id = '' and g.delete_flag = 1
and g.name=#{name}
ORDER BY g.sort_index ASC,g.create_dt DESC
</select>
</mapper>