Search in sources :

Example 1 with PInformationUtil

use of com.ganster.cms.auth.util.PInformationUtil in project Ganster-CMS by Gangster-trio.

the class AllotGroupController method updateGroup.

@RequestMapping("/update")
public int updateGroup(@RequestParam(value = "Group") Group group) {
    this.index();
    List<String> permissionName = this.getPermissionName("group", "updategroup");
    Subject subject = SecurityUtils.getSubject();
    for (String i : permissionName) {
        if (subject.isPermitted(i)) {
            PInformationUtil pInformationUtil = new PInformationUtil();
            try {
                pInformationUtil.dealInfromation(i);
                Group needUpdateGroup = groupService.selectByPrimaryKey(Integer.parseInt(pInformationUtil.getId()));
                if (needUpdateGroup.getGroupId().equals(group.getGroupId())) {
                    return groupService.updateByPrimaryKey(group);
                } else
                    continue;
            } catch (InformationException e) {
                logger.info("权限信息异常");
            }
        }
    }
    return 0;
}
Also used : InformationException(com.ganster.cms.auth.Exception.InformationException) Group(com.ganster.cms.core.pojo.Group) Subject(org.apache.shiro.subject.Subject) PInformationUtil(com.ganster.cms.auth.util.PInformationUtil) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with PInformationUtil

use of com.ganster.cms.auth.util.PInformationUtil in project Ganster-CMS by Gangster-trio.

the class AllotGroupController method getPermissionName.

public List<String> getPermissionName(String groupName, String permission) {
    List<String> permissionName = new ArrayList<>();
    PInformationUtil pInformationUtil = new PInformationUtil();
    Subject subject = SecurityUtils.getSubject();
    Integer id = (Integer) subject.getSession().getAttribute("id");
    GroupExample groupExample = new GroupExample();
    groupExample.createCriteria().andGroupNameEqualTo(groupName + ":" + id);
    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 = permission + ":" + 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) ArrayList(java.util.ArrayList) PInformationUtil(com.ganster.cms.auth.util.PInformationUtil) Subject(org.apache.shiro.subject.Subject) GroupNotFountException(com.ganster.cms.core.exception.GroupNotFountException) PermissionNotFoundException(com.ganster.cms.core.exception.PermissionNotFoundException) UserNotFoundException(com.ganster.cms.core.exception.UserNotFoundException) InformationException(com.ganster.cms.auth.Exception.InformationException) GroupExample(com.ganster.cms.core.pojo.GroupExample) Permission(com.ganster.cms.core.pojo.Permission)

Example 3 with PInformationUtil

use of com.ganster.cms.auth.util.PInformationUtil in project Ganster-CMS by Gangster-trio.

the class AllotGroupController method deleteGroup.

@RequestMapping("/delete")
public int deleteGroup(@RequestParam(value = "GroupId") Integer groupId) {
    this.index();
    Subject subject = SecurityUtils.getSubject();
    List<String> permissionName = this.getPermissionName("group", "delectgroup");
    for (String i : permissionName) {
        if (subject.isPermitted(i)) {
            PInformationUtil pInformationUtil = new PInformationUtil();
            try {
                pInformationUtil.dealInfromation(i);
                Group group = groupService.selectByPrimaryKey(Integer.parseInt(pInformationUtil.getId()));
                if (group.getGroupId().equals(groupId)) {
                    return groupService.deleteByPrimaryKey(groupId);
                } else
                    continue;
            } catch (InformationException e) {
                logger.info("权限信息异常");
            }
        }
    }
    return 0;
}
Also used : InformationException(com.ganster.cms.auth.Exception.InformationException) Group(com.ganster.cms.core.pojo.Group) Subject(org.apache.shiro.subject.Subject) PInformationUtil(com.ganster.cms.auth.util.PInformationUtil) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with PInformationUtil

use of com.ganster.cms.auth.util.PInformationUtil in project Ganster-CMS by Gangster-trio.

the class AllotGroupController method findGroups.

@RequestMapping("/find")
public List<Group> findGroups() {
    this.index();
    List<Group> groupList = new ArrayList<>();
    Subject subject = SecurityUtils.getSubject();
    List<String> permissionName = this.getPermissionName("group", "findgroup");
    for (String i : permissionName) {
        if (subject.isPermitted(i)) {
            PInformationUtil pInformationUtil = new PInformationUtil();
            try {
                pInformationUtil.dealInfromation(i);
                Group group = groupService.selectByPrimaryKey(Integer.parseInt(pInformationUtil.getId()));
                if (group == null)
                    break;
                groupList.add(group);
            } catch (InformationException e) {
                logger.info("权限信息异常");
            }
        }
    }
    return groupList;
}
Also used : InformationException(com.ganster.cms.auth.Exception.InformationException) Group(com.ganster.cms.core.pojo.Group) ArrayList(java.util.ArrayList) Subject(org.apache.shiro.subject.Subject) PInformationUtil(com.ganster.cms.auth.util.PInformationUtil) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

InformationException (com.ganster.cms.auth.Exception.InformationException)4 PInformationUtil (com.ganster.cms.auth.util.PInformationUtil)4 Group (com.ganster.cms.core.pojo.Group)4 Subject (org.apache.shiro.subject.Subject)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ArrayList (java.util.ArrayList)2 GroupNotFountException (com.ganster.cms.core.exception.GroupNotFountException)1 PermissionNotFoundException (com.ganster.cms.core.exception.PermissionNotFoundException)1 UserNotFoundException (com.ganster.cms.core.exception.UserNotFoundException)1 GroupExample (com.ganster.cms.core.pojo.GroupExample)1 Permission (com.ganster.cms.core.pojo.Permission)1