use of com.bc.pmpheep.back.po.PmphPermission in project pmph by BCSquad.
the class PmphUserController method resources.
/**
* <pre>
* 功能描述:根据用户 id 跳转到用户权限的列表页面
* 使用示范:
*
* @param userId
* @param model
* @return
* </pre>
*/
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "查询指定用户 id 所拥有的权限")
@RequestMapping(value = "/resources/{id}", method = RequestMethod.GET)
public ResponseBean resources(@PathVariable("id") Long userId) {
Map<String, Object> result = new HashMap<String, Object>();
List<PmphPermission> resourceList = userService.getListAllResource(userId);
PmphUser user = userService.get(userId);
result.put("resources", resourceList);
result.put("user", user);
return new ResponseBean(result);
}
use of com.bc.pmpheep.back.po.PmphPermission in project pmph by BCSquad.
the class PmphUserRealm method doGetAuthorizationInfo.
/**
* 授权
*
* @param principalCollection
* @return
*/
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
logger.info("--- MyRealm doGetAuthorizationInfo ---");
// 获得经过认证的主体信息
PmphUser user = (PmphUser) principalCollection.getPrimaryPrincipal();
Long userId = user.getId();
// UserService userService = (UserService)InitServlet.getBean("userService");
List<PmphPermission> resourceList = null;
List<String> roleSnList = null;
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
try {
resourceList = userService.getListAllResource(userId);
roleSnList = userService.getListRoleSnByUser(userId);
List<String> resStrList = new ArrayList<>();
for (PmphPermission resource : resourceList) {
resStrList.add(resource.getUrl());
}
info.setRoles(new HashSet<>(roleSnList));
info.setStringPermissions(new HashSet<>(resStrList));
// 以上完成了动态地对用户授权
logger.info("role => " + roleSnList);
logger.info("permission => " + resStrList);
} catch (Exception e) {
logger.info("message => " + e);
}
return info;
}
use of com.bc.pmpheep.back.po.PmphPermission in project pmph by BCSquad.
the class PmphPermissionServiceTest method testDeletePmphPermissionById.
@Test
@Rollback(Const.ISROLLBACK)
public void testDeletePmphPermissionById() {
pmphPermissionService.addPmphPermission(pmphPermission);
Integer bInteger = pmphPermissionService.deletePmphPermissionById(new PmphPermission((pmphPermission.getId())));
Assert.assertTrue("删除失败", bInteger > 0);
}
use of com.bc.pmpheep.back.po.PmphPermission in project pmph by BCSquad.
the class PmphPermissionServiceTest method testGetPmphPermissionById.
@Test
@Rollback(Const.ISROLLBACK)
public void testGetPmphPermissionById() {
pmphPermissionService.addPmphPermission(pmphPermission);
PmphPermission pp = pmphPermissionService.getPmphPermissionById(new PmphPermission((pmphPermission.getId())));
Assert.assertNotNull("获取数据", pp);
}
use of com.bc.pmpheep.back.po.PmphPermission in project pmph by BCSquad.
the class PmphPermissionServiceImpl method getListAllParentMenu.
@Override
public List<PmphPermission> getListAllParentMenu() {
List<PmphPermission> permissions = pmphPermissionDao.getListAllParentMenu();
for (PmphPermission permission : permissions) {
List<PmphPermission> subList = this.getListChildMenuByParentId(permission.getId());
permission.setChildren(subList);
}
return permissions;
}
Aggregations