Переглянути джерело

获取角色精简信息列表 增加筛选条件

gaohp 1 рік тому
батько
коміт
3220772252

+ 3 - 1
feifan-module-system/feifan-module-system-biz/src/main/java/cn/newfeifan/mall/module/system/controller/admin/permission/RoleController.java

@@ -23,6 +23,7 @@ import javax.validation.Valid;
 import java.io.IOException;
 import java.util.Comparator;
 import java.util.List;
+import java.util.stream.Collectors;
 
 import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
 import static cn.newfeifan.mall.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
@@ -87,9 +88,10 @@ public class RoleController {
 
     @GetMapping({"/list-all-simple", "/simple-list"})
     @Operation(summary = "获取角色精简信息列表", description = "只包含被开启的角色,主要用于前端的下拉选项")
-    public CommonResult<List<RoleSimpleRespVO>> getSimpleRoleList() {
+    public CommonResult<List<RoleSimpleRespVO>> getSimpleRoleList(@RequestParam("categoryId") Integer categoryId) {
         List<RoleDO> list = roleService.getRoleListByStatus(singleton(CommonStatusEnum.ENABLE.getStatus()));
         list.sort(Comparator.comparing(RoleDO::getSort));
+        list = list.stream().filter(k -> k.getCategoryId().equals(categoryId)).collect(Collectors.toList());
         return success(BeanUtils.toBean(list, RoleSimpleRespVO.class));
     }