| | |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.srm.controller.admin.supplier.vo.SrmSupplierPageReqVO; |
| | | import cn.iocoder.yudao.module.srm.controller.admin.supplier.vo.SrmSupplierSaveReqVO; |
| | | import cn.iocoder.yudao.module.srm.dal.dataobject.SrmSupplierDO; |
| | | import cn.iocoder.yudao.module.srm.dal.dataobject.*; |
| | | import cn.iocoder.yudao.module.srm.dal.mysql.SrmBidAwardMapper; |
| | | import cn.iocoder.yudao.module.srm.dal.mysql.SrmBidEvaluationMapper; |
| | | import cn.iocoder.yudao.module.srm.dal.mysql.SrmSupplierApplyMapper; |
| | | import cn.iocoder.yudao.module.srm.dal.mysql.SrmSupplierCategoryMapper; |
| | | import cn.iocoder.yudao.module.srm.dal.mysql.SrmSupplierContactMapper; |
| | | import cn.iocoder.yudao.module.srm.dal.mysql.SrmSupplierCertificateMapper; |
| | | import cn.iocoder.yudao.module.srm.dal.mysql.SrmSupplierMapper; |
| | | import cn.iocoder.yudao.module.srm.dal.mysql.SrmTenderBidMapper; |
| | | import cn.iocoder.yudao.module.srm.enums.ErrorCodeConstants; |
| | | import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | |
| | | |
| | | @Resource |
| | | private SrmSupplierCategoryMapper supplierCategoryMapper; |
| | | |
| | | @Resource |
| | | private SrmSupplierApplyMapper supplierApplyMapper; |
| | | |
| | | @Resource |
| | | private SrmSupplierCertificateMapper supplierCertificateMapper; |
| | | |
| | | @Resource |
| | | private SrmTenderBidMapper tenderBidMapper; |
| | | |
| | | @Resource |
| | | private SrmBidEvaluationMapper bidEvaluationMapper; |
| | | |
| | | @Resource |
| | | private SrmBidAwardMapper bidAwardMapper; |
| | | |
| | | @Override |
| | | public Long createSupplier(SrmSupplierSaveReqVO createReqVO) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteSupplier(Long id) { |
| | | // 校验存在性 |
| | | validateSupplierExists(id); |
| | | // 删除关联数据 |
| | | // 关联数据存在时,不允许删除 |
| | | validateNoReference(id); |
| | | // 可直接清理的关联数据 |
| | | supplierContactMapper.deleteBySupplierId(id); |
| | | supplierCategoryMapper.deleteBySupplierId(id); |
| | | // 逻辑删除 |
| | |
| | | } |
| | | } |
| | | |
| | | private void validateNoReference(Long id) { |
| | | boolean hasReference = supplierApplyMapper.existsApprovedBySupplierId(id) |
| | | || supplierCertificateMapper.selectCount(SrmSupplierCertificateDO::getSupplierId, id) > 0 |
| | | || tenderBidMapper.selectCount(SrmTenderBidDO::getSupplierId, id) > 0 |
| | | || bidEvaluationMapper.selectCount(SrmBidEvaluationDO::getSupplierId, id) > 0 |
| | | || bidAwardMapper.selectCount(SrmBidAwardDO::getSupplierId, id) > 0; |
| | | if (hasReference) { |
| | | throw ServiceExceptionUtil.exception(ErrorCodeConstants.SUPPLIER_EXISTS_REFERENCE); |
| | | } |
| | | } |
| | | |
| | | } |