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;
}
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("信息错误");
}
}
}
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;
}
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;
}
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;
}
Aggregations