Blame view

backend/sys/src/main/resources/mapper/SysMenuMapper.xml 5.73 KB
8ea9c133   陈威   初始化提交
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?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.hotent.sys.persistence.dao.SysMenuDao">
	<resultMap id="SysMenu" type="com.hotent.sys.persistence.model.SysMenu">
		<id property="id" column="ID_" jdbcType="VARCHAR"/>
		<result property="parentId" column="PARENT_ID_" jdbcType="VARCHAR"/>
		<result property="name" column="NAME_" jdbcType="VARCHAR"/>
		<result property="alias" column="ALIAS_" jdbcType="VARCHAR"/>
		<result property="menuIcon" column="MENU_ICON_" jdbcType="VARCHAR"/>
		<result property="open" column="OPENED_" jdbcType="NUMERIC"/>
		<result property="sn" column="SN_" jdbcType="NUMERIC"/>
		<result property="activeTab" column="ACTIVE_TAB_" jdbcType="VARCHAR"/>
		<result property="tabsStyle" column="TABS_STYLE_" jdbcType="VARCHAR"/>
		<result property="path" column="PATH_" jdbcType="VARCHAR"/>
        <result property="href" column="HREF_" jdbcType="VARCHAR"/>
        <result property="tenantId" column="tenant_id_" jdbcType="VARCHAR"/>
        <result property="type" column="TYPE_" jdbcType="VARCHAR"/>
	</resultMap>


	<select id="getByAlias"   parameterType="java.lang.String" resultMap="SysMenu">
		SELECT * FROM portal_sys_menu
		WHERE
		ALIAS_=#{alias}
		<if test="tenantIds != null and tenantIds.size>0">
			and tenant_id_ in
			<foreach collection="tenantIds" item="tenantId" separator="," open="(" close=")">
				#{tenantId}
			</foreach>
		</if>
	</select>


	<select id="isExistByAlias"   parameterType="java.lang.String"  resultType="int">
		SELECT count(1) FROM portal_sys_menu
		WHERE
		ALIAS_=#{alias}
	</select>

	<select id="isExistPlateformByAlias"   parameterType="java.util.List"  resultType="int">
		SELECT count(1) FROM portal_sys_menu
		WHERE
		ALIAS_=#{alias}
		<if test="tenantIds != null and tenantIds.size>0">
			and tenant_id_ in
			<foreach collection="tenantIds" item="tenantId" separator="," open="(" close=")">
				#{tenantId}
			</foreach>
		</if>
	</select>


	<select id="getByParentId"   parameterType="java.lang.String" resultMap="SysMenu">
		SELECT * FROM portal_sys_menu
		WHERE
		PARENT_ID_=#{parentId}
	</select>

	<select id="getByChidrensParentPath"   parameterType="java.lang.String" resultMap="SysMenu">
		SELECT * FROM portal_sys_menu
		WHERE
		PATH_ like concat("",#{path},"%")
	</select>

	<select id="getByChidrensParentPath"  databaseId="oracle" parameterType="java.lang.String" resultMap="SysMenu">
		SELECT * FROM portal_sys_menu
		WHERE
		PATH_ like concat(#{path},'%')
	</select>

	<select id="getByChidrensParentPath"  databaseId="pg" parameterType="java.lang.String" resultMap="SysMenu">
		SELECT * FROM portal_sys_menu
		WHERE
		PATH_ like concat_ws('',#{path},'%')
	</select>

	<select id="getMenuByRoleAlias"   parameterType="java.util.List" resultMap="SysMenu">
		select * from portal_sys_menu sysMenu
		LEFT JOIN portal_sys_role_auth sysRoleAuth on sysMenu.ALIAS_ = sysRoleAuth.MENU_ALIAS_
		WHERE sysRoleAuth.ROLE_ALIAS_ IN
		<foreach collection="roles" item="role" separator="," open="(" close=")">
			#{role}
		</foreach>
		<if test="tenantId!=null">
			AND	sysRoleAuth.TENANT_ID_=#{tenantId}
		</if>
		<if test="ignoreMenus!=null">
			AND sysMenu.ALIAS_ NOT IN
			<foreach collection="ignoreMenus" item="ignoreMenu" separator="," open="(" close=")">
	      		#{ignoreMenu}
	   		</foreach>
		</if>
		<if test="tenantIds != null and tenantIds.size>0">
			and sysMenu.tenant_id_ in
			<foreach collection="tenantIds" item="tenantId" separator="," open="(" close=")">
				#{tenantId}
			</foreach>
		</if>
   		ORDER BY SN_ ASC
	</select>

	<select id="getMenuByRoleAlias" databaseId="oracle" parameterType="java.util.List" resultMap="SysMenu">
		select sysMenu.* from portal_sys_menu sysMenu
		LEFT JOIN portal_sys_role_auth sysRoleAuth on sysMenu.ALIAS_ = sysRoleAuth.MENU_ALIAS_
		WHERE sysRoleAuth.ROLE_ALIAS_ IN
		<foreach collection="roles" item="role" separator="," open="(" close=")">
			#{role}
		</foreach>
		<if test="tenantId!=null">
			AND	sysRoleAuth.TENANT_ID_=#{tenantId}
		</if>
		<if test="ignoreMenus!=null">
			AND sysMenu.ALIAS_ NOT IN
			<foreach collection="ignoreMenus" item="ignoreMenu" separator="," open="(" close=")">
				#{ignoreMenu}
			</foreach>
		</if>
		<if test="tenantIds != null and tenantIds.size>0">
			and sysMenu.tenant_id_ in
			<foreach collection="tenantIds" item="tenantId" separator="," open="(" close=")">
				#{tenantId}
			</foreach>
		</if>
		ORDER BY SN_ ASC
	</select>

	<select id="getAllMenuRoleAlias"   parameterType="string" resultType="map">
		SELECT ID_ AS "id",PARENT_ID_ "parentId",NAME_ "name",ALIAS_ "alias", tenant_id_,
	    (SELECT COUNT(tmp.ID_) FROM portal_sys_menu tmp WHERE tmp.PARENT_ID_ = sysMenu.ID_ ) "isParent",
	    (SELECT count(tmpB.id_) FROM portal_sys_role_auth tmpB WHERE tmpB.menu_alias_ = sysMenu.ALIAS_ AND tmpB.ROLE_ALIAS_ = #{roleAlias}
	   	 	<if test="tenantId!=null">
				AND tmpB.TENANT_ID_ = #{tenantId}
			</if>
	    ) "checked",
		(SELECT DISTINCT IS_OPEN_ FROM portal_sys_role_auth tmpB WHERE tmpB.menu_alias_ = sysMenu.ALIAS_ AND tmpB.ROLE_ALIAS_ = #{roleAlias}
		<if test="tenantId!=null">
			AND tmpB.TENANT_ID_ = #{tenantId}
		</if>
		) "isOpen"
		FROM
		portal_sys_menu sysMenu
		${ew.customSqlSegment}
	</select>

	<select id="getByTemplateAlias" parameterType="java.lang.String" resultMap="SysMenu">
		SELECT * FROM portal_sys_menu
		WHERE
		ROUTE_EXTEND_ like concat("%",#{templateAlias},"%")
		<if test="pathPrefix!=null">
			AND	PATH_ like concat("",#{pathPrefix},"%")
		</if>
	</select>

	<select id="getByLikeAlias" parameterType="java.lang.String" resultMap="SysMenu">
		SELECT * FROM portal_sys_menu
		WHERE
		ALIAS_ like concat("%",#{alias},"%")
		<if test="pathPrefix!=null">
			AND	PATH_ like concat("",#{pathPrefix},"%")
		</if>
	</select>
</mapper>