zhongrj
2023-12-20 7c533d448acabda7ec92d75757d760b447e41f00
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
<?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="org.springblade.modules.label.mapper.LabelMapper">
 
    <!--自定义列表-->
    <select id="selectLabelPage" resultType="org.springblade.modules.label.vo.LabelVO">
        select * from jczz_label where 1=1
    </select>
 
    <!--标签查询,按父id查询下级 mysql 5.7 有时会查询无结果-->
<!--    <select id="getLabelList" resultType="org.springblade.common.node.TreeIntegerNode">-->
<!--        SELECT-->
<!--            jl.id as id,jl.parent_id as parentId,jl.label_name as name-->
<!--        FROM-->
<!--            (-->
<!--            SELECT-->
<!--                @ids AS ids,-->
<!--                ( SELECT @ids := GROUP_CONCAT( id ) FROM jczz_label WHERE FIND_IN_SET( parent_id, @ids ) ) AS cids-->
<!--            FROM-->
<!--                jczz_label-->
<!--            WHERE-->
<!--                @ids IS NOT NULL-->
<!--                AND @ids := #{label.parentId}-->
<!--            ) id,-->
<!--            jczz_label jl-->
<!--        WHERE-->
<!--            FIND_IN_SET(jl.parent_id,ids)-->
<!--    </select>-->
 
    <!--标签查询,按父id查询下级-->
    <select id="getLabelList" resultType="org.springblade.common.node.TreeIntegerNode">
        SELECT
            jl.id as id,jl.parent_id as parentId,jl.label_name as name
        FROM
         jczz_label jl
        where parent_id = #{label.parentId}
    </select>
 
 
    <select id="getLabelTreeList" resultType="org.springblade.common.node.TreeIntegerNode">
        SELECT
            jl.id AS id,
            jl.parent_id AS parentId,
            jl.label_name AS NAME,
            jl.sort,
            (SELECT count(1) from jczz_user_house_label where label_id = jl.id ) count
        FROM
            jczz_label jl  where is_deleted = 0
    </select>
 
 
</mapper>