Search in sources :

Example 6 with GroupExample

use of com.ganster.cms.core.pojo.GroupExample 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

Group (com.ganster.cms.core.pojo.Group)6 GroupExample (com.ganster.cms.core.pojo.GroupExample)6 AjaxData (com.ganster.cms.admin.dto.AjaxData)3 GroupNotFountException (com.ganster.cms.core.exception.GroupNotFountException)3 Permission (com.ganster.cms.core.pojo.Permission)3 ArrayList (java.util.ArrayList)3 InformationException (com.ganster.cms.auth.Exception.InformationException)2 PermissionNotFoundException (com.ganster.cms.core.exception.PermissionNotFoundException)2 UserNotFoundException (com.ganster.cms.core.exception.UserNotFoundException)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 GroupWithPermission (com.ganster.cms.admin.dto.GroupWithPermission)1 PInformationUtil (com.ganster.cms.auth.util.PInformationUtil)1 RInformationUtil (com.ganster.cms.auth.util.RInformationUtil)1 PageInfo (com.github.pagehelper.PageInfo)1 Subject (org.apache.shiro.subject.Subject)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1