feat(oa): 实现送货单和工艺卡删除时级联删除明细记录
- 在删除送货单主记录前先删除其关联的明细记录 - 在删除工艺卡主记录前先删除其关联的明细记录 - 为送货单删除方法添加事务注解确保数据一致性 - 明确删除操作顺序避免外键约束导致的删除失败
This commit is contained in:
@@ -155,10 +155,20 @@ public class OaDeliveryOrderServiceImpl implements IOaDeliveryOrderService {
|
||||
* 批量删除送货单主
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
|
||||
// 先删除明细表记录
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
LambdaQueryWrapper<OaDeliveryOrderDetail> detailWrapper = Wrappers.lambdaQuery();
|
||||
detailWrapper.in(OaDeliveryOrderDetail::getOrderId, ids);
|
||||
detailMapper.delete(detailWrapper);
|
||||
}
|
||||
|
||||
// 再删除主表记录
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -139,6 +139,10 @@ public class OaProcessCardServiceImpl implements IOaProcessCardService {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
// 先删除明细表数据 先判断
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
oaProcessCardDetailMapper.delete(Wrappers.<OaProcessCardDetail>lambdaQuery().in(OaProcessCardDetail::getCardId, ids));
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user