use of com.ganster.cms.auth.Exception.InformationException 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.Exception.InformationException 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.auth.Exception.InformationException in project Ganster-CMS by Gangster-trio.
the class PInformationUtil method dealInfromation.
public void dealInfromation(String permissionInformation) throws InformationException {
PInformationUtil pInformationUtil = new PInformationUtil();
String[] dealResult = permissionInformation.split(":");
if (dealResult.length <= 2) {
permissionname = dealResult[0];
logger.info("---------------------------------------------------" + permissionname + "-----------------------------------");
id = dealResult[1];
logger.info("----------------------------------" + id + "-------------------------------------------");
pInformationUtil.setId(id);
pInformationUtil.setPermissionname(permissionname);
} else
throw new InformationException();
}
use of com.ganster.cms.auth.Exception.InformationException 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.Exception.InformationException 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