com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper Java Examples

The following examples show how to use com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper. 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: 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 #2
Source File: SysPermissionServiceImpl.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * 根据父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) {
		String id = ""; // id
		int num = 0; // 查出的子级数量
		// 如果查出的集合不为空, 则先删除所有
		this.remove(query);
		// 再遍历刚才查出的集合, 根据每个对象,查找其是否仍有子级
		for (int i = 0, len = permissionList.size(); i < len; i++) {
			id = permissionList.get(i).getId();
			num = this.count(new LambdaQueryWrapper<SysPermission>().eq(SysPermission::getParentId, id));
			// 如果有, 则递归
			if (num > 0) {
				this.removeChildrenBy(id);
			}
		}
	}
}
 
Example #3
Source File: SysDepartPermissionController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
* 部门管理授权查询数据规则数据
*/
@GetMapping(value = "/datarule/{permissionId}/{departId}")
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("departId") String departId) {
	List<SysPermissionDataRule> list = sysPermissionDataRuleService.getPermRuleListByPermId(permissionId);
	if(list==null || list.size()==0) {
		return Result.error("未找到权限配置信息");
	}else {
		Map<String,Object> map = new HashMap<>();
		map.put("datarule", list);
		LambdaQueryWrapper<SysDepartPermission> query = new LambdaQueryWrapper<SysDepartPermission>()
			 .eq(SysDepartPermission::getPermissionId, permissionId)
			 .eq(SysDepartPermission::getDepartId,departId);
		SysDepartPermission sysDepartPermission = sysDepartPermissionService.getOne(query);
		if(sysDepartPermission==null) {
		 //return Result.error("未找到角色菜单配置信息");
		}else {
			String drChecked = sysDepartPermission.getDataRuleIds();
			if(oConvertUtils.isNotEmpty(drChecked)) {
				map.put("drChecked", drChecked.endsWith(",")?drChecked.substring(0, drChecked.length()-1):drChecked);
			}
		}
		return Result.ok(map);
		//TODO 以后按钮权限的查询也走这个请求 无非在map中多加两个key
	}
}
 
Example #4
Source File: SysPermissionController.java    From jeecg-boot 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 #5
Source File: CodeService.java    From pybbs with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Code selectNotUsedCode(Integer userId, String email, String mobile) {
    QueryWrapper<Code> wrapper = new QueryWrapper<>();
    LambdaQueryWrapper<Code> lambda = wrapper.lambda();
    if (email != null) {
        lambda.eq(Code::getEmail, email);
        lambda.eq(Code::getUserId, userId);
    } else if (mobile != null) {
        lambda.eq(Code::getMobile, mobile);
    }
    lambda.eq(Code::getUsed, false);
    lambda.gt(Code::getExpireTime, new Date());
    List<Code> codes = codeMapper.selectList(wrapper);
    if (codes.isEmpty()) return null;
    return codes.get(0);
}
 
Example #6
Source File: SysCategoryController.java    From teaching with Apache License 2.0 6 votes vote down vote up
/**
 * [列表页面]加载分类字典数据 用于值的替换
 * @param code
 * @return
 */
@RequestMapping(value = "/loadAllData", method = RequestMethod.GET)
public Result<List<DictModel>> loadAllData(@RequestParam(name="code",required = true) String code) {
 Result<List<DictModel>> result = new Result<List<DictModel>>();
 LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<SysCategory>();
 if(oConvertUtils.isNotEmpty(code) && !"0".equals(code)){
	 query.likeRight(SysCategory::getCode,code);
 }
 List<SysCategory> list = this.sysCategoryService.list(query);
 if(list==null || list.size()==0) {
	 result.setMessage("无数据,参数有误.[code]");
	 result.setSuccess(false);
	 return result;
 }
 List<DictModel> rdList = new ArrayList<DictModel>();
 for (SysCategory c : list) {
	 rdList.add(new DictModel(c.getId(),c.getName()));
 }
 result.setSuccess(true);
 result.setResult(rdList);
 return result;
}
 
Example #7
Source File: PayServiceImpl.java    From mall4j with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
@Transactional(rollbackFor = Exception.class)
public List<String> paySuccess(String payNo, String bizPayNo) {
    List<OrderSettlement> orderSettlements = orderSettlementMapper.selectList(new LambdaQueryWrapper<OrderSettlement>().eq(OrderSettlement::getPayNo, payNo));

    OrderSettlement settlement = orderSettlements.get(0);

    // 订单已支付
    if (settlement.getPayStatus() == 1) {
        throw new YamiShopBindException("订单已支付");
    }
    // 修改订单结算信息
    if (orderSettlementMapper.updateToPay(payNo, settlement.getVersion()) < 1) {
        throw new YamiShopBindException("结算信息已更改");
    }


    List<String> orderNumbers = orderSettlements.stream().map(OrderSettlement::getOrderNumber).collect(Collectors.toList());

    // 将订单改为已支付状态
    orderMapper.updateByToPaySuccess(orderNumbers, PayType.WECHATPAY.value());

    List<Order> orders = orderNumbers.stream().map(orderNumber -> orderMapper.getOrderByOrderNumber(orderNumber)).collect(Collectors.toList());
    eventPublisher.publishEvent(new PaySuccessOrderEvent(orders));
    return orderNumbers;
}
 
Example #8
Source File: SysGatewayRouteController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
@GetMapping(value = "/list")
public Result<?> queryPageList(SysGatewayRoute sysGatewayRoute) {
	LambdaQueryWrapper<SysGatewayRoute> query = new LambdaQueryWrapper<>();
	query.eq(SysGatewayRoute::getStatus,1);
	List<SysGatewayRoute> ls = sysGatewayRouteService.list(query);
	JSONArray array = new JSONArray();
	for(SysGatewayRoute rt: ls){
		JSONObject obj = (JSONObject)JSONObject.toJSON(rt);
		if(oConvertUtils.isNotEmpty(rt.getPredicates())){
			obj.put("predicates", JSONArray.parseArray(rt.getPredicates()));
		}
		if(oConvertUtils.isNotEmpty(rt.getFilters())){
			obj.put("filters", JSONArray.parseArray(rt.getFilters()));
		}
		array.add(obj);
	}
	return Result.ok(array);
}
 
Example #9
Source File: UserRoleServiceImpl.java    From kvf-admin with MIT License 6 votes vote down vote up
@Override
public void saveOrUpdateBatchUserRole(UserRoleVO userRoleVO) {
    Long roleId = userRoleVO.getRoleId();
    List<Long> userIds = userRoleVO.getUserIds();
    List<UserRole> userRoles = new ArrayList<>();

    userIds.forEach(userId -> {
        UserRole userRole = super.getOne(new LambdaQueryWrapper<UserRole>()
                .eq(UserRole::getRoleId, roleId).eq(UserRole::getUserId, userId));
        if (userRole == null) {
            userRole = new UserRole();
            userRole.setRoleId(roleId).setUserId(userId);
        }
        userRoles.add(userRole);
    });
    super.saveOrUpdateBatch(userRoles);
}
 
Example #10
Source File: SysUserServiceImpl.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
@Override
@CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true)
public Result<?> resetPassword(String username, String oldpassword, String newpassword, String confirmpassword) {
    SysUser user = userMapper.getUserByName(username);
    String passwordEncode = PasswordUtil.encrypt(username, oldpassword, user.getSalt());
    if (!user.getPassword().equals(passwordEncode)) {
        return Result.error("旧密码输入错误!");
    }
    if (oConvertUtils.isEmpty(newpassword)) {
        return Result.error("新密码不允许为空!");
    }
    if (!newpassword.equals(confirmpassword)) {
        return Result.error("两次输入密码不一致!");
    }
    String password = PasswordUtil.encrypt(username, newpassword, user.getSalt());
    this.userMapper.update(new SysUser().setPassword(password), new LambdaQueryWrapper<SysUser>().eq(SysUser::getId, user.getId()));
    return Result.ok("密码重置成功!");
}
 
Example #11
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 #12
Source File: GoodsBrandGroupServiceImpl.java    From spring-cloud-shop with MIT License 6 votes vote down vote up
@Override
public Response<List<GoodsBrandGroupResponse>> queryPage(GoodsBrandGroupPageRequest request) {

    LambdaQueryWrapper<GoodsBrandGroup> wrapper = new LambdaQueryWrapper<>();
    wrapper.eq(GoodsBrandGroup::getDeleteStatus, Boolean.FALSE);
    if (StringUtils.isNotBlank(request.getBrandGroupName())) {
        wrapper.likeRight(GoodsBrandGroup::getBrandGroupName, request.getBrandGroupName());
    }

    if (CollectionUtils.isNotEmpty(request.getDateTimes())) {
        wrapper.ge(GoodsBrandGroup::getUpdateTime, request.getDateTimes().get(0));
        wrapper.le(GoodsBrandGroup::getUpdateTime, request.getDateTimes().get(1));
    }

    wrapper.orderByDesc(GoodsBrandGroup::getSequence);

    Response<List<GoodsBrandGroup>> response = this.toPage(request.getPage(), request.getPageSize(), wrapper);
    return Response.toResponse(Optional.ofNullable(response.getData()).orElse(Collections.emptyList()).stream()
                    .map(this::convert)
                    .collect(Collectors.toList()),
            response.getTotal());
}
 
Example #13
Source File: SysDepartServiceImpl.java    From jeecg-cloud 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 #14
Source File: CategoryController.java    From mall4j with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 更新分类
 */
@SysLog("更新分类")
@PutMapping
@PreAuthorize("@pms.hasPermission('prod:category:update')")
public ResponseEntity<String> update(@RequestBody Category category){
	category.setShopId(SecurityUtils.getSysUser().getShopId());
	if (Objects.equals(category.getParentId(),category.getCategoryId())) {
		return ResponseEntity.badRequest().body("分类的上级不能是自己本身");
	}
	Category categoryName = categoryService.getOne(new LambdaQueryWrapper<Category>().eq(Category::getCategoryName,category.getCategoryName())
			.eq(Category::getShopId,category.getShopId()).ne(Category::getCategoryId,category.getCategoryId()));
	if(categoryName != null){
		throw new YamiShopBindException("类目名称已存在!");
	}
	categoryService.updateCategroy(category);
	return ResponseEntity.ok().build();
}
 
Example #15
Source File: DriverAttributeServiceImpl.java    From iot-dc3 with Apache License 2.0 6 votes vote down vote up
@Override
public LambdaQueryWrapper<DriverAttribute> fuzzyQuery(DriverAttributeDto driverAttributeDto) {
    LambdaQueryWrapper<DriverAttribute> queryWrapper = Wrappers.<DriverAttribute>query().lambda();
    Optional.ofNullable(driverAttributeDto).ifPresent(dto -> {
        if (StringUtils.isNotBlank(dto.getDisplayName())) {
            queryWrapper.like(DriverAttribute::getDisplayName, dto.getDisplayName());
        }
        if (StringUtils.isNotBlank(dto.getName())) {
            queryWrapper.eq(DriverAttribute::getName, dto.getName());
        }
        if (StringUtils.isNotBlank(dto.getType())) {
            queryWrapper.eq(DriverAttribute::getType, dto.getType());
        }
        Optional.ofNullable(dto.getDriverId()).ifPresent(driverId -> queryWrapper.eq(DriverAttribute::getDriverId, driverId));
    });
    return queryWrapper;
}
 
Example #16
Source File: SysPermissionDataRuleImpl.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
@Override
@Transactional
public void deletePermissionDataRule(String dataRuleId) {
	SysPermissionDataRule dataRule = this.baseMapper.selectById(dataRuleId);
	if(dataRule!=null) {
		this.removeById(dataRuleId);
		Integer count =  this.baseMapper.selectCount(new LambdaQueryWrapper<SysPermissionDataRule>().eq(SysPermissionDataRule::getPermissionId, dataRule.getPermissionId()));
		//注:同一个事务中删除后再查询是会认为数据已被删除的 若事务回滚上述删除无效
		if(count==null || count==0) {
			SysPermission permission = sysPermissionMapper.selectById(dataRule.getPermissionId());
			if(permission!=null && permission.getRuleFlag().equals(CommonConstant.RULE_FLAG_1)) {
				permission.setRuleFlag(CommonConstant.RULE_FLAG_0);
				sysPermissionMapper.updateById(permission);
			}
		}
	}
	
}
 
Example #17
Source File: SysGatewayRouteServiceImpl.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
@Override
public void updateAll(JSONArray array) {
    this.remove(new LambdaQueryWrapper<SysGatewayRoute>().eq(SysGatewayRoute::getStatus,1));
    List<SysGatewayRoute> ls = new ArrayList<>();
    for(int i =0;i<array.size();i++){
        JSONObject json = array.getJSONObject(i);
        SysGatewayRoute route = new SysGatewayRoute();
        route.setId(json.getString("id"));
        route.setName(json.getString("name"));
        route.setPredicates(json.getString("predicates"));
        route.setFilters(json.getString("filters"));
        route.setUri(json.getString("uri"));
        if(json.get("status")==null){
            route.setStatus(1);
        }else{
            route.setStatus(json.getInteger("status"));
        }
        ls.add(route);
    }
    this.saveBatch(ls);
    redisTemplate.opsForValue().set(CacheConstant.GATEWAY_ROUTES,  JSON.toJSONString(ls));
}
 
Example #18
Source File: SysDepartPermissionController.java    From jeecg-cloud with Apache License 2.0 6 votes vote down vote up
/**
* 部门管理授权查询数据规则数据
*/
@GetMapping(value = "/datarule/{permissionId}/{departId}")
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("departId") String departId) {
	List<SysPermissionDataRule> list = sysPermissionDataRuleService.getPermRuleListByPermId(permissionId);
	if(list==null || list.size()==0) {
		return Result.error("未找到权限配置信息");
	}else {
		Map<String,Object> map = new HashMap<>();
		map.put("datarule", list);
		LambdaQueryWrapper<SysDepartPermission> query = new LambdaQueryWrapper<SysDepartPermission>()
			 .eq(SysDepartPermission::getPermissionId, permissionId)
			 .eq(SysDepartPermission::getDepartId,departId);
		SysDepartPermission sysDepartPermission = sysDepartPermissionService.getOne(query);
		if(sysDepartPermission==null) {
		 //return Result.error("未找到角色菜单配置信息");
		}else {
			String drChecked = sysDepartPermission.getDataRuleIds();
			if(oConvertUtils.isNotEmpty(drChecked)) {
				map.put("drChecked", drChecked.endsWith(",")?drChecked.substring(0, drChecked.length()-1):drChecked);
			}
		}
		return Result.ok(map);
		//TODO 以后按钮权限的查询也走这个请求 无非在map中多加两个key
	}
}
 
Example #19
Source File: SysDictServiceImpl.java    From jeecg-boot 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 #20
Source File: SysRoleController.java    From jeecg-boot with Apache License 2.0 6 votes vote down vote up
/**
 * 保存数据规则至角色菜单关联表
 */
@PostMapping(value = "/datarule")
public Result<?> saveDatarule(@RequestBody JSONObject jsonObject) {
	try {
		String permissionId = jsonObject.getString("permissionId");
		String roleId = jsonObject.getString("roleId");
		String dataRuleIds = jsonObject.getString("dataRuleIds");
		log.info("保存数据规则>>"+"菜单ID:"+permissionId+"角色ID:"+ roleId+"数据权限ID:"+dataRuleIds);
		LambdaQueryWrapper<SysRolePermission> query = new LambdaQueryWrapper<SysRolePermission>()
				.eq(SysRolePermission::getPermissionId, permissionId)
				.eq(SysRolePermission::getRoleId,roleId);
		SysRolePermission sysRolePermission = sysRolePermissionService.getOne(query);
		if(sysRolePermission==null) {
			return Result.error("请先保存角色菜单权限!");
		}else {
			sysRolePermission.setDataRuleIds(dataRuleIds);
			this.sysRolePermissionService.updateById(sysRolePermission);
		}
	} catch (Exception e) {
		log.error("SysRoleController.saveDatarule()发生异常:" + e.getMessage(),e);
		return Result.error("保存失败");
	}
	return Result.ok("保存成功!");
}
 
Example #21
Source File: DriverServiceImpl.java    From iot-dc3 with Apache License 2.0 6 votes vote down vote up
@Override
public LambdaQueryWrapper<Driver> fuzzyQuery(DriverDto driverDto) {
    LambdaQueryWrapper<Driver> queryWrapper = Wrappers.<Driver>query().lambda();
    Optional.ofNullable(driverDto).ifPresent(dto -> {
        if (StringUtils.isNotBlank(dto.getName())) {
            queryWrapper.like(Driver::getName, dto.getName());
        }
        if (StringUtils.isNotBlank(dto.getServiceName())) {
            queryWrapper.like(Driver::getServiceName, dto.getServiceName());
        }
        if (StringUtils.isNotBlank(dto.getHost())) {
            queryWrapper.like(Driver::getHost, dto.getHost());
        }
        Optional.ofNullable(dto.getPort()).ifPresent(port -> queryWrapper.eq(Driver::getPort, port));
    });
    return queryWrapper;
}
 
Example #22
Source File: GoodsBrandServiceImpl.java    From spring-cloud-shop with MIT License 6 votes vote down vote up
@Override
public Response<List<GoodsBrandResponse>> queryPage(GoodsBrandPageRequest request) {
    LambdaQueryWrapper<GoodsBrand> wrapper = new LambdaQueryWrapper<>();
    wrapper.eq(GoodsBrand::getDeleteStatus, Boolean.FALSE);

    if (StringUtils.isNotBlank(request.getBrandCode())) {
        wrapper.eq(GoodsBrand::getBrandCode, request.getBrandCode());
    }

    if (StringUtils.isNotBlank(request.getBrandName())) {
        wrapper.likeRight(GoodsBrand::getBrandName, request.getBrandName());
    }

    if (!CollectionUtils.isEmpty(request.getDateTimes())) {
        wrapper.ge(GoodsBrand::getCreateTime, request.getDateTimes().get(0));
        wrapper.le(GoodsBrand::getCreateTime, request.getDateTimes().get(1));
    }

    Response<List<GoodsBrand>> page = this.toPage(request.getPage(), request.getPageSize(), wrapper);

    return Response.toResponse(page.getData().stream().map(this::convert).collect(Collectors.toList()), page.getTotal());
}
 
Example #23
Source File: SysRoleController.java    From jeecg-boot-with-activiti with MIT License 6 votes vote down vote up
/**
 * 查询数据规则数据
 */
@GetMapping(value = "/datarule/{permissionId}/{roleId}")
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("roleId") String roleId) {
	List<SysPermissionDataRule> list = sysPermissionDataRuleService.getPermRuleListByPermId(permissionId);
	if(list==null || list.size()==0) {
		return Result.error("未找到权限配置信息");
	}else {
		Map<String,Object> map = new HashMap<>();
		map.put("datarule", list);
		LambdaQueryWrapper<SysRolePermission> query = new LambdaQueryWrapper<SysRolePermission>()
				.eq(SysRolePermission::getPermissionId, permissionId)
				.eq(SysRolePermission::getRoleId,roleId);
		SysRolePermission sysRolePermission = sysRolePermissionService.getOne(query);
		if(sysRolePermission==null) {
			//return Result.error("未找到角色菜单配置信息");
		}else {
			String drChecked = sysRolePermission.getDataRuleIds();
			if(oConvertUtils.isNotEmpty(drChecked)) {
				map.put("drChecked", drChecked.endsWith(",")?drChecked.substring(0, drChecked.length()-1):drChecked);
			}
		}
		return Result.ok(map);
		//TODO 以后按钮权限的查询也走这个请求 无非在map中多加两个key
	}
}
 
Example #24
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 #25
Source File: PointServiceImpl.java    From iot-dc3 with Apache License 2.0 5 votes vote down vote up
@Override
@Cacheable(value = Common.Cache.POINT + Common.Cache.NAME, key = "#profileId+'.'+#name", unless = "#result==null")
public Point selectByNameAndProfile(String name, Long profileId) {
    LambdaQueryWrapper<Point> queryWrapper = Wrappers.<Point>query().lambda();
    queryWrapper.eq(Point::getName, name);
    queryWrapper.eq(Point::getProfileId, profileId);
    return pointMapper.selectOne(queryWrapper);
}
 
Example #26
Source File: TestUser.java    From SpringBoot2.0 with Apache License 2.0 5 votes vote down vote up
@Test
public void testLambdaSelect() {
    LambdaQueryWrapper<User> id = Wrappers.<User>query().lambda().eq(User::getId, "1");
    id.eq(User::getId, "2");
    for (int i = 0; i < 100000; i++) {
        List<User> list = userService.list(id);
        System.out.println(list);
    }
}
 
Example #27
Source File: NoticeController.java    From mall4j with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 分页查询
 *
 * @param page   分页对象
 * @param notice 公告管理
 * @return 分页数据
 */
@GetMapping("/page")
public ResponseEntity<IPage<Notice>> getNoticePage(PageParam<Notice> page, Notice notice) {
    IPage<Notice> noticeIPage = noticeService.page(page, new LambdaQueryWrapper<Notice>()
            .eq(notice.getStatus() != null, Notice::getStatus, notice.getStatus())
            .like(notice.getTitle() != null, Notice::getTitle, notice.getTitle()).orderByDesc(Notice::getUpdateTime));
    return ResponseEntity.ok(noticeIPage);
}
 
Example #28
Source File: SysDepartServiceImpl.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
/**
 * queryTreeList 对应 queryTreeList 查询所有的部门数据,以树结构形式响应给前端
 */
@Cacheable(value = CacheConstant.SYS_DEPARTS_CACHE)
@Override
public List<SysDepartTreeModel> queryTreeList() {
	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<SysDepartTreeModel> listResult = FindsDepartsChildrenUtil.wrapTreeDataToTreeList(list);
	return listResult;
}
 
Example #29
Source File: FormServiceImpl.java    From spring-cloud-shop with MIT License 5 votes vote down vote up
@Override
public List<FieldResponse> get(String bizType) {

    // 查询表单模型
    Form form = this.baseMapper.selectOne(new LambdaQueryWrapper<Form>()
            .eq(Form::getBizType, bizType)
            .eq(Form::getDeleteStatus, Boolean.FALSE));
    if (Objects.isNull(form)) {
        return Collections.emptyList();
    }

    // 查询表单字段
    List<Field> fields = fieldMapper.selectList(new LambdaQueryWrapper<Field>()
            .eq(Field::getFormId, form.getId())
            .eq(Field::getDeleteStatus, Boolean.FALSE));
    if (CollectionUtils.isEmpty(fields)) {
        return Collections.emptyList();
    }

    return fields.stream().map(field -> {
        FieldResponse fieldRes = new FieldResponse();
        fieldRes.setType(field.getType());
        fieldRes.setTitle(field.getTitle());

        FieldProps fieldProps = fieldPropsMapper.selectOne(new LambdaQueryWrapper<FieldProps>()
                .eq(FieldProps::getFieldId, field.getId())
                .eq(FieldProps::getDeleteStatus, Boolean.FALSE));
        // 字段没有配置,则返回空
        if (Objects.isNull(fieldProps)) {
            return null;
        }

        fieldRes.setProps(BeanCopier.copy(fieldProps, new FieldPropsResponse()));
        return fieldRes;
    }).filter(Objects::nonNull).collect(Collectors.toList());
}
 
Example #30
Source File: SysPermissionServiceImpl.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
/**
 * 根据父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) {
		String id = ""; // 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);
			}
		}
	}
}