| | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> customerList(Customer customer) { |
| | | LambdaQueryWrapper<Customer> queryWrapper = Wrappers.lambdaQuery(); |
| | | queryWrapper.select(Customer::getId, Customer::getCustomerName, Customer::getTaxpayerIdentificationNumber); |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | Long loginUserId = loginUser.getUserId(); |
| | | CustomerDto query = new CustomerDto(); |
| | | if (customer != null) { |
| | | BeanUtils.copyProperties(customer, query); |
| | | } |
| | | |
| | | // 获取原始查询结果 |
| | | List<Map<String, Object>> result = customerMapper.selectMaps(queryWrapper); |
| | | // 复用客户列表的可见性规则,避免把别人的私海客户暴露给当前账号 |
| | | List<CustomerVo> visibleCustomers = customerMapper.list(query, loginUserId); |
| | | if (CollectionUtils.isEmpty(visibleCustomers)) { |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | // 将下划线命名转换为驼峰命名 |
| | | return result.stream().map(map -> map.entrySet().stream() |
| | | .collect(Collectors.toMap( |
| | | entry -> underlineToCamel(entry.getKey()), |
| | | Map.Entry::getValue)) |
| | | ).collect(Collectors.toList()); |
| | | return visibleCustomers.stream().map(item -> { |
| | | Map<String, Object> map = new LinkedHashMap<>(); |
| | | map.put("id", item.getId()); |
| | | map.put("customerName", item.getCustomerName()); |
| | | map.put("taxpayerIdentificationNumber", item.getTaxpayerIdentificationNumber()); |
| | | return map; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | // 分配公海客户给私海 |