| | |
| | | package cn.iocoder.yudao.module.srm.service.certificate; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.srm.controller.admin.certificate.vo.SrmSupplierCertificatePageReqVO; |
| | |
| | | import cn.iocoder.yudao.module.srm.dal.mysql.SrmSupplierCertificateMapper; |
| | | import cn.iocoder.yudao.module.srm.enums.ErrorCodeConstants; |
| | | import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; |
| | | import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.time.LocalDate; |
| | |
| | | @Validated |
| | | public class SrmSupplierCertificateServiceImpl implements SrmSupplierCertificateService { |
| | | |
| | | /** |
| | | * 资质证书附件的业务记录类型,对应 {@link cn.iocoder.yudao.module.system.enums.storage.StorageRecordTypeEnum#SRM_SUPPLIER_CERTIFICATE} |
| | | */ |
| | | public static final String CERTIFICATE_RECORD_TYPE = "srm_supplier_certificate"; |
| | | |
| | | @Resource |
| | | private SrmSupplierCertificateMapper certificateMapper; |
| | | |
| | | @Resource |
| | | private StorageAttachmentApi storageAttachmentApi; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long createCertificate(SrmSupplierCertificateSaveReqVO createReqVO) { |
| | | SrmSupplierCertificateDO certificate = BeanUtils.toBean(createReqVO, SrmSupplierCertificateDO.class); |
| | | updateStatus(certificate); |
| | | certificateMapper.insert(certificate); |
| | | // 绑定证书附件 |
| | | if (CollUtil.isNotEmpty(createReqVO.getBlobIds())) { |
| | | storageAttachmentApi.bindAttachments("file", CERTIFICATE_RECORD_TYPE, certificate.getId(), createReqVO.getBlobIds()); |
| | | } |
| | | return certificate.getId(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateCertificate(SrmSupplierCertificateSaveReqVO updateReqVO) { |
| | | validateCertificateExists(updateReqVO.getId()); |
| | | SrmSupplierCertificateDO updateObj = BeanUtils.toBean(updateReqVO, SrmSupplierCertificateDO.class); |
| | | updateStatus(updateObj); |
| | | certificateMapper.updateById(updateObj); |
| | | // 增量更新证书附件 |
| | | storageAttachmentApi.updateAttachments("file", CERTIFICATE_RECORD_TYPE, updateReqVO.getId(), updateReqVO.getBlobIds()); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteCertificate(Long id) { |
| | | validateCertificateExists(id); |
| | | // 删除证书附件 |
| | | storageAttachmentApi.deleteAttachmentsByRecord(CERTIFICATE_RECORD_TYPE, id); |
| | | certificateMapper.deleteById(id); |
| | | } |
| | | |