package jnpf.dmsService.pdf;
|
|
import jnpf.dmsEntity.storage.pdf.DmsPdfGenerationTask;
|
import jnpf.dmsEntity.storage.vo.DmsPersistentPdfGenerateVO;
|
import jnpf.dmsMapper.DmsPdfGenerationTaskMapper;
|
import jnpf.exception.DataException;
|
import lombok.RequiredArgsConstructor;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
@Service
|
@RequiredArgsConstructor
|
public class DmsPdfGenerationCompletion {
|
private final DmsPdfGenerationTaskMapper mapper;
|
|
@Transactional(rollbackFor = Exception.class)
|
public void succeed(DmsPdfGenerationTask task, String token, DmsPersistentPdfGenerateVO pdf) {
|
if (pdf == null || pdf.getObjectKey() == null || pdf.getSizeBytes() == null
|
|| pdf.getChecksumSha256() == null || pdf.getSourceChecksumSha256() == null) {
|
throw new DataException("持久化 PDF 返回结果不完整");
|
}
|
if (mapper.writePdf(task.getTenantId(), task.getFileVersionId(),
|
task.getSourceChecksumSha256(), pdf) != 1) {
|
throw new DataException("源文件已变化,拒绝写入过期 PDF");
|
}
|
if (mapper.succeed(task.getTenantId(), task.getFileVersionId(), token) != 1) {
|
throw new DataException("持久化 PDF 任务租约已失效");
|
}
|
}
|
}
|