Search in sources :

Example 1 with GroupExample

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

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

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

the class UserController method findAllGroup.

/**
 * 查找所有的用户组
 * @return AjaxData  查找到的信息
 */
@GetMapping("/findgroup")
@ResponseBody
public AjaxData findAllGroup() {
    int number = 0;
    AjaxData ajaxData = new AjaxData();
    GroupExample groupExample = new GroupExample();
    groupService.selectByExample(groupExample);
    List<Group> groupList = groupService.selectByExample(groupExample);
    if (groupList != null && !groupList.isEmpty()) {
        ajaxData.setData((ArrayList) groupList);
        for (Group i : groupList) {
            number++;
        }
        ajaxData.setCode(number);
        return ajaxData;
    }
    ajaxData.setMsg("查找失败");
    return ajaxData;
}
Also used : Group(com.ganster.cms.core.pojo.Group) GroupExample(com.ganster.cms.core.pojo.GroupExample) AjaxData(com.ganster.cms.admin.dto.AjaxData)

Example 4 with GroupExample

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

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

the class UserController method findUserGroup.

/**
 * 通过用户Id,查找所属于的的用户组
 *
 * @param userId
 * @param page
 * @param limit
 * @return  AjaxData 通过用户Id,查找所属于的用户组
 */
@GetMapping("/findgroup/{UserId}")
@ResponseBody
public AjaxData findUserGroup(@PathVariable("UserId") Integer userId, @RequestParam(required = false) Integer page, @RequestParam(required = false) Integer limit) {
    AjaxData ajaxData = new AjaxData();
    PageInfo pageInfo;
    int count = 0;
    GroupExample groupExample = new GroupExample();
    List<Group> groupList = groupService.selectByUserId(userId);
    if (groupList != null && !groupList.isEmpty()) {
        for (Group i : groupList) {
            count++;
        }
        if (page != null && limit != null) {
            pageInfo = PageHelper.startPage(page, limit).doSelectPageInfo(() -> groupService.selectByExample(groupExample));
            return super.buildAjaxData(0, "success", count, (ArrayList) groupList);
        } else {
            pageInfo = PageHelper.startPage(0, 0).doSelectPageInfo(() -> groupService.selectByExample(groupExample));
            return super.buildAjaxData(0, "success", count, (ArrayList) groupList);
        }
    }
    ajaxData.setMsg("查找失败");
    return ajaxData;
}
Also used : Group(com.ganster.cms.core.pojo.Group) PageInfo(com.github.pagehelper.PageInfo) GroupExample(com.ganster.cms.core.pojo.GroupExample) AjaxData(com.ganster.cms.admin.dto.AjaxData)

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