Search in sources :

Example 6 with AjaxData

use of com.ganster.cms.admin.dto.AjaxData in project Ganster-CMS by Gangster-trio.

the class PermissionController method findGroup.

/**
 * 查找所有角色组
 *
 * @param groupId  用户组id
 * @return  AjaxData 查找到的所有角色组
 */
@GetMapping("/findGroupName/{GroupId}")
public AjaxData findGroup(@PathVariable("GroupId") Integer groupId) {
    AjaxData ajaxData = new AjaxData();
    Group group = groupService.selectByPrimaryKey(groupId);
    List<Group> groupList = new ArrayList<>();
    groupList.add(group);
    ajaxData.setData(groupList);
    return ajaxData;
}
Also used : AjaxData(com.ganster.cms.admin.dto.AjaxData) ArrayList(java.util.ArrayList)

Example 7 with AjaxData

use of com.ganster.cms.admin.dto.AjaxData 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)

Example 8 with AjaxData

use of com.ganster.cms.admin.dto.AjaxData 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

AjaxData (com.ganster.cms.admin.dto.AjaxData)8 Group (com.ganster.cms.core.pojo.Group)3 GroupExample (com.ganster.cms.core.pojo.GroupExample)3 ArrayList (java.util.ArrayList)2 GroupWithPermission (com.ganster.cms.admin.dto.GroupWithPermission)1 Permission (com.ganster.cms.core.pojo.Permission)1 PageInfo (com.github.pagehelper.PageInfo)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1