use of com.ganster.cms.auth.util.PInformationUtil in project Ganster-CMS by Gangster-trio.
the class AllotGroupController method updateGroup.
@RequestMapping("/update")
public int updateGroup(@RequestParam(value = "Group") Group group) {
this.index();
List<String> permissionName = this.getPermissionName("group", "updategroup");
Subject subject = SecurityUtils.getSubject();
for (String i : permissionName) {
if (subject.isPermitted(i)) {
PInformationUtil pInformationUtil = new PInformationUtil();
try {
pInformationUtil.dealInfromation(i);
Group needUpdateGroup = groupService.selectByPrimaryKey(Integer.parseInt(pInformationUtil.getId()));
if (needUpdateGroup.getGroupId().equals(group.getGroupId())) {
return groupService.updateByPrimaryKey(group);
} else
continue;
} catch (InformationException e) {
logger.info("权限信息异常");
}
}
}
return 0;
}
use of com.ganster.cms.auth.util.PInformationUtil 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.auth.util.PInformationUtil in project Ganster-CMS by Gangster-trio.
the class AllotGroupController method deleteGroup.
@RequestMapping("/delete")
public int deleteGroup(@RequestParam(value = "GroupId") Integer groupId) {
this.index();
Subject subject = SecurityUtils.getSubject();
List<String> permissionName = this.getPermissionName("group", "delectgroup");
for (String i : permissionName) {
if (subject.isPermitted(i)) {
PInformationUtil pInformationUtil = new PInformationUtil();
try {
pInformationUtil.dealInfromation(i);
Group group = groupService.selectByPrimaryKey(Integer.parseInt(pInformationUtil.getId()));
if (group.getGroupId().equals(groupId)) {
return groupService.deleteByPrimaryKey(groupId);
} else
continue;
} catch (InformationException e) {
logger.info("权限信息异常");
}
}
}
return 0;
}
use of com.ganster.cms.auth.util.PInformationUtil in project Ganster-CMS by Gangster-trio.
the class AllotGroupController method findGroups.
@RequestMapping("/find")
public List<Group> findGroups() {
this.index();
List<Group> groupList = new ArrayList<>();
Subject subject = SecurityUtils.getSubject();
List<String> permissionName = this.getPermissionName("group", "findgroup");
for (String i : permissionName) {
if (subject.isPermitted(i)) {
PInformationUtil pInformationUtil = new PInformationUtil();
try {
pInformationUtil.dealInfromation(i);
Group group = groupService.selectByPrimaryKey(Integer.parseInt(pInformationUtil.getId()));
if (group == null)
break;
groupList.add(group);
} catch (InformationException e) {
logger.info("权限信息异常");
}
}
}
return groupList;
}
Aggregations