use of org.jeecg.modules.system.entity.SysPermission in project jeecg-boot by jeecgboot.
the class NgAlainServiceImpl method getJeecgMenu.
@Override
public JSONArray getJeecgMenu(String id) throws Exception {
List<SysPermission> metaList = sysPermissionService.queryByUser(id);
JSONArray jsonArray = new JSONArray();
getPermissionJsonArray(jsonArray, metaList, null);
JSONArray menulist = parseNgAlain(jsonArray);
JSONObject jeecgMenu = new JSONObject();
jeecgMenu.put("text", "jeecg菜单");
jeecgMenu.put("group", true);
jeecgMenu.put("children", menulist);
JSONArray jeecgMenuList = new JSONArray();
jeecgMenuList.add(jeecgMenu);
return jeecgMenuList;
}
use of org.jeecg.modules.system.entity.SysPermission in project jeecg-boot by jeecgboot.
the class SysDepartPermissionController method queryTreeListForDeptRole.
/**
* 用户角色授权功能,查询菜单权限树
* @param request
* @return
*/
@RequestMapping(value = "/queryTreeListForDeptRole", method = RequestMethod.GET)
public Result<Map<String, Object>> queryTreeListForDeptRole(@RequestParam(name = "departId", required = true) String departId, HttpServletRequest request) {
Result<Map<String, Object>> result = new Result<>();
// 全部权限ids
List<String> ids = new ArrayList<>();
try {
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
query.orderByAsc(SysPermission::getSortNo);
query.inSql(SysPermission::getId, "select permission_id from sys_depart_permission where depart_id='" + departId + "'");
List<SysPermission> list = sysPermissionService.list(query);
for (SysPermission sysPer : list) {
ids.add(sysPer.getId());
}
List<TreeModel> treeList = new ArrayList<>();
getTreeModelList(treeList, list, null);
Map<String, Object> resMap = new HashMap<String, Object>();
// 全部树节点数据
resMap.put("treeList", treeList);
// 全部树ids
resMap.put("ids", ids);
result.setResult(resMap);
result.setSuccess(true);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return result;
}
use of org.jeecg.modules.system.entity.SysPermission in project jeecg-boot by jeecgboot.
the class SysDepartPermissionController method getTreeModelList.
private void getTreeModelList(List<TreeModel> treeList, List<SysPermission> metaList, TreeModel temp) {
for (SysPermission permission : metaList) {
String tempPid = permission.getParentId();
TreeModel tree = new TreeModel(permission.getId(), tempPid, permission.getName(), permission.getRuleFlag(), permission.isLeaf());
if (temp == null && oConvertUtils.isEmpty(tempPid)) {
treeList.add(tree);
if (!tree.getIsLeaf()) {
getTreeModelList(treeList, metaList, tree);
}
} else if (temp != null && tempPid != null && tempPid.equals(temp.getKey())) {
temp.getChildren().add(tree);
if (!tree.getIsLeaf()) {
getTreeModelList(treeList, metaList, tree);
}
}
}
}
use of org.jeecg.modules.system.entity.SysPermission in project jeecg-boot by jeecgboot.
the class SysPermissionServiceImpl method hasPermission.
@Override
public boolean hasPermission(String username, String url) {
SysPermission sysPermission = new SysPermission();
sysPermission.setUrl(url);
int count = baseMapper.queryCountByUsername(username, sysPermission);
if (count > 0) {
return true;
} else {
return false;
}
}
use of org.jeecg.modules.system.entity.SysPermission in project jeecg-boot by jeecgboot.
the class SysPermissionServiceImpl method removeChildrenBy.
/**
* 根据父id删除其关联的子节点数据
*
* @return
*/
public void removeChildrenBy(String parentId) {
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<>();
// 封装查询条件parentId为主键,
query.eq(SysPermission::getParentId, parentId);
// 查出该主键下的所有子级
List<SysPermission> permissionList = this.list(query);
if (permissionList != null && permissionList.size() > 0) {
// id
String id = "";
// 查出的子级数量
int num = 0;
// 如果查出的集合不为空, 则先删除所有
this.remove(query);
// 再遍历刚才查出的集合, 根据每个对象,查找其是否仍有子级
for (int i = 0, len = permissionList.size(); i < len; i++) {
id = permissionList.get(i).getId();
Map map = new HashMap<>();
map.put("permission_id", id);
// 删除数据规则
this.deletePermRuleByPermId(id);
// 删除角色授权表
sysRolePermissionMapper.deleteByMap(map);
// 删除部门权限表
sysDepartPermissionMapper.deleteByMap(map);
// 删除部门角色授权
sysDepartRolePermissionMapper.deleteByMap(map);
num = this.count(new LambdaQueryWrapper<SysPermission>().eq(SysPermission::getParentId, id));
// 如果有, 则递归
if (num > 0) {
this.removeChildrenBy(id);
}
}
}
}
Aggregations