xiaoyong931011
2021-06-29 e5c78c0e75059580f1b66efc8b99f2cd8313589f
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.xzx.gc.shop.mapper.ScoreGoodsCategoryMapper">
 
    <resultMap id="goodsCategoryMap" type="com.xzx.gc.shop.vo.GoodsCategoryVo">
        <id column="id" property="id" />
        <result column="name" property="name" />
        <collection property="children" ofType="com.xzx.gc.shop.vo.GoodsCategoryVo">
            <id column="c_id" property="id" />
            <result column="c_name" property="name" />
        </collection>
    </resultMap>
 
    <select id="selectCategoryWithChildren" resultMap="goodsCategoryMap">
        select a.id id, a.name name, b.id c_id, b.name c_name
        from xzx_score_goods_category a
        left join xzx_score_goods_category b on a.id=b.parent_id
        where a.parent_id=0
    </select>
 
    <select id="queryGoodsCategoryList" resultType="com.xzx.gc.shop.vo.QueryGoodsCategoryListVo">
        SELECT
               a.*,
        a.CREATED_TIME createTime
        FROM
        xzx_score_goods_category a
        WHERE 1 = 1
        <if test="record.name != null and record.name != ''">
            and a.name like concat('%',#{record.name},'%')
        </if>
        <if test="record.categoryIden != null and record.categoryIden != ''">
            and a.category_iden=#{record.categoryIden}
        </if>
        <if test="record.parentId != null and record.parentId != ''">
            and a.parent_id=#{record.parentId}
        </if>
        order by a.CREATED_TIME desc
    </select>
 
    <select id="viewGoodsCategoryOneList" resultType="com.xzx.gc.shop.vo.ViewGoodsCategoryListVo">
        SELECT
        a.*,
        a.CREATED_TIME createTime
        FROM
        xzx_score_goods_category a
        WHERE 1 = 1
            and a.parent_id=#{parentId}
    </select>
 
    <select id="viewGoodsCategoryList" resultType="com.xzx.gc.shop.vo.ViewGoodsCategoryListVo">
        SELECT
            a.*,
            a.CREATED_TIME createTime,
               (select name from xzx_score_goods_category where a.parent_id = id) parentName
        FROM
            xzx_score_goods_category a
        WHERE 1 = 1
    </select>
 
</mapper>