zf
2023-08-30 9ca0dc6e7833715b875cc9b6b91d5c497b2bae8b
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
<?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.gk.hotwork.Mapper.ElementManagementMapper" >
  <resultMap id="BaseResultMap" type="com.gk.hotwork.Domain.ElementManagement" >
    <!--          -->
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="valid_flag" property="validFlag" jdbcType="TINYINT" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="create_by" property="createBy" jdbcType="VARCHAR" />
    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
    <result column="update_by" property="updateBy" jdbcType="VARCHAR" />
 
    <result column="name" property="name" jdbcType="BIGINT" />
    <result column="type" property="type" jdbcType="VARCHAR" />
    <result column="parent_id" property="parentId" jdbcType="VARCHAR" />
    <result column="parent_name" property="parentName" jdbcType="VARCHAR" />
    <result column="remark" property="remark" jdbcType="VARCHAR" />
    <result column="point" property="point" jdbcType="VARCHAR" />
    <result column="weight" property="weight" />
    <result column="menu_type" property="menuType" jdbcType="VARCHAR"/>
  </resultMap>
  <select id="selectPages" resultMap="BaseResultMap">
    select a.*,
    b.name parent_name
    from element_management as a
    left join element_management as b on a.parent_id = b.id and b.valid_flag = 1
    where a.valid_flag = 1
    <if test="params.name != null  and params.name != ''">
      and a.name like concat("%",#{params.name},"%")
    </if>
    <if test="params.type != null  ">
      and a.type = #{params.type}
    </if>
    order by a.create_time desc
  </select>
 
  <select id="getElementByType" resultMap="BaseResultMap">
    select *  from element_management where valid_flag = 1 and type = #{type}
  </select>
  
  
 <!-- <select id="getElementTree" resultType="java.util.Map">
      select DISTINCT t.label,t.mt,t.type,t.pid,t.value,(case when (t.keyw is null and t.type>0) then  1 else  0 end ) as isLeaf from(
    select t1.mt,t1.label,t1.type,t1.value,t1.pid,t2.label as keyw
    from (select name as label,menu_type as mt,type,id as value,parent_id as pid from element_management WHERE valid_flag=1) t1  left join (select name as label,type,id as value,      parent_id as pid from element_management WHERE valid_flag=1) t2
    on t1.value=t2.pid) t
  </select>-->
  <select id="getElementTree" resultType="java.util.Map">
    SELECT DISTINCT
      t.label,
      t.mt,
      t.type,
      t.pid,
      t.point,
      t.value,
      (CASE
 
         WHEN ( t.keyw IS NULL AND t.type > 0 ) THEN
           1 ELSE 0
        END ) AS isLeaf
    FROM
      (
        SELECT
          t1.mt,
          t1.label,
          t1.type,
          t1.value,
          t1.pid,
          t1.point,
          t2.label AS keyw
        FROM
          ( SELECT
              name AS label,
              menu_type AS mt,
              type,
              id AS value,
              parent_id AS pid,
              point
            FROM
              element_management
            WHERE
              valid_flag = 1
          ) t1
            LEFT JOIN ( SELECT name AS label, type, id AS value, parent_id AS pid FROM element_management WHERE valid_flag = 1 ) t2 ON t1.value= t2.pid
      ) t
  </select>
 
</mapper>