fix: clean booth snapshots when deleting outdoor fairs
This commit is contained in:
@@ -423,7 +423,7 @@ public class OutdoorFairController extends BaseController
|
||||
if (RoleUtils.isCompanyAdmin()) {
|
||||
return AjaxResult.error("企业用户无权删除户外招聘会");
|
||||
}
|
||||
return toAjax(outdoorFairService.removeByIds(Arrays.asList(ids)));
|
||||
return toAjax(outdoorFairService.removeWithBoothSnapshotsByIds(Arrays.asList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.cms.service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
@@ -21,6 +22,14 @@ public interface IOutdoorFairService extends IService<OutdoorFair>
|
||||
*/
|
||||
List<OutdoorFair> selectOutdoorFairList(OutdoorFair outdoorFair);
|
||||
|
||||
/**
|
||||
* 删除户外招聘会及其展位副本、展位预定记录。
|
||||
*
|
||||
* @param ids 招聘会 ID 集合
|
||||
* @return 删除的招聘会数量
|
||||
*/
|
||||
int removeWithBoothSnapshotsByIds(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 新增户外招聘会相关字典项
|
||||
*
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
package com.ruoyi.cms.service.impl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cms.domain.OutdoorFair;
|
||||
import com.ruoyi.cms.mapper.OutdoorFairBoothBookingMapper;
|
||||
import com.ruoyi.cms.mapper.OutdoorFairBoothMapper;
|
||||
import com.ruoyi.cms.mapper.OutdoorFairMapper;
|
||||
import com.ruoyi.cms.service.IOutdoorFairService;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DictUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 户外招聘会Service业务层处理
|
||||
@@ -25,6 +30,12 @@ public class OutdoorFairServiceImpl extends ServiceImpl<OutdoorFairMapper, Outdo
|
||||
|
||||
private static final String OUTDOOR_FAIR_REGION_DICT = "outdoor_fair_region";
|
||||
|
||||
@Autowired
|
||||
private OutdoorFairBoothMapper outdoorFairBoothMapper;
|
||||
|
||||
@Autowired
|
||||
private OutdoorFairBoothBookingMapper outdoorFairBoothBookingMapper;
|
||||
|
||||
/**
|
||||
* 查询户外招聘会列表
|
||||
*
|
||||
@@ -46,6 +57,27 @@ public class OutdoorFairServiceImpl extends ServiceImpl<OutdoorFairMapper, Outdo
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除招聘会时,展位副本和预定没有继续保留的业务意义;必须与主记录在同一事务内清理,
|
||||
* 避免逻辑删除后的招聘会遗留可见展位或预定孤儿数据。
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int removeWithBoothSnapshotsByIds(Collection<Long> ids)
|
||||
{
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
for (Long fairId : ids) {
|
||||
if (fairId == null) {
|
||||
continue;
|
||||
}
|
||||
outdoorFairBoothBookingMapper.physicalDeleteByFairId(fairId);
|
||||
outdoorFairBoothMapper.physicalDeleteByFairId(fairId);
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增户外招聘会相关字典项
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user