From 2e233cfdd15c32036feb52c607cb21fc5d3da4fe Mon Sep 17 00:00:00 2001 From: BrunoGao Date: Sun, 21 Sep 2025 22:48:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8Dcustomer=E7=A7=9F?= =?UTF-8?q?=E6=88=B7=E7=AE=A1=E7=90=86=E7=B3=BB=E7=BB=9F=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=92=8C=E5=88=9B=E5=BB=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复租户列表接口返回正确的customerId(顶级部门ID) - 修复查询接口按customer_id字段正确查询 - 优化customer创建流程,确保数据一致性 - 添加查询参数验证,避免id=0干扰查询结果 - 移除重复的组织单元创建逻辑,防止重复事件触发 - 统一customer概念,明确数据关联关系 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../customer/TCustomerConfigController.java | 7 +- .../dto/config/TCustomerConfigSearchDTO.java | 2 + .../impl/TCustomerConfigFacadeImpl.java | 6 +- .../impl/TCustomerConfigServiceImpl.java | 76 ++++++++++++------- 4 files changed, 55 insertions(+), 36 deletions(-) diff --git a/ljwx-boot/ljwx-boot-admin/src/main/java/com/ljwx/admin/controller/customer/TCustomerConfigController.java b/ljwx-boot/ljwx-boot-admin/src/main/java/com/ljwx/admin/controller/customer/TCustomerConfigController.java index 9ece133..59af049 100644 --- a/ljwx-boot/ljwx-boot-admin/src/main/java/com/ljwx/admin/controller/customer/TCustomerConfigController.java +++ b/ljwx-boot/ljwx-boot-admin/src/main/java/com/ljwx/admin/controller/customer/TCustomerConfigController.java @@ -429,10 +429,11 @@ public class TCustomerConfigController { .filter(config -> config.getIsDeleted() == null || config.getIsDeleted() == 0) // 过滤未删除的 .map(config -> { Map customer = new HashMap<>(); - customer.put("customerId", config.getId()); + customer.put("customerId", config.getCustomerId()); // 返回顶级部门ID,用于前端选择 customer.put("customerName", config.getCustomerName()); - log.debug("Customer: id={}, name={}, isDeleted={}", - config.getId(), config.getCustomerName(), config.getIsDeleted()); + customer.put("configId", config.getId()); // 添加配置记录ID,备用 + log.debug("Customer: configId={}, customerId={}, name={}, isDeleted={}", + config.getId(), config.getCustomerId(), config.getCustomerName(), config.getIsDeleted()); return customer; }) .collect(Collectors.toList()); diff --git a/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/domain/dto/config/TCustomerConfigSearchDTO.java b/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/domain/dto/config/TCustomerConfigSearchDTO.java index d4fd22a..cf14eda 100644 --- a/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/domain/dto/config/TCustomerConfigSearchDTO.java +++ b/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/domain/dto/config/TCustomerConfigSearchDTO.java @@ -40,5 +40,7 @@ public class TCustomerConfigSearchDTO implements Serializable { private String customerName; private Long id; + + private Long customerId; } diff --git a/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/facade/impl/TCustomerConfigFacadeImpl.java b/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/facade/impl/TCustomerConfigFacadeImpl.java index e06e9ee..f2cc2fa 100644 --- a/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/facade/impl/TCustomerConfigFacadeImpl.java +++ b/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/facade/impl/TCustomerConfigFacadeImpl.java @@ -104,10 +104,8 @@ public class TCustomerConfigFacadeImpl implements ITCustomerConfigFacade { boolean result = tCustomerConfigService.save(tCustomerConfigBO); - if (result && tCustomerConfigBO.getId() != null) { - // 同步到 sys_org_units 表 - syncToSysOrgUnits(tCustomerConfigBO.getId(), tCustomerConfigBO.getCustomerName(), "CREATE"); - } + // 注意:不再需要手动同步到 sys_org_units,Service层已经处理了创建逻辑 + // 避免重复创建和重复事件触发 return result; } diff --git a/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/service/impl/TCustomerConfigServiceImpl.java b/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/service/impl/TCustomerConfigServiceImpl.java index aefbc10..7309f91 100644 --- a/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/service/impl/TCustomerConfigServiceImpl.java +++ b/ljwx-boot/ljwx-boot-modules/src/main/java/com/ljwx/modules/customer/service/impl/TCustomerConfigServiceImpl.java @@ -34,6 +34,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import lombok.extern.slf4j.Slf4j; /** * Service 服务接口实现层 @@ -44,6 +45,7 @@ import org.springframework.transaction.annotation.Transactional; * @CreateTime 2024-12-29 - 15:33:30 */ +@Slf4j @Service public class TCustomerConfigServiceImpl extends ServiceImpl implements ITCustomerConfigService { @@ -55,15 +57,27 @@ public class TCustomerConfigServiceImpl extends ServiceImpl listTCustomerConfigPage(PageQuery pageQuery, TCustomerConfigBO tCustomerConfigBO) { + log.info("查询t_customer_config参数: id={}, customerId={}, customerName={}", + tCustomerConfigBO.getId(), tCustomerConfigBO.getCustomerId(), tCustomerConfigBO.getCustomerName()); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() - .eq(ObjectUtils.isNotEmpty(tCustomerConfigBO.getId()), TCustomerConfig::getId, tCustomerConfigBO.getId()); + .eq(ObjectUtils.isNotEmpty(tCustomerConfigBO.getId()) && tCustomerConfigBO.getId() > 0, + TCustomerConfig::getId, tCustomerConfigBO.getId()); - // 简化查询,移除租户逻辑暂时 - 暂时注释掉getCustomerName调用避免编译错误 - // if (ObjectUtils.isNotEmpty(tCustomerConfigBO.getCustomerName())) { - // queryWrapper.like(TCustomerConfig::getCustomerName, tCustomerConfigBO.getCustomerName()); - // } + // URL参数customerId是顶级部门ID,应该按customer_id字段查询 + if (ObjectUtils.isNotEmpty(tCustomerConfigBO.getCustomerId())) { + log.info("按customer_id查询: {}", tCustomerConfigBO.getCustomerId()); + queryWrapper.eq(TCustomerConfig::getCustomerId, tCustomerConfigBO.getCustomerId()); + } - return baseMapper.selectPage(pageQuery.buildPage(), queryWrapper); + if (ObjectUtils.isNotEmpty(tCustomerConfigBO.getCustomerName())) { + queryWrapper.like(TCustomerConfig::getCustomerName, tCustomerConfigBO.getCustomerName()); + } + + IPage result = baseMapper.selectPage(pageQuery.buildPage(), queryWrapper); + log.info("查询结果: total={}, records={}", result.getTotal(), result.getRecords().size()); + + return result; } @Override @@ -76,35 +90,39 @@ public class TCustomerConfigServiceImpl extends ServiceImpl