You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

2.8 KiB

crm-rule 公海池批量删除 pool/delete-batch

Type: task Status: resolved Depends on: 10 ADR: docs/adr/0023-lead-batch-operations-and-view-stats.md (D5, 方案 A)

Question(实现目标)

为公海池补批量删除(原型 A7-3-1)。失败项归 crm-rule 自持(crm-rule 不能依赖 crm-lead,故不复用 LeadBatchFailItem)。

交付物

领域件(crm-rule)

  • domain/enums/PoolBatchFailReason.javaNOT_EXIST(64004)、HAS_ACTIVE_LEAD(64005, 预留)、UNKNOWN;各带 code + fromCode(int)
  • domain/dto/PoolBatchFailItem.javaLong poolId + PoolBatchFailReason reason + String message + of(...) 工厂。

service(crm-rule)

  • ILeadPoolServiceBatchResult<PoolBatchFailItem> deleteBatch(List<Long> ids)
  • LeadPoolServiceImpl@Lazy self-injection 逐条调 self.deletePool(id)(各自独立事务);捕 BusinessErrorExceptionPoolBatchFailReason.fromCode(e.getCode());其他→UNKNOWN+log。批量方法不加 @Transactional

controller(crm-rule)

  • LeadPoolController@PostMapping("/delete-batch")@RequestParam("ids") List<Long> ids,返回 Result<BatchResult<PoolBatchFailItem>>

范围外(本期不做,grill 决策 B)

  • 不补「池下有非终态线索则拒删」守卫(CODE_POOL_HAS_ACTIVE_LEAD 64005 保持预留)。该守卫需跨 crm-rule→线索表查询,触及依赖方向难题,另立独立 issue。故本期池批量删除实际失败原因仅 NOT_EXIST/UNKNOWN

验收

  • 编译:mvn -q -pl crm-rule -am compile。无 BOM。
  • 无依赖环:crm-rule 不 import 任何 com.crm.lead.*mvn -pl crm-rule compile 能独立于 crm-lead 通过)。
  • 单测:全成功 / 混入不存在 id(64004) / 空 ids → 计数与 failures 正确。

Comments

Answer

已交付(ADR-0023 D5 方案 A):

  • crm-rule 自持失败项(避 cycle):domain/enums/PoolBatchFailReason(NOT_EXIST=64004 / HAS_ACTIVE_LEAD=64005 保留 / UNKNOWN,各带 code)+ domain/dto/PoolBatchFailItem(poolId+reason+message+of),复用 crm-base BatchResult<F>
  • ILeadPoolService.deletePoolBatch(List<Long>) + impl:@Slf4j + @Lazy @Autowired ILeadPoolService self,逐条 self.deletePool(id)(各自独立事务),捕 BusinessErrorException 映 reason / 其他异常 UNKNOWN+log.error。
  • LeadPoolController POST /api/rule/pool/delete-batch@RequestParam("ids") List<Long>,返 Result<BatchResult<PoolBatchFailItem>>
  • 本期口径:单条 deletePool 只抛 NOT_EXIST,批量仅产出 NOT_EXIST/UNKNOWN;HAS_ACTIVE_LEAD 为保留项(Q8 方案 B,守卫延后)。

验收:无 BOM;mvn -pl crm-rule -am compile BUILD SUCCESS;LeadPoolBatchDeleteTest 4/4(全成功/NOT_EXIST 映射/UNKNOWN 兜底/空 ids)+ LeadPoolServiceImplTest 15/15 无回归。