Java Code Examples for com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper#orderByAsc()

The following examples show how to use com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper#orderByAsc() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MenuServiceImpl.java    From FEBS-Cloud with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, Object> findMenus(Menu menu) {
    Map<String, Object> result = new HashMap<>(2);
    try {
        LambdaQueryWrapper<Menu> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.orderByAsc(Menu::getOrderNum);
        List<Menu> menus = baseMapper.selectList(queryWrapper);

        List<MenuTree> trees = new ArrayList<>();
        buildTrees(trees, menus);

        if (StringUtils.equals(menu.getType(), Menu.TYPE_BUTTON)) {
            result.put(PageConstant.ROWS, trees);
        } else {
            List<? extends Tree<?>> menuTree = TreeUtil.build(trees);
            result.put(PageConstant.ROWS, menuTree);
        }

        result.put("total", menus.size());
    } catch (NumberFormatException e) {
        log.error("查询菜单失败", e);
        result.put(PageConstant.ROWS, null);
        result.put(PageConstant.TOTAL, 0);
    }
    return result;
}
 
Example 2
Source File: SysPermissionController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 查询子菜单
 * @param parentId
 * @return
 */
@RequestMapping(value = "/getSystemSubmenu", method = RequestMethod.GET)
public Result<List<SysPermissionTree>> getSystemSubmenu(@RequestParam("parentId") String parentId){
	Result<List<SysPermissionTree>> result = new Result<>();
	try{
		LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
		query.eq(SysPermission::getParentId,parentId);
		query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
		query.orderByAsc(SysPermission::getSortNo);
		List<SysPermission> list = sysPermissionService.list(query);
		List<SysPermissionTree> sysPermissionTreeList = new ArrayList<SysPermissionTree>();
		for(SysPermission sysPermission : list){
			SysPermissionTree sysPermissionTree = new SysPermissionTree(sysPermission);
			sysPermissionTreeList.add(sysPermissionTree);
		}
		result.setResult(sysPermissionTreeList);
		result.setSuccess(true);
	}catch (Exception e){
		log.error(e.getMessage(), e);
	}
	return result;
}
 
Example 3
Source File: SysPermissionController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * 查询子菜单
 * @param parentId
 * @return
 */
@RequestMapping(value = "/getSystemSubmenu", method = RequestMethod.GET)
public Result<List<SysPermissionTree>> getSystemSubmenu(@RequestParam("parentId") String parentId){
	Result<List<SysPermissionTree>> result = new Result<>();
	try{
		LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
		query.eq(SysPermission::getParentId,parentId);
		query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
		query.orderByAsc(SysPermission::getSortNo);
		List<SysPermission> list = sysPermissionService.list(query);
		List<SysPermissionTree> sysPermissionTreeList = new ArrayList<SysPermissionTree>();
		for(SysPermission sysPermission : list){
			SysPermissionTree sysPermissionTree = new SysPermissionTree(sysPermission);
			sysPermissionTreeList.add(sysPermissionTree);
		}
		result.setResult(sysPermissionTreeList);
		result.setSuccess(true);
	}catch (Exception e){
		log.error(e.getMessage(), e);
	}
	return result;
}
 
Example 4
Source File: SysDepartServiceImpl.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 根据用户所负责部门ids获取父级部门编码
 * @param departIds
 * @return
 */
private String[] getMyDeptParentOrgCode(String departIds){
	//根据部门id查询所负责部门
	LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
	query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
	query.in(SysDepart::getId, Arrays.asList(departIds.split(",")));
	query.orderByAsc(SysDepart::getOrgCode);
	List<SysDepart> list = this.list(query);
	//查找根部门
	if(list == null || list.size()==0){
		return null;
	}
	String orgCode = this.getMyDeptParentNode(list);
	String[] codeArr = orgCode.split(",");
	return codeArr;
}
 
Example 5
Source File: SysPermissionController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 系统菜单列表(一级菜单)
 *
 * @return
 */
@RequestMapping(value = "/getSystemMenuList", method = RequestMethod.GET)
public Result<List<SysPermissionTree>> getSystemMenuList() {
       long start = System.currentTimeMillis();
	Result<List<SysPermissionTree>> result = new Result<>();
	try {
		LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
		query.eq(SysPermission::getMenuType,CommonConstant.MENU_TYPE_0);
		query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
		query.orderByAsc(SysPermission::getSortNo);
		List<SysPermission> list = sysPermissionService.list(query);
		List<SysPermissionTree> sysPermissionTreeList = new ArrayList<SysPermissionTree>();
		for(SysPermission sysPermission : list){
			SysPermissionTree sysPermissionTree = new SysPermissionTree(sysPermission);
			sysPermissionTreeList.add(sysPermissionTree);
		}
		result.setResult(sysPermissionTreeList);
		result.setSuccess(true);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
       log.info("======获取一级菜单数据=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
	return result;
}
 
Example 6
Source File: SysPermissionController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
 * 查询子菜单
 * @param parentId
 * @return
 */
@RequestMapping(value = "/getSystemSubmenu", method = RequestMethod.GET)
public Result<List<SysPermissionTree>> getSystemSubmenu(@RequestParam("parentId") String parentId){
	Result<List<SysPermissionTree>> result = new Result<>();
	try{
		LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
		query.eq(SysPermission::getParentId,parentId);
		query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
		query.orderByAsc(SysPermission::getSortNo);
		List<SysPermission> list = sysPermissionService.list(query);
		List<SysPermissionTree> sysPermissionTreeList = new ArrayList<SysPermissionTree>();
		for(SysPermission sysPermission : list){
			SysPermissionTree sysPermissionTree = new SysPermissionTree(sysPermission);
			sysPermissionTreeList.add(sysPermissionTree);
		}
		result.setResult(sysPermissionTreeList);
		result.setSuccess(true);
	}catch (Exception e){
		log.error(e.getMessage(), e);
	}
	return result;
}
 
Example 7
Source File: SysRoleController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 用户角色授权功能,查询菜单权限树
 * @param request
 * @return
 */
@RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
public Result<Map<String,Object>> queryTreeList(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);
		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); //全部树节点数据
		resMap.put("ids", ids);//全部树ids
		result.setResult(resMap);
		result.setSuccess(true);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
	return result;
}
 
Example 8
Source File: SysDictServiceImpl.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, List<DictModel>> queryAllDictItems() {
	Map<String, List<DictModel>> res = new HashMap<String, List<DictModel>>();
	List<SysDict> ls = sysDictMapper.selectList(null);
	LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<SysDictItem>();
	queryWrapper.eq(SysDictItem::getStatus, 1);
	queryWrapper.orderByAsc(SysDictItem::getSortOrder);
	List<SysDictItem> sysDictItemList = sysDictItemMapper.selectList(queryWrapper);

	for (SysDict d : ls) {
		List<DictModel> dictModelList = sysDictItemList.stream().filter(s -> d.getId().equals(s.getDictId())).map(item -> {
			DictModel dictModel = new DictModel();
			dictModel.setText(item.getItemText());
			dictModel.setValue(item.getItemValue());
			return dictModel;
		}).collect(Collectors.toList());
		res.put(d.getDictCode(), dictModelList);
	}
	log.debug("-------登录加载系统字典-----" + res.toString());
	return res;
}
 
Example 9
Source File: SysDepartServiceImpl.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
@Override
public List<SysDepartTreeModel> queryMyDeptTreeList(String departIds) {
	//根据部门id获取所负责部门
	LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
	String[] codeArr = this.getMyDeptParentOrgCode(departIds);
	for(int i=0;i<codeArr.length;i++){
		query.or().likeRight(SysDepart::getOrgCode,codeArr[i]);
	}
	query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
	query.orderByAsc(SysDepart::getDepartOrder);
	//将父节点ParentId设为null
	List<SysDepart> listDepts = this.list(query);
	for(int i=0;i<codeArr.length;i++){
		for(SysDepart dept : listDepts){
			if(dept.getOrgCode().equals(codeArr[i])){
				dept.setParentId(null);
			}
		}
	}
	// 调用wrapTreeDataToTreeList方法生成树状数据
	List<SysDepartTreeModel> listResult = FindsDepartsChildrenUtil.wrapTreeDataToTreeList(listDepts);
	return listResult;
}
 
Example 10
Source File: SysPermissionController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 系统菜单列表(一级菜单)
 *
 * @return
 */
@RequestMapping(value = "/getSystemMenuList", method = RequestMethod.GET)
public Result<List<SysPermissionTree>> getSystemMenuList() {
       long start = System.currentTimeMillis();
	Result<List<SysPermissionTree>> result = new Result<>();
	try {
		LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
		query.eq(SysPermission::getMenuType,CommonConstant.MENU_TYPE_0);
		query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
		query.orderByAsc(SysPermission::getSortNo);
		List<SysPermission> list = sysPermissionService.list(query);
		List<SysPermissionTree> sysPermissionTreeList = new ArrayList<SysPermissionTree>();
		for(SysPermission sysPermission : list){
			SysPermissionTree sysPermissionTree = new SysPermissionTree(sysPermission);
			sysPermissionTreeList.add(sysPermissionTree);
		}
		result.setResult(sysPermissionTreeList);
		result.setSuccess(true);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
       log.info("======获取一级菜单数据=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
	return result;
}
 
Example 11
Source File: SysRoleController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 用户角色授权功能,查询菜单权限树
 * @param request
 * @return
 */
@RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
public Result<Map<String,Object>> queryTreeList(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);
		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); //全部树节点数据
		resMap.put("ids", ids);//全部树ids
		result.setResult(resMap);
		result.setSuccess(true);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
	return result;
}
 
Example 12
Source File: SysPermissionController.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * 获取全部的权限树
 * 
 * @return
 */
@RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
public Result<Map<String, Object>> queryTreeList() {
	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);
		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); // 全部树节点数据
		resMap.put("ids", ids);// 全部树ids
		result.setResult(resMap);
		result.setSuccess(true);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
	return result;
}
 
Example 13
Source File: DataPermissionTestServiceImpl.java    From FEBS-Cloud with Apache License 2.0 5 votes vote down vote up
@Override
public IPage<DataPermissionTest> findDataPermissionTests(QueryRequest request, DataPermissionTest dataPermissionTest) {
    LambdaQueryWrapper<DataPermissionTest> queryWrapper = new LambdaQueryWrapper<>();
    queryWrapper.orderByAsc(DataPermissionTest::getCreateTime);
    Page<DataPermissionTest> page = new Page<>(request.getPageNum(), request.getPageSize());
    return this.page(page, queryWrapper);
}
 
Example 14
Source File: SysPermissionController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 获取全部的权限树
 * 
 * @return
 */
@RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
public Result<Map<String, Object>> queryTreeList() {
	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);
		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); // 全部树节点数据
		resMap.put("ids", ids);// 全部树ids
		result.setResult(resMap);
		result.setSuccess(true);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
	return result;
}
 
Example 15
Source File: SysDepartServiceImpl.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
@Cacheable(value = CacheConstant.SYS_DEPART_IDS_CACHE)
@Override
public List<DepartIdModel> queryDepartIdTreeList() {
	LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
	query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
	query.orderByAsc(SysDepart::getDepartOrder);
	List<SysDepart> list = this.list(query);
	// 调用wrapTreeDataToTreeList方法生成树状数据
	List<DepartIdModel> listResult = FindsDepartsChildrenUtil.wrapTreeDataToDepartIdTreeList(list);
	return listResult;
}
 
Example 16
Source File: SysPermissionController.java    From teaching with Apache License 2.0 5 votes vote down vote up
/**
 * 查询子菜单
 *
 * @param parentIds 父ID(多个采用半角逗号分割)
 * @return 返回 key-value 的 Map
 */
@GetMapping("/getSystemSubmenuBatch")
public Result getSystemSubmenuBatch(@RequestParam("parentIds") String parentIds) {
	try {
		LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<>();
		List<String> parentIdList = Arrays.asList(parentIds.split(","));
		query.in(SysPermission::getParentId, parentIdList);
		query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
		query.orderByAsc(SysPermission::getSortNo);
		List<SysPermission> list = sysPermissionService.list(query);
		Map<String, List<SysPermissionTree>> listMap = new HashMap<>();
		for (SysPermission item : list) {
			String pid = item.getParentId();
			if (parentIdList.contains(pid)) {
				List<SysPermissionTree> mapList = listMap.get(pid);
				if (mapList == null) {
					mapList = new ArrayList<>();
				}
				mapList.add(new SysPermissionTree(item));
				listMap.put(pid, mapList);
			}
		}
		return Result.ok(listMap);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		return Result.error("批量查询子菜单失败:" + e.getMessage());
	}
}
 
Example 17
Source File: SysDepartPermissionController.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * 用户角色授权功能,查询菜单权限树
 * @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); //全部树节点数据
	 resMap.put("ids", ids);//全部树ids
	 result.setResult(resMap);
	 result.setSuccess(true);
 } catch (Exception e) {
	 log.error(e.getMessage(), e);
 }
 return result;
}
 
Example 18
Source File: SysPermissionController.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
/**
 * 获取全部的权限树
 * 
 * @return
 */
@RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
public Result<Map<String, Object>> queryTreeList() {
	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);
		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); // 全部树节点数据
		resMap.put("ids", ids);// 全部树ids
		result.setResult(resMap);
		result.setSuccess(true);
	} catch (Exception e) {
		log.error(e.getMessage(), e);
	}
	return result;
}
 
Example 19
Source File: SysDepartController.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * 查询所有部门信息
 * @return
 */
@GetMapping("listAll")
public Result<List<SysDepart>> listAll(@RequestParam(name = "id", required = false) String id) {
	Result<List<SysDepart>> result = new Result<>();
	LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
	query.orderByAsc(SysDepart::getOrgCode);
	if(oConvertUtils.isNotEmpty(id)){
		String arr[] = id.split(",");
		query.in(SysDepart::getId,arr);
	}
	List<SysDepart> ls = this.sysDepartService.list(query);
	result.setSuccess(true);
	result.setResult(ls);
	return result;
}
 
Example 20
Source File: RoleServiceImpl.java    From FEBS-Cloud with Apache License 2.0 4 votes vote down vote up
@Override
public List<Role> findAllRoles() {
    LambdaQueryWrapper<Role> queryWrapper = new LambdaQueryWrapper<>();
    queryWrapper.orderByAsc(Role::getRoleId);
    return this.baseMapper.selectList(queryWrapper);
}