云
2026-09-29 f87ce86307056f63f79312178037cc8714eb2b13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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);
    }
 
}