Search in sources :

Example 6 with Permission

use of com.ganster.cms.core.pojo.Permission in project Ganster-CMS by Gangster-trio.

the class GetPermissionUtil method getPermissionName.

public List<String> getPermissionName(String groupName) {
    List<String> permissionName = new ArrayList<>();
    PInformationUtil pInformationUtil = new PInformationUtil();
    GroupExample groupExample = new GroupExample();
    logger.info("++++++++++++++++" + groupService);
    logger.info("+++++++++++++++++++" + groupName);
    groupExample.createCriteria().andGroupNameEqualTo(groupName);
    logger.info("++++++++++++++++++++++" + groupExample.toString());
    List<Group> groupList = groupService.selectByExample(groupExample);
    for (Group group : groupList) {
        try {
            List<Permission> permissionList = permissionService.selectByGroupId(group.getGroupId());
            for (Permission i : permissionList) {
                int j = 0;
                try {
                    pInformationUtil.dealInfromation(i.getPermissionName());
                    String name = "findgroup" + ":" + pInformationUtil.getId();
                    permissionName.add(name);
                    j++;
                } catch (Exception e) {
                    break;
                }
            }
        } catch (GroupNotFountException e) {
            e.printStackTrace();
        }
    }
    return permissionName;
}
Also used : Group(com.ganster.cms.core.pojo.Group) GroupNotFountException(com.ganster.cms.core.exception.GroupNotFountException) GroupExample(com.ganster.cms.core.pojo.GroupExample) ArrayList(java.util.ArrayList) Permission(com.ganster.cms.core.pojo.Permission) GroupNotFountException(com.ganster.cms.core.exception.GroupNotFountException)

Example 7 with Permission

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

Permission (com.ganster.cms.core.pojo.Permission)7 Group (com.ganster.cms.core.pojo.Group)5 GroupNotFountException (com.ganster.cms.core.exception.GroupNotFountException)3 GroupExample (com.ganster.cms.core.pojo.GroupExample)3 ArrayList (java.util.ArrayList)3 PermissionNotFoundException (com.ganster.cms.core.exception.PermissionNotFoundException)2 User (com.ganster.cms.core.pojo.User)2 UserExample (com.ganster.cms.core.pojo.UserExample)2 SimpleAuthorizationInfo (org.apache.shiro.authz.SimpleAuthorizationInfo)2 Subject (org.apache.shiro.subject.Subject)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 AjaxData (com.ganster.cms.admin.dto.AjaxData)1 GroupWithPermission (com.ganster.cms.admin.dto.GroupWithPermission)1 InformationException (com.ganster.cms.auth.Exception.InformationException)1 PInformationUtil (com.ganster.cms.auth.util.PInformationUtil)1 UserNotFoundException (com.ganster.cms.core.exception.UserNotFoundException)1 PermissionExample (com.ganster.cms.core.pojo.PermissionExample)1 GroupService (com.ganster.cms.core.service.GroupService)1 PermissionService (com.ganster.cms.core.service.PermissionService)1 UserService (com.ganster.cms.core.service.UserService)1