use of com.ibeiliao.deployment.admin.vo.account.AccountRoleRelation in project Corgi by kevinYin.
the class MenuServiceImpl method gainHasPermissionMenu.
/**
* 获取有权限的菜单
*
* @param accountId
* @param menuList
* @return
*/
private List<MenuPO> gainHasPermissionMenu(long accountId, List<MenuPO> menuList) {
if (adminAccountService.isSuperAdmin(accountId)) {
return menuList;
}
// 读取角色
List<AccountRoleRelation> accountRoleList = adminAccountService.listAccountRoles(accountId);
List<RoleMenuRelation> roleMenuList = new LinkedList<>();
// 读取每个角色的菜单ID
for (AccountRoleRelation arr : accountRoleList) {
roleMenuList.addAll(roleService.listRoleMenus(arr.getRoleId()));
}
Set<Integer> accountMenuIdSet = new HashSet<>(roleMenuList.size());
for (RoleMenuRelation rmr : roleMenuList) {
accountMenuIdSet.add(Integer.valueOf(rmr.getMenuId()));
}
// 判断哪个菜单有权限
List<MenuPO> list = new LinkedList<>();
StringBuilder buf = new StringBuilder(1024);
for (MenuPO menuPO : menuList) {
if (accountMenuIdSet.contains(Integer.valueOf(menuPO.getMenuId()))) {
list.add(menuPO);
if (buf.length() > 0)
buf.append(" , ");
buf.append(menuPO.getMenuId()).append(": ").append(menuPO.getMenuName());
}
}
return list;
}
use of com.ibeiliao.deployment.admin.vo.account.AccountRoleRelation in project Corgi by kevinYin.
the class MenuServiceImpl method listMenuResourceByAccount.
@Override
public List<UrlResource> listMenuResourceByAccount(long accountId, int appId) {
// 读取角色
List<AccountRoleRelation> accountRoleList = adminAccountService.listAccountRoles(accountId);
// List<RoleMenuRelation> roleMenuList = new LinkedList<>();
// 读取每个角色的菜单ID
// for (AccountRoleRelation arr : accountRoleList) {
// roleMenuList.addAll(roleService.listRoleMenus(arr.getRoleId()));
// }
/*
Map<Integer, UrlResourcePO> resourceMap = new HashMap<>(roleMenuList.size() * 4 + 16);
for (RoleMenuRelation rmr : roleMenuList) {
List<UrlResourcePO> tmpList = menuResourcesRelationDao.listSpecResourceByMenu(rmr.getMenuId(), appId);
for (UrlResourcePO res : tmpList) {
Integer resId = res.getResId();
if (!resourceMap.containsKey(resId)) {
resourceMap.put(resId, res);
}
}
}
Collection<UrlResourcePO> collections = resourceMap.values();
return VOUtil.fromList(collections, UrlResource.class);
*/
Map<Integer, UrlResourcePO> resourceMap = new HashMap<>(10);
for (AccountRoleRelation arr : accountRoleList) {
List<UrlResourcePO> list = roleResRelationDao.listResourceByRole(arr.getRoleId());
for (UrlResourcePO res : list) {
Integer resId = res.getResId();
if (!resourceMap.containsKey(resId)) {
resourceMap.put(resId, res);
}
}
}
Collection<UrlResourcePO> collections = resourceMap.values();
return VOUtil.fromList(collections, UrlResource.class);
}
use of com.ibeiliao.deployment.admin.vo.account.AccountRoleRelation in project Corgi by kevinYin.
the class ListAccountController method listAccount.
/**
* 读取管理员列表
* @param keyword 搜索的关键字
* @param page 第几页
* @param pageSize 每页多少
* @return result.object=数据列表,数据列表不为null
*/
@RequestMapping("queryAccount")
@MenuResource("读取管理员列表")
@ResponseBody
public PageResult<List<AdminAccount>> listAccount(String keyword, int page, int pageSize, HttpServletRequest request) {
List<AdminAccount> list = adminAccountService.listAccounts(keyword, page, pageSize);
int total = adminAccountService.statAccount(keyword);
for (AdminAccount account : list) {
StringBuilder buf = new StringBuilder();
List<AccountRoleRelation> tmpList = adminAccountService.listAccountRoles(account.getUid());
for (AccountRoleRelation arr : tmpList) {
Role role = roleService.getById(arr.getRoleId());
if (role != null) {
if (buf.length() > 0)
buf.append(",");
buf.append(role.getRoleName());
}
}
account.setRoleName(buf.toString());
}
PageResult<List<AdminAccount>> result = new PageResult<>(list);
result.setCurrentPage(page);
result.setPageSize(pageSize);
result.setCount(total);
return result;
}
use of com.ibeiliao.deployment.admin.vo.account.AccountRoleRelation in project Corgi by kevinYin.
the class EditAccountController method getAdmin.
/**
* 读取管理员信息
* @param uid 管理员ID
* @return 返回管理员信息
*/
@RequestMapping("getAdmin")
@MenuResource("读取管理员信息")
@ResponseBody
public RestResult<AdminAccount> getAdmin(long uid) {
AdminAccount account = adminAccountService.getById(uid);
RestResult<AdminAccount> result;
if (account == null) {
result = new RestResult<>(ApiCode.FAILURE, "管理员不存在:uid=" + uid);
} else {
List<AccountRoleRelation> list = adminAccountService.listAccountRoles(uid);
if (list.size() == 1) {
account.setRoleId(list.get(0).getRoleId());
}
account.setPassword(aesPropertiesEncoder.decode(account.getPassword()));
result = new RestResult<>(account);
}
return result;
}
Aggregations