Search in sources :

Example 1 with GroupWithPermission

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;
}
Also used : GroupWithPermission(com.ganster.cms.admin.dto.GroupWithPermission) Group(com.ganster.cms.core.pojo.Group) GroupExample(com.ganster.cms.core.pojo.GroupExample) ArrayList(java.util.ArrayList) Permission(com.ganster.cms.core.pojo.Permission) GroupWithPermission(com.ganster.cms.admin.dto.GroupWithPermission) AjaxData(com.ganster.cms.admin.dto.AjaxData) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

AjaxData (com.ganster.cms.admin.dto.AjaxData)1 GroupWithPermission (com.ganster.cms.admin.dto.GroupWithPermission)1 Group (com.ganster.cms.core.pojo.Group)1 GroupExample (com.ganster.cms.core.pojo.GroupExample)1 Permission (com.ganster.cms.core.pojo.Permission)1 ArrayList (java.util.ArrayList)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1