shenyijian
2024-06-21 f20611265f7d34fd4fbcdfdaff6cb9cccd0b25fc
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
<?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.gistack.sm.sjztmd.mapper.AttBasBaseMapper">
    <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode">
        <id column="id" property="id"/>
        <result column="parent_id" property="parentId"/>
        <result column="title" property="title"/>
        <result column="value" property="value"/>
        <result column="key" property="key"/>
        <result column="has_children" property="hasChildren"/>
    </resultMap>
    <!--namespace根据自己需要创建的的mapper的路径和名称填写-->
    <select id="lazyTree" resultType="cn.gistack.sm.sjztmd.vo.AttBasBaseVO">
        select distinct
            a."code" AS "code",
            a."name" AS "name",
            a."grad" AS "grad",
            a."p_code" AS "pCode",
        ( SELECT CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END FROM "SJZT_MD"."att_bas_base" WHERE "p_code" = a."code" ) AS "hasChildren"
        from "SJZT_MD"."att_bas_base" a
        left join "SJZT_MD"."rel_ad_bas_loc" b on (a."code" = b."bas_code" )
        left join "SJZT_MD"."att_ad_base" b2 on (b."ad_code" = b2."p_ad_code" )
        left join "SJZT_MD"."att_ad_base" b3 on (b2."guid" = b3."p_ad_code" )
        left join "SJZT_MD"."att_ad_base" b4 on (b2."guid" = b4."p_ad_code" )
        <where>
            <if test="param1!=null">
                and (b."ad_code" = #{param1} or b2."ad_code" = #{param1} or b3."ad_code" = #{param1})
            </if>
            and a."grad" = 1
        </where>
 
        ORDER BY a."grad"
    </select>
 
    <select id="selectListByCode" resultType="cn.gistack.sm.sjztmd.vo.AttBasBaseVO">
        select * from "SJZT_MD"."att_bas_base"
        <where>
            <if test="param1!=null">
                and "p_code" = #{param1}
            </if>
        </where>
    </select>
 
</mapper>