云
16 小时以前 fec1341c1cb8e11cfbe3fa7dfabe447edb72b630
yudao-module-srm/src/main/java/cn/iocoder/yudao/module/srm/controller/admin/certificate/SrmSupplierCertificateController.java
@@ -6,7 +6,9 @@
import cn.iocoder.yudao.module.srm.controller.admin.certificate.vo.*;
import cn.iocoder.yudao.module.srm.dal.dataobject.SrmSupplierDO;
import cn.iocoder.yudao.module.srm.service.certificate.SrmSupplierCertificateService;
import cn.iocoder.yudao.module.srm.service.certificate.SrmSupplierCertificateServiceImpl;
import cn.iocoder.yudao.module.srm.service.supplier.SrmSupplierService;
import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -35,6 +37,9 @@
    @Resource
    private SrmSupplierService supplierService;
    @Resource
    private StorageAttachmentApi storageAttachmentApi;
    @PostMapping("/create")
    @Operation(summary = "创建资质证书")
    @PreAuthorize("@ss.hasPermission('srm:supplier-certificate:create')")
@@ -61,26 +66,25 @@
    @GetMapping("/page")
    @Operation(summary = "获取资质证书分页")
    @PreAuthorize("@ss.hasPermission('srm:supplier-certificate:query')")
    public CommonResult<PageResult<SrmSupplierCertificateRespVO>> getCertificatePage(@Valid SrmSupplierCertificatePageReqVO pageReqVO) {
        var pageResult = certificateService.getCertificatePage(pageReqVO);
        var respList = BeanUtils.toBean(pageResult.getList(), SrmSupplierCertificateRespVO.class);
        enrichSupplierNames(respList);
        enrichAttachments(respList);
        return success(new PageResult<>(respList, pageResult.getTotal()));
    }
    @GetMapping("/list-by-supplier")
    @Operation(summary = "根据供应商ID获取资质列表")
    @PreAuthorize("@ss.hasPermission('srm:supplier-certificate:query')")
    public CommonResult<List<SrmSupplierCertificateRespVO>> getListBySupplier(@RequestParam("supplierId") Long supplierId) {
        var list = BeanUtils.toBean(certificateService.getCertificateListBySupplierId(supplierId), SrmSupplierCertificateRespVO.class);
        enrichSupplierNames(list);
        enrichAttachments(list);
        return success(list);
    }
    @GetMapping("/expiring-list")
    @Operation(summary = "获取即将到期的资质列表(30天内)")
    @PreAuthorize("@ss.hasPermission('srm:supplier-certificate:query')")
    public CommonResult<List<SrmSupplierCertificateRespVO>> getExpiringList() {
        var list = BeanUtils.toBean(certificateService.getExpiringCertificates(), SrmSupplierCertificateRespVO.class);
        enrichSupplierNames(list);
@@ -89,10 +93,10 @@
    @GetMapping("/get")
    @Operation(summary = "获取资质证书详情")
    @PreAuthorize("@ss.hasPermission('srm:supplier-certificate:query')")
    public CommonResult<SrmSupplierCertificateRespVO> getCertificate(@RequestParam("id") Long id) {
        var resp = BeanUtils.toBean(certificateService.getCertificate(id), SrmSupplierCertificateRespVO.class);
        enrichSupplierName(resp);
        enrichAttachments(List.of(resp));
        return success(resp);
    }
@@ -118,4 +122,10 @@
        }
    }
    private void enrichAttachments(List<SrmSupplierCertificateRespVO> list) {
        if (list == null || list.isEmpty()) return;
        list.forEach(vo -> vo.setAttachmentList(storageAttachmentApi.listAttachments(
                SrmSupplierCertificateServiceImpl.CERTIFICATE_RECORD_TYPE, vo.getId())));
    }
}