IMCategoryMapper.xml
2.6 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
<?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.dao.IMCategoryDao">
<!-- 查询父类分类和子类分类
<select id="listImCategory" resultMap="listIMCategory" useCache="true" statementType="PREPARED">
SELECT
g.im_category_id, g.name, g.image_url, g.sort_index,
g2.im_category_id cim_category_id, g2.name cim_name, g2.image_url cim_image_url, g2.sort_index cim_index
FROM
im_category g left join im_category g2 ON g2.child_category_id = g.im_category_id
WHERE
g.child_category_id IS NULL and g.delete_flag = 1
</select>
-->
<select id="listImCategory" resultMap="listParentIMCategory" 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
</select>
<select id="listChildrenImCategory" parameterType="String" resultMap="listParentIMCategory" 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.child_category_id = #{categoryId} and g.delete_flag = 1
order by g.sort_index asc
</select>
<resultMap type="IMCategoryBean" id="listParentIMCategory">
<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" />
</resultMap>
<resultMap type="IMCategoryBean" id="listIMCategory">
<result column="im_category_id" property="imCategoryId" />
<result column="name" property="name" />
<result column="image_url" property="imageUrl" />
<result column="sort_index" property="sortIndex" />
<collection property="childs" column="child_category_id" ofType="IMCategoryBean">
<result property="imCategoryId" column="cim_category_id" javaType="String" jdbcType="VARCHAR"/>
<result property="name" column="cim_name" javaType="String" jdbcType="VARCHAR"/>
<result property="imageUrl" column="cim_image_url" javaType="String" jdbcType="VARCHAR"/>
<result property="sortIndex" column="cim_index" javaType="Integer" jdbcType="INTEGER"/>
</collection>
</resultMap>
</mapper>