ny
昨天 b6f169fe43a2b13f351aefc152374fc7f0bc8cb7
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
package jnpf.permission.controller;
 
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import jnpf.annotation.OrganizeAdminIsTrator;
import jnpf.base.ActionResult;
import jnpf.base.PrintApi;
import jnpf.base.SystemApi;
import jnpf.base.UserInfo;
import jnpf.base.controller.SuperController;
import jnpf.base.entity.PrintDevEntity;
import jnpf.base.entity.SystemEntity;
import jnpf.base.model.base.SystemApiByIdsModel;
import jnpf.base.model.portalManage.PortalListVO;
import jnpf.base.model.portalManage.PortalVO;
import jnpf.base.model.portalManage.SavePortalAuthModel;
import jnpf.base.model.print.PaginationPrint;
import jnpf.base.vo.ListVO;
import jnpf.config.ConfigValueUtil;
import jnpf.constant.AuthorizeConst;
import jnpf.constant.MsgCode;
import jnpf.constant.PermissionConst;
import jnpf.database.model.superQuery.SuperJsonModel;
import jnpf.database.util.TenantDataSourceUtil;
import jnpf.flowable.TemplateApi;
import jnpf.flowable.entity.TemplateEntity;
import jnpf.flowable.model.template.TemplateTreeListVo;
import jnpf.model.login.UserSystemVO;
import jnpf.permission.AuthorizeApi;
import jnpf.permission.entity.*;
import jnpf.permission.model.authorize.*;
import jnpf.permission.model.columnspurview.ColumnsPurviewUpForm;
import jnpf.permission.service.*;
import jnpf.permission.util.AuthPermUtil;
import jnpf.util.JsonUtil;
import jnpf.util.NoDataSourceBind;
import jnpf.util.StringUtil;
import jnpf.util.UserProvider;
import jnpf.util.context.RequestContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * 操作权限
 *
 * @author JNPF开发平台组
 * @version V3.1.0
 * @copyright 引迈信息技术有限公司
 * @date 2019年9月26日 上午9:18
 */
@Tag(name = "操作权限", description = "Authorize")
@RestController
@RequestMapping("/Authority")
public class AuthorizeController extends SuperController<AuthorizeService, AuthorizeEntity> implements AuthorizeApi {
    @Autowired
    private AuthorizeService authorizeService;
    @Autowired
    private ColumnsPurviewService columnsPurviewService;
    @Autowired
    private PermissionGroupService permissionGroupService;
    @Autowired
    private SystemApi systemApi;
    @Autowired
    private TemplateApi templateApi;
    @Autowired
    private PrintApi printDevService;
    @Autowired
    private AuthPermUtil authPermUtil;
    @Autowired
    private OrganizeService organizeService;
    @Autowired
    private PositionService positionService;
    @Autowired
    private RoleRelationService roleRelationService;
    @Autowired
    private ConfigValueUtil configValueUtil;
 
    @Operation(summary = "获取岗位/角色/用户权限树形结构")
    @Parameters({
            @Parameter(name = "objectId", description = "对象主键", required = true),
            @Parameter(name = "dataValuesQuery", description = "权限值", required = true)
    })
    @SaCheckPermission(value = {"permission.auth", "permission.role"}, mode = SaMode.OR)
    @PostMapping("/Data/{objectId}/Values")
    public ActionResult<AuthorizeDataReturnVO> getValuesData(@PathVariable("objectId") String objectId, @RequestBody DataValuesQuery dataValuesQuery) {
        if (!StringUtil.isEmpty(dataValuesQuery.getType())) {
            AuthorizeParam authorizeParam = AuthorizeParam.builder()
                    .appCode(RequestContext.getAppCode())
                    .objectId(objectId)
                    .objectType(dataValuesQuery.getObjectType())
                    .itemType(dataValuesQuery.getType())
                    .moduleIds(dataValuesQuery.getModuleIds())
                    .build();
            AuthorizeDataReturnVO dataRes = authPermUtil.getAuthMenuList(authorizeParam);
            return ActionResult.success(dataRes);
        }
        return ActionResult.fail(MsgCode.PS012.get());
    }
 
    /**
     * 对象数据
     *
     * @return
     */
    @Operation(summary = "获取功能权限数据")
    @Parameters({
            @Parameter(name = "itemId", description = "对象主键", required = true),
            @Parameter(name = "objectType", description = "对象类型", required = true)
    })
    @SaCheckPermission(value = {"permission.auth", "permission.role", "onlineDev.visualPortal"}, mode = SaMode.OR)
    @GetMapping("/Model/{itemId}/{objectType}")
    public ActionResult<AuthorizeItemObjIdsVO> getObjectAuth(@PathVariable("itemId") String itemId, @PathVariable("objectType") String objectType) {
        List<AuthorizeEntity> authorizeList = authorizeService.getListByObjectAndItem(itemId, objectType);
        List<String> ids = authorizeList.stream().map(u -> u.getObjectId()).collect(Collectors.toList());
        AuthorizeItemObjIdsVO vo = new AuthorizeItemObjIdsVO();
        vo.setIds(ids);
        return ActionResult.success(vo);
    }
 
    @Operation(summary = "门户管理授权")
    @Parameters({
            @Parameter(name = "itemId", description = "对象主键", required = true),
            @Parameter(name = "saveAuthForm", description = "保存权限模型", required = true)})
    @PutMapping("/Model/{portalManageId}")
    @SaCheckPermission(value = {"permission.auth", "permission.role"}, mode = SaMode.OR)
    public ActionResult savePortalManage(@PathVariable("portalManageId") String portalManageId, @RequestBody SavePortalAuthModel model) {
        model.setId(portalManageId);
        model.setType(AuthorizeConst.AUTHORIZE_PORTAL_MANAGE);
        model.setIds(model.getObjectId());
        authorizeService.saveObjectAuth(model);
        return ActionResult.success(MsgCode.SU005.get());
    }
 
    /**
     * 保存
     *
     * @param objectId            对象主键
     * @param authorizeDataUpForm 修改权限模型
     * @return
     */
    @OrganizeAdminIsTrator
    @Operation(summary = "保存权限")
    @Parameters({
            @Parameter(name = "objectId", description = "对象主键", required = true),
            @Parameter(name = "authorizeDataUpForm", description = "修改权限模型", required = true)
    })
    @SaCheckPermission(value = {"permission.auth", "permission.role"}, mode = SaMode.OR)
    @PutMapping("/Data/{objectId}")
    public ActionResult save(@PathVariable("objectId") String objectId, @RequestBody AuthorizeDataUpForm authorizeDataUpForm) {
        authorizeDataUpForm.setObjectId(objectId);
        String err = authorizeService.save(authorizeDataUpForm);
        if (StringUtil.isNotEmpty(err)) {
            return ActionResult.success(err);
        }
        return ActionResult.success(MsgCode.SU005.get());
    }
 
    /**
     * 获取模块列表展示字段
     *
     * @param moduleId 菜单Id
     * @return
     */
    @Operation(summary = "获取模块列表展示字段")
    @Parameters({
            @Parameter(name = "moduleId", description = "菜单id", required = true)
    })
    @GetMapping("/GetColumnsByModuleId/{moduleId}")
    public ActionResult getColumnsByModuleId(@PathVariable("moduleId") String moduleId) {
        ColumnsPurviewEntity entity = columnsPurviewService.getInfo(moduleId);
        List<Map<String, Object>> jsonToListMap = null;
        if (entity != null) {
            jsonToListMap = JsonUtil.getJsonToListMap(entity.getFieldList());
        }
        return ActionResult.success(jsonToListMap != null ? jsonToListMap : new ArrayList<>(16));
    }
 
    /**
     * 配置模块列表展示字段
     *
     * @param columnsPurviewUpForm 修改模型
     * @return
     */
    @Operation(summary = "配置模块列表展示字段")
    @Parameters({
            @Parameter(name = "columnsPurviewUpForm", description = "修改模型", required = true)
    })
    @PutMapping("/SetColumnsByModuleId")
    public ActionResult setColumnsByModuleId(@RequestBody ColumnsPurviewUpForm columnsPurviewUpForm) {
        ColumnsPurviewEntity entity = JsonUtil.getJsonToBean(columnsPurviewUpForm, ColumnsPurviewEntity.class);
        columnsPurviewService.update(columnsPurviewUpForm.getModuleId(), entity);
        return ActionResult.success(MsgCode.SU005.get());
    }
 
    /**
     * 查看流程权限组
     *
     * @param id 主键
     * @return
     */
    @Operation(summary = "查看流程权限组")
    @Parameter(name = "id", description = "主键", required = true)
    @GetMapping("/GroupFlow/{id}")
    public ActionResult<ListVO<String>> groupFlow(@PathVariable("id") String id) {
        List<PermissionGroupEntity> data = permissionGroupService.list(true, null);
        List<String> objectId = data.stream().map(PermissionGroupEntity::getId).collect(Collectors.toList());
        List<String> groupId = authorizeService.getListByRoleIdsAndItemType(objectId, AuthorizeConst.FLOW).stream().filter(t -> t.getItemId().equals(id)).map(AuthorizeEntity::getObjectId).collect(Collectors.toList());
        List<String> groupList = data.stream().filter(t -> groupId.contains(t.getId())).map(PermissionGroupEntity::getId).collect(Collectors.toList());
        ListVO listVO = new ListVO<>();
        listVO.setList(groupList);
        return ActionResult.success(listVO);
    }
 
    /**
     * 保存流程权限
     *
     * @return
     */
    @Operation(summary = "保存流程权限")
    @Parameters({
            @Parameter(name = "id", description = "对象主键", required = true)
    })
    @PostMapping("/GroupFlow/{id}")
    public ActionResult groupFlow(@PathVariable("id") String id, @RequestBody SavePortalAuthModel model) {
        model.setId(id);
        model.setType(AuthorizeConst.FLOW);
        authorizeService.saveObjectAuth(model);
        return ActionResult.success(MsgCode.SU005.get());
    }
 
    /**
     * 保存流程权限
     *
     * @return
     */
    @Operation(summary = "保存流程权限")
    @Parameters({
            @Parameter(name = "id", description = "对象主键", required = true)
    })
    @PostMapping("/Flow/{id}")
    public ActionResult saveFlowAuth(@PathVariable("id") String id, @RequestBody SavePortalAuthModel model) {
        model.setId(id);
        model.setType(AuthorizeConst.FLOW);
        authorizeService.saveItemAuth(model);
        return ActionResult.success(MsgCode.SU005.get());
    }
 
    /**
     * 获取流程权限
     *
     * @return
     */
    @Operation(summary = "获取流程权限")
    @Parameters({
            @Parameter(name = "id", description = "对象主键", required = true)
    })
    @GetMapping("/Flow/{id}")
    public ActionResult<PortalVO> getFlowAuth(@PathVariable("id") String id, @RequestParam("objectType") String objectType) {
        UserInfo userInfo = UserProvider.getUser();
        Boolean isAdmin = userInfo.getIsAdministrator();
        Boolean isManageRole = userInfo.getIsManageRole();
        Boolean isDevRole = userInfo.getIsDevRole();
        PortalVO vo = new PortalVO();
        //全部流程
        List<TemplateTreeListVo> treeList = templateApi.treeListWithPower();
        //上级权限传递(treeList移除无权限的)
        treeList = filterParent(id, objectType, treeList, AuthorizeConst.FLOW);
        // 当前权限组权限
        List<AuthorizeEntity> authorizePortalManage = authorizeService.getListByObjectId(id, AuthorizeConst.FLOW);
        List<String> ids = authorizePortalManage.stream().map(AuthorizeEntity::getItemId).collect(Collectors.toList());
 
        List<String> idAll = new ArrayList<>();
 
        //当前用户拥有的权限
        if (isAdmin || isManageRole || isDevRole) {
            idList(treeList, idAll, null, ids);
        } else {
            List<AuthorizeEntity> list = authorizeService.getListByUserId(false, userInfo.getUserId(), true);
            List<String> itemIds = list.stream().filter(t -> AuthorizeConst.FLOW.equals(t.getItemType())).map(AuthorizeEntity::getItemId).collect(Collectors.toList());
            itemIds.addAll(templateApi.getListByCreUser(userInfo.getUserId()).stream().map(TemplateEntity::getId).collect(Collectors.toList()));
            //没有权限的禁用
            idList(treeList, idAll, itemIds, ids);
        }
 
        vo.setAll(idAll);
        vo.setIds(ids);
        vo.setList(JsonUtil.getJsonToList(treeList, PortalListVO.class));
        return ActionResult.success(vo);
    }
 
    /**
     * 根据itemIds,禁用以外的选项
     *
     * @param list    树形结构数据
     * @param idAll   提取全部id
     * @param itemIds 非禁用id列表
     */
    private void idList(List<TemplateTreeListVo> list, List<String> idAll, List<String> itemIds, List<String> selectIds) {
        for (TemplateTreeListVo vo : list) {
            vo.setDisabled(false);
            if (vo.getChildren() != null) {
                idList(vo.getChildren(), idAll, itemIds, selectIds);
                //子集有被禁用且被选中的的,那么上级肯定被禁用,如果没有被选中,那么只有全部禁用的情况才禁用
                boolean isDisabled = false;
                int n = 0;
                for (TemplateTreeListVo child : vo.getChildren()) {
                    if (child.getDisabled()) {
                        if (selectIds.contains(child.getId())) {
                            isDisabled = true;
                            break;
                        } else {
                            n++;
                        }
                    }
                }
                if (n == vo.getChildren().size()) {
                    isDisabled = true;
                }
                vo.setDisabled(isDisabled);
            } else {
                if (itemIds != null) {
                    if (!itemIds.contains(vo.getId())) {
                        vo.setDisabled(true);
                    }
                }
            }
            idAll.add(vo.getId());
        }
    }
 
    //根据List<String> 过滤树形数据
    private List<TemplateTreeListVo> filter(List<TemplateTreeListVo> list, List<String> filterList) {
        List<TemplateTreeListVo> listRes = new ArrayList<>(list);
        for (TemplateTreeListVo vo : list) {
            if (!filterList.contains(vo.getId())) {
                listRes.remove(vo);
            } else {
                if (CollectionUtil.isNotEmpty(vo.getChildren())) {
                    vo.setChildren(filter(vo.getChildren(), filterList));
                }
            }
        }
        return listRes;
    }
 
    //传递上级权限--过滤上级没有的权限
    private List<TemplateTreeListVo> filterParent(String id, String objectType, List<TemplateTreeListVo> treeList, String itemType) {
        boolean filter = false;
        List<String> filterList = new ArrayList<>();
        if (PermissionConst.ORGANIZE.equals(objectType)) {
            OrganizeEntity info = organizeService.getInfo(id);
            if (!"-1".equals(info.getParentId())) {
                filter = true;
                List<String> objectIds = new ArrayList<>();
                objectIds.add(info.getParentId());
                List<String> collect = roleRelationService.getListByObjectId(info.getParentId(), PermissionConst.ORGANIZE)
                        .stream().map(RoleRelationEntity::getRoleId).collect(Collectors.toList());
                objectIds.addAll(collect);
                filterList.addAll(authorizeService.getListByRoleIdsAndItemType(objectIds, itemType)
                        .stream().map(AuthorizeEntity::getItemId).collect(Collectors.toList()));
            }
        }
        if (PermissionConst.POSITION.equals(objectType)) {
            filter = true;
            PositionEntity info = positionService.getInfo(id);
            if (StringUtil.isEmpty(info.getParentId()) || "-1".equals(info.getParentId())) {
                //继承组织
                List<String> objectIds = new ArrayList<>();
                objectIds.add(info.getOrganizeId());
                List<String> collect = roleRelationService.getListByObjectId(info.getOrganizeId(), PermissionConst.ORGANIZE)
                        .stream().map(RoleRelationEntity::getRoleId).collect(Collectors.toList());
                objectIds.addAll(collect);
                filterList.addAll(authorizeService.getListByRoleIdsAndItemType(objectIds, itemType)
                        .stream().map(AuthorizeEntity::getItemId).collect(Collectors.toList()));
            } else {
                //继承上级岗位
                List<String> objectIds = new ArrayList<>();
                objectIds.add(info.getParentId());
                List<String> collect = roleRelationService.getListByObjectId(info.getParentId(), PermissionConst.POSITION)
                        .stream().map(RoleRelationEntity::getRoleId).collect(Collectors.toList());
                objectIds.addAll(collect);
                filterList.addAll(authorizeService.getListByRoleIdsAndItemType(objectIds, itemType)
                        .stream().map(AuthorizeEntity::getItemId).collect(Collectors.toList()));
            }
        }
        if (filter) {
            return filter(treeList, filterList);
        }
        return treeList;
    }
 
 
    /**
     * 保存打印权限
     *
     * @return
     */
    @Operation(summary = "保存打印权限")
    @Parameters({
            @Parameter(name = "id", description = "对象主键", required = true)
    })
    @PostMapping("/Print/{id}")
    public ActionResult savePrintAuth(@PathVariable("id") String id, @RequestBody SavePortalAuthModel model) {
        model.setId(id);
        model.setType(AuthorizeConst.PRINT);
        authorizeService.saveItemAuth(model);
        return ActionResult.success(MsgCode.SU005.get());
    }
 
    /**
     * 获取打印权限
     *
     * @return
     */
    @Operation(summary = "获取打印权限")
    @Parameters({
            @Parameter(name = "id", description = "对象主键", required = true)
    })
    @GetMapping("/Print/{id}")
    public ActionResult<PortalVO> getPrintAuth(@PathVariable("id") String id, @RequestParam("objectType") String objectType) {
        UserInfo userInfo = UserProvider.getUser();
        Boolean isAdmin = userInfo.getIsAdministrator();
        Boolean isManageRole = userInfo.getIsManageRole();
        Boolean isDevRole = userInfo.getIsDevRole();
        PortalVO vo = new PortalVO();
        PaginationPrint paginationPrint = new PaginationPrint();
        paginationPrint.setDataType(1);
        paginationPrint.setVisibleType(2);
        List<PrintDevEntity> list = printDevService.getWorkSelector(paginationPrint);
        List<String> systemIds = list.stream().map(PrintDevEntity::getSystemId).collect(Collectors.toList());
        List<SystemEntity> systemList = systemApi.getListByIds(new SystemApiByIdsModel(systemIds, null));
        List<TemplateTreeListVo> treeList = new ArrayList<>();
        for (SystemEntity dict : systemList) {
            TemplateTreeListVo tree = JsonUtil.getJsonToBean(dict, TemplateTreeListVo.class);
            List<PrintDevEntity> childList = list.stream()
                    .filter(e -> dict.getId().equals(e.getSystemId()))
                    .sorted(Comparator.comparing(PrintDevEntity::getSortCode, Comparator.nullsLast(Comparator.naturalOrder()))
                            .thenComparing(PrintDevEntity::getCreatorTime, Comparator.nullsLast(Comparator.reverseOrder()))).collect(Collectors.toList());
            if (childList.size() > 0) {
                List<TemplateTreeListVo> childListAll = new ArrayList<>();
                for (PrintDevEntity entity : childList) {
                    TemplateTreeListVo user = JsonUtil.getJsonToBean(entity, TemplateTreeListVo.class);
                    childListAll.add(user);
                }
                tree.setChildren(childListAll);
                treeList.add(tree);
            }
        }
        //上级权限传递(treeList移除无权限的)
        treeList = filterParent(id, objectType, treeList, AuthorizeConst.PRINT);
 
        // 当前权限组权限
        List<AuthorizeEntity> authorizePortalManage = authorizeService.getListByObjectId(id, AuthorizeConst.PRINT);
        List<String> ids = authorizePortalManage.stream().map(AuthorizeEntity::getItemId).collect(Collectors.toList());
 
        List<String> idAll = new ArrayList<>();
        //当前用户拥有的权限--没有权限禁用
        if (isAdmin || isManageRole || isDevRole) {
            idList(treeList, idAll, null, ids);
        } else {
            List<AuthorizeEntity> lista = authorizeService.getListByUserId(false, userInfo.getUserId(), true);
            List<String> itemIds = lista.stream().filter(t -> AuthorizeConst.PRINT.equals(t.getItemType())).map(AuthorizeEntity::getItemId).collect(Collectors.toList());
            itemIds.addAll(printDevService.getListByCreUser(userInfo.getUserId()).stream().map(PrintDevEntity::getId).collect(Collectors.toList()));
            //没有权限的禁用
            idList(treeList, idAll, itemIds, ids);
        }
 
        vo.setAll(idAll);
        vo.setIds(ids);
        vo.setList(JsonUtil.getJsonToList(treeList, PortalListVO.class));
        return ActionResult.success(vo);
    }
 
    //API调用接口,勿删!!!---------
 
    /**
     * 根据对象Id获取列表
     *
     * @param objectId 对象主键
     * @return
     */
    @Override
    @PostMapping("/GetListByObjectId")
    public List<AuthorizeEntity> getListByObjectId(@RequestBody List<String> objectId) {
        return authorizeService.getListByObjectId(objectId);
    }
 
    /**
     * 根据对象Id获取列表
     *
     * @param objectId 对象主键
     * @return
     */
    @Override
    @PostMapping("/GetListByObjectIdTenant")
    @NoDataSourceBind
    public List<AuthorizeEntity> GetListByObjectIdTenant(@RequestBody List<String> objectId, @RequestParam("tenantId") String tenantId) {
        if (configValueUtil.isMultiTenancy()) {
            //切换成租户库
            try{
                TenantDataSourceUtil.switchTenant(tenantId);
 
            }catch (Exception e){
                return Collections.EMPTY_LIST;
            }
        }
        return authorizeService.getListByObjectId(objectId);
    }
 
    /**
     * 根据对象Id获取列表
     *
     * @param objectId 对象主键
     * @param type     类型
     * @return
     */
    @Override
    @GetMapping("/GetListByObjectId/{objectId}/{type}")
    public List<AuthorizeEntity> getListByObjectId(@PathVariable("objectId") String objectId, @PathVariable("type") String type) {
        return authorizeService.getListByObjectId(objectId, type);
    }
 
    /**
     * 将查出来的某个对象删除
     *
     * @param id
     * @return
     */
    @Override
    @DeleteMapping("/remove")
    public void remove(@RequestParam("id") String id) {
        if (StringUtil.isNotEmpty(id)) {
            QueryWrapper<AuthorizeEntity> queryWrapper = new QueryWrapper<>();
            queryWrapper.lambda().eq(AuthorizeEntity::getObjectType, "role");
            queryWrapper.lambda().eq(AuthorizeEntity::getItemType, "portalManage");
            queryWrapper.lambda().eq(AuthorizeEntity::getItemId, id);
            authorizeService.remove(queryWrapper);
        }
    }
 
    @Override
    @GetMapping("/getAuthorize")
    public AuthorizeVO getAuthorize(
            @RequestParam("singletonOrg") boolean singletonOrg,
            @RequestParam(value = "currentSystemCode", required = false) String currentSystemCode,
            @RequestParam(value = "isBackend", required = false) Integer isBackend) {
        return authorizeService.getAuthorize(singletonOrg, currentSystemCode, isBackend);
    }
 
    @Override
    @GetMapping("/getAuthorizeByItem")
    public List<AuthorizeEntity> getAuthorizeByItem(@RequestParam(value = "itemType", required = false) String itemType,
                                                    @RequestParam(value = "itemId", required = false) String itemId) {
        return authorizeService.getAuthorizeByItem(itemType, itemId);
    }
 
    @Override
    @GetMapping("/getAuthorizeByUser")
    public AuthorizeVO getAuthorizeByUser(@RequestParam("singletonOrg") boolean singletonOrg) {
        return authorizeService.getAuthorizeByUser(singletonOrg);
    }
 
    @Override
    @GetMapping("/removeAuthByUserOrMenu")
    public void removeAuthByUserOrMenu(@RequestParam(value = "userIds", required = false) List<String> userIds
            , @RequestParam(value = "menuIds", required = false) List<String> menuIds) {
        authorizeService.removeAuthByUserOrMenu(userIds, menuIds);
    }
 
    @Override
    @GetMapping("/getListByObjectAndItemIdAndType")
    public List<AuthorizeEntity> getListByObjectAndItemIdAndType(@RequestParam(value = "itemId", required = false) String itemId,
                                                                 @RequestParam(value = "itemType", required = false) String itemType) {
        return authorizeService.getListByObjectAndItemIdAndType(itemId, itemType);
    }
 
    @Override
    @GetMapping("/getListByRoleIdsAndItemType")
    public List<AuthorizeEntity> getListByRoleIdsAndItemType(@RequestParam(value = "roleIds") List<String> roleIds, @RequestParam(value = "itemType") String itemType) {
        return authorizeService.getListByRoleIdsAndItemType(roleIds, itemType);
    }
 
    @Override
    @GetMapping("/getConditionSql")
    public List<SuperJsonModel> getConditionSql(@RequestParam(value = "moduleId") String moduleId, @RequestParam(value = "systemCode") String systemCode) {
        return authorizeService.getConditionSql(moduleId, systemCode);
    }
 
}