package cn.iocoder.yudao.module.archive.api.document;
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.module.archive.api.document.dto.ArchiveDocumentCreateReqDTO;
|
import cn.iocoder.yudao.module.archive.api.document.dto.ArchiveDocumentRespDTO;
|
import cn.iocoder.yudao.module.archive.dal.dataobject.category.ArchiveCategoryDO;
|
import cn.iocoder.yudao.module.archive.dal.dataobject.document.ArchiveDocumentDO;
|
import cn.iocoder.yudao.module.archive.service.category.ArchiveCategoryService;
|
import cn.iocoder.yudao.module.archive.service.document.ArchiveDocumentService;
|
import jakarta.annotation.Resource;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
/**
|
* 档案归档 API 实现类
|
*
|
* 供其他模块(课题/会员/财务)按来源单据归档,生成档案条目并带入来源附件。
|
* 该实现为本地 Bean 调用(无 {@code @PreAuthorize}),权限由调用方(来源模块)的归档按钮权限点控制。
|
*
|
* @author 超级管理员
|
*/
|
@RestController
|
@RequestMapping(ArchiveDocumentApi.PREFIX)
|
@Validated
|
public class ArchiveDocumentApiImpl implements ArchiveDocumentApi {
|
|
@Resource
|
private ArchiveDocumentService archiveDocumentService;
|
|
@Resource
|
private ArchiveCategoryService archiveCategoryService;
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public CommonResult<Long> archiveBySource(ArchiveDocumentCreateReqDTO reqDTO) {
|
return success(archiveDocumentService.archiveBySource(reqDTO));
|
}
|
|
@Override
|
public CommonResult<Boolean> isArchived(Integer sourceType, Long sourceId) {
|
return success(archiveDocumentService.isArchived(sourceType, sourceId));
|
}
|
|
@Override
|
public CommonResult<ArchiveDocumentRespDTO> getBySource(Integer sourceType, Long sourceId) {
|
ArchiveDocumentDO document = archiveDocumentService.getBySource(sourceType, sourceId);
|
if (document == null) {
|
return success(null);
|
}
|
// 补充分类名称,便于来源模块列表页直接展示
|
ArchiveDocumentRespDTO respDTO = BeanUtils.toBean(document, ArchiveDocumentRespDTO.class);
|
ArchiveCategoryDO category = archiveCategoryService.getCategory(document.getCategoryId());
|
if (category != null) {
|
respDTO.setCategoryName(category.getName());
|
}
|
return success(respDTO);
|
}
|
|
}
|