CustomMenuMapper.xml
17.1 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<?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.engine.portalTs.mapper.customMenu.CustomMenuMapper">
<!-- List<Menu> findById(String menuType);-->
<!--select * from menucustom where menutype = #{menuType} and menuparentid = '0' order by convert(menuindex,SIGNED) asc-->
<select id="findById" resultMap="resultMap1" databaseId="mysql">
select * from (
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharevalue = #{departmentId} and menushareinfo.sharetype= '1' and menucustom.menutype = #{menuType}
union
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharevalue = #{subcompanyId} and menushareinfo.sharetype= '6' and menucustom.menutype = #{menuType}
union
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharetype= '3' and menucustom.menutype = #{menuType}
union
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharevalue = #{uId} and menushareinfo.sharetype= '5' and menucustom.menutype = #{menuType}
union
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharetype= '2' and menucustom.menutype = #{menuType}
union
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharevalue = #{jobId} and menushareinfo.sharetype= '7' and menucustom.menutype = #{menuType}
union
select menucustom.*, -1 as shareId from menucustom where (select count(1) from menushareinfo where menushareinfo.customid = menucustom.menutype and menushareinfo.infoid = menucustom.id) = 0 and menucustom.menutype = #{menuType}
) as lr order by convert(menuindex,SIGNED) asc
</select>
<!--select * from menucustom where menutype = #{menuType} and menuparentid = '0' order by convert(int,menuindex) asc-->
<select id="findById" resultMap="resultMap1" databaseId="sqlserver">
select * from (
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharevalue = #{departmentId} and menushareinfo.sharetype= '1' and menucustom.menutype = #{menuType}
union
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharevalue = #{subcompanyId} and menushareinfo.sharetype= '6' and menucustom.menutype = #{menuType}
union
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharetype= '3' and menucustom.menutype = #{menuType}
union
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharevalue = #{uId} and menushareinfo.sharetype= '5' and menucustom.menutype = #{menuType}
union
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharetype= '2' and menucustom.menutype = #{menuType}
union
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharevalue = #{jobId} and menushareinfo.sharetype= '7' and menucustom.menutype = #{menuType}
union
select menucustom.*, -1 as shareId from menucustom where (select count(1) from menushareinfo where menushareinfo.customid = menucustom.menutype and menushareinfo.infoid = menucustom.id) = 0 and menucustom.menutype = #{menuType}
) as lr order by convert(int,menuindex) asc
</select>
<!--select * from menucustom where menutype = #{menuType} and menuparentid = '0' order by to_number(menuindex) asc-->
<select id="findById" resultMap="resultMap1">
select * from (
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharevalue = #{departmentId} and menushareinfo.sharetype= '1' and menucustom.menutype = #{menuType}
union
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharevalue = #{subcompanyId} and menushareinfo.sharetype= '6' and menucustom.menutype = #{menuType}
union
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharetype= '3' and menucustom.menutype = #{menuType}
union
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharevalue = #{uId} and menushareinfo.sharetype= '5' and menucustom.menutype = #{menuType}
union
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharetype= '2' and menucustom.menutype = #{menuType}
union
select menucustom.*,menushareinfo.id as shareId from menucustom,menushareinfo where menucustom.menutype = menushareinfo.customid and menucustom.id = menushareinfo.infoid and menushareinfo.sharevalue = #{jobId} and menushareinfo.sharetype= '7' and menucustom.menutype = #{menuType}
union
select menucustom.*, -1 as shareId from menucustom where (select count(1) from menushareinfo where menushareinfo.customid = menucustom.menutype and menushareinfo.infoid = menucustom.id) = 0 and menucustom.menutype = #{menuType}
) lr order by to_number(menuindex) asc
</select>
<resultMap id="resultMap1" type="com.engine.portalTs.entity.customMenu.Menu">
<result column="id" property="id"></result>
<result column="menuname" property="name"></result>
<result column="menuhref" property="url"></result>
<result column="menutarget" property="openType"></result>
<result column="menuparentid" property="parentId"></result>
<result column="setting" property="setting"></result>
<association property="shareItem" select="com.engine.portalTs.mapper.customMenu.CustomMenuMapper.findShareItemById" column="shareId"></association>
</resultMap>
<select id="findShareItemById" resultMap="resultMap3">
select * from menushareinfo where id = #{id}
</select>
<resultMap id="resultMap3" type="com.engine.portalTs.entity.customMenu.ShareItem">
<id column="id" property="id"></id>
<result column="seclevel" property="secLevel"></result>
<result column="jobtitlelevel" property="jobTitleLevel"></result>
<result column="jobtitlesharevalue" property="jobTitleShareValue"></result>
<result column="sharetype" property="shareType"></result>
<result column="sharevalue" property="shareValue"></result>
<result column="rolelevel" property="roleLevel"></result>
</resultMap>
<!--List<Menu> filterNoRightMenusOfIds(@Param("ids") String ids, @Param("subcompanyId") String subcompanyId, @Param("departmentId") String departmentId, @Param("jobId") String jobId, @Param("uId") String uId);-->
<select id="filterNoRightMenusOfIds" resultMap="resultMap1" databaseId="mysql">
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharevalue = #{departmentId} and menushareinfo.sharetype= '1' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharevalue = #{subcompanyId} and menushareinfo.sharetype= '6' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharetype= '3' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharevalue = #{uId} and menushareinfo.sharetype= '5' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharetype= '2' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharevalue = #{jobId} and menushareinfo.sharetype= '7' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
<foreach collection="ids" item="id" separator="union">
select case when(count(1) =0) then convert(${id},SIGNED) else -1 end as id, -1 as shareId from menushareinfo where menushareinfo.infoid = #{id} and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
</foreach>
</select>
<select id="filterNoRightMenusOfIds" resultMap="resultMap1" databaseId="sqlserver">
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharevalue = #{departmentId} and menushareinfo.sharetype= '1' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharevalue = #{subcompanyId} and menushareinfo.sharetype= '6' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharetype= '3' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharevalue = #{uId} and menushareinfo.sharetype= '5' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharetype= '2' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharevalue = #{jobId} and menushareinfo.sharetype= '7' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
<foreach collection="ids" item="id" separator="union">
select case when(count(1) =0) then convert(int,${id}) else -1 end as id, -1 as shareId from menushareinfo where menushareinfo.infoid = #{id} and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
</foreach>
</select>
<select id="filterNoRightMenusOfIds" resultMap="resultMap1">
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharevalue = #{departmentId} and menushareinfo.sharetype= '1' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharevalue = #{subcompanyId} and menushareinfo.sharetype= '6' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharetype= '3' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharevalue = #{uId} and menushareinfo.sharetype= '5' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharetype= '2' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
select menushareinfo.infoid as id,menushareinfo.id as shareId from menushareinfo where menushareinfo.infoid in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and menushareinfo.sharevalue = #{jobId} and menushareinfo.sharetype= '7' and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
union
<foreach collection="ids" item="id" separator="union">
select case when(count(1) =0) then to_number(${id}) else -1 end as id, -1 as shareId from menushareinfo where menushareinfo.infoid = #{id} and resourceType = #{resourceType} and resourceid = #{resourceId} and menutype = #{menuType}
</foreach>
</select>
</mapper>