Search in sources :

Example 1 with RInformationUtil

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

the class AllotGroupController method addGroup.

@RequestMapping("/add")
public void addGroup(@RequestParam(value = "UserId") Integer userId, @RequestParam(value = "GroupName") String groupName) {
    this.index();
    GroupExample groupExample = new GroupExample();
    groupExample.createCriteria().andGroupNameEqualTo(groupName);
    List<Group> groupList = groupService.selectByExample(groupExample);
    if (userId != null) {
        try {
            if (groupList == null) {
                RInformationUtil rInformationUtil = new RInformationUtil();
                rInformationUtil.dealInfromation(groupName);
                Group group = new Group();
                group.setGroupName(groupName);
                groupService.insert(group);
                groupService.addUserToGroup(userId, groupName);
            // groupService.addCategoryPermissionToGroup(groupName,"update:"+group.getGroupId());
            // groupService.addCategoryPermissionToGroup(groupName, "delete:" + group.getGroupId());
            // groupService.addCategoryPermissionToGroup(groupName,"find:"+group.getGroupId());
            } else {
                for (Group i : groupList) {
                    groupService.addUserToGroup(userId, i.getGroupName());
                }
            }
        } catch (UserNotFoundException e) {
            logger.info("用户未找到");
        } catch (GroupNotFountException e) {
            logger.info("用户组未找到");
        } catch (InformationException e) {
            logger.info("用户组信息不正确");
        } catch (PermissionNotFoundException e) {
            logger.info("用户组未找到");
        } catch (Exception e) {
            logger.info("信息错误");
        }
    }
}
Also used : UserNotFoundException(com.ganster.cms.core.exception.UserNotFoundException) InformationException(com.ganster.cms.auth.Exception.InformationException) Group(com.ganster.cms.core.pojo.Group) GroupNotFountException(com.ganster.cms.core.exception.GroupNotFountException) GroupExample(com.ganster.cms.core.pojo.GroupExample) RInformationUtil(com.ganster.cms.auth.util.RInformationUtil) PermissionNotFoundException(com.ganster.cms.core.exception.PermissionNotFoundException) 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) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with RInformationUtil

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

the class AllotGroupController method index.

public String index() {
    RInformationUtil rInformationUtil = new RInformationUtil();
    Subject subject = SecurityUtils.getSubject();
    Integer id = (Integer) subject.getSession().getAttribute("id");
    List<Group> group = groupService.selectByUserId(id);
    List<String> groupName = new ArrayList<>();
    for (Group i : group) {
        try {
            rInformationUtil.dealInfromation(i.getGroupName());
            groupName.add(rInformationUtil.getRolename());
        } catch (Exception e) {
            logger.info("++++++++++++++++++++ index        错误++++++++++++++++++++");
            return "/403.html";
        }
    }
    for (String i : groupName) {
        if (groupName.equals("group"))
            return "ok";
    }
    return "/login/403.html";
}
Also used : Group(com.ganster.cms.core.pojo.Group) RInformationUtil(com.ganster.cms.auth.util.RInformationUtil) ArrayList(java.util.ArrayList) 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)

Aggregations

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