use of com.ganster.cms.admin.dto.GroupWithPermission in project Ganster-CMS by Gangster-trio.
the class GroupController method getGroupList.
/**
* 用户组的查询(包含权限)
*
* @return AjaxData
*/
@RequestMapping(value = "/find")
@ResponseBody
public AjaxData getGroupList() {
// 查询所有的用户组
GroupExample groupExample = new GroupExample();
List<Group> groupList = groupService.selectByExample(groupExample);
List<GroupWithPermission> gpList = new ArrayList<>();
Set<Permission> permissionList;
for (Group group : groupList) {
permissionList = permissionService.selectByGroupId(group.getGroupId());
List<String> permissionNameList = new ArrayList<>();
if (permissionList != null) {
for (Permission permission : permissionList) {
String permissionNames = permission.getPermissionName();
permissionNameList.add(permissionNames);
}
}
GroupWithPermission groupWithPermission = new GroupWithPermission(group, permissionNameList);
gpList.add(groupWithPermission);
}
/* List permissionNameList = groupList.stream()
.map(group ->
permissionService.selectByGroupId(group.getGroupId()).stream()
.map(Permission::getPermissionName)
).collect(Collectors.toList());
for (Object o:permissionNameList){
System.out.println(o);
}*/
AjaxData ajaxData = new AjaxData();
ajaxData.setMsg("success");
ajaxData.setCount(gpList.size());
ajaxData.setData(gpList);
return ajaxData;
}
Aggregations