| | |
| | | // 2. 构建查询条件(增强空值安全) |
| | | LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>(); |
| | | String customerName = customer.getCustomerName(); |
| | | String customerType = customer.getCustomerType(); |
| | | if (StringUtils.isNotBlank(customerName)) { |
| | | queryWrapper.like(Customer::getCustomerName, customerName); |
| | | } |
| | | if (StringUtils.isNotBlank(customerType)) { |
| | | queryWrapper.like(Customer::getCustomerType, customerType); |
| | | } |
| | | |
| | | // 3. 执行分页查询(保留分页元数据) |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> customerList(Customer customer) { |
| | | LambdaQueryWrapper<Customer> queryWrapper = Wrappers.lambdaQuery(); |
| | | queryWrapper.select(Customer::getId, Customer::getCustomerName, Customer::getTaxpayerIdentificationNumber); |
| | | |
| | | // 获取原始查询结果 |
| | | List<Map<String, Object>> result = customerMapper.selectMaps(queryWrapper); |
| | | |
| | | // 将下划线命名转换为驼峰命名 |
| | | return result.stream().map(map -> map.entrySet().stream() |
| | | .collect(Collectors.toMap( |
| | | entry -> underlineToCamel(entry.getKey()), |
| | | Map.Entry::getValue)) |
| | | ).collect(Collectors.toList()); |
| | | public List<Customer> customerList(Customer customer) { |
| | | return customerMapper.selectList( null); |
| | | } |
| | | |
| | | /** |