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;
}
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;
}
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;
}
Aggregations