From 3b9ba1076abd6560b054b541f5af029350e40c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=B9=8F?= Date: Sun, 23 Feb 2025 10:41:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/module/infra/api/file/FileApi.java | 12 ++++++--- .../infra/api/file/dto/InfraFileInfoDTO.java | 9 +++++++ .../module/infra/api/file/FileApiImpl.java | 11 ++++++-- .../controller/admin/file/FileController.java | 3 ++- .../app/file/AppFileController.java | 4 ++- .../infra/service/file/FileService.java | 5 ++-- .../infra/service/file/FileServiceImpl.java | 18 ++++++------- .../enterprise/EnterpriseController.java | 18 +++++++------ .../admin/enterprise/vo/EnterpriseRespVO.java | 3 ++- .../InspectionsLogController.java | 8 +++--- .../vo/InspectionsLogSaveReqVO.java | 2 +- .../EnterpriseQualificationController.java | 12 ++++++++- .../vo/EnterpriseQualificationRespVO.java | 3 +++ .../vo/EnterpriseQualificationSaveReqVO.java | 3 +++ .../dataobject/enterprise/EnterpriseDO.java | 3 ++- .../inspectionslog/InspectionsLogDO.java | 3 ++- .../enterprise/EnterpriseServiceImpl.java | 14 ++++++++--- .../service/fileInfo/FileInfoService.java | 8 ++++-- .../service/fileInfo/FileInfoServiceImpl.java | 24 ++++++++++++------ .../EnterpriseQualificationServiceImpl.java | 25 +++++++++++++++++++ .../social/SocialClientServiceImpl.java | 2 +- .../service/user/AdminUserServiceImpl.java | 7 +++--- 22 files changed, 145 insertions(+), 52 deletions(-) create mode 100644 yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/dto/InfraFileInfoDTO.java diff --git a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApi.java b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApi.java index d322a86..97fa57c 100644 --- a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApi.java +++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApi.java @@ -1,5 +1,7 @@ package cn.iocoder.yudao.module.infra.api.file; +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; + import java.util.List; import java.util.Map; @@ -16,7 +18,7 @@ public interface FileApi { * @param content 文件内容 * @return 文件路径 */ - default Map createFile(byte[] content) { + default InfraFileInfoDTO createFile(byte[] content) { return createFile(null, null, content); } @@ -27,7 +29,7 @@ public interface FileApi { * @param content 文件内容 * @return 文件路径 */ - default Map createFile(String path, byte[] content) { + default InfraFileInfoDTO createFile(String path, byte[] content) { return createFile(null, path, content); } @@ -39,8 +41,10 @@ public interface FileApi { * @param content 文件内容 * @return 文件路径 */ - Map createFile(String name, String path, byte[] content); + InfraFileInfoDTO createFile(String name, String path, byte[] content); + + List listFile(List ids); - List> listFile(List ids); + void deleteFile(Long id) throws Exception; } diff --git a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/dto/InfraFileInfoDTO.java b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/dto/InfraFileInfoDTO.java new file mode 100644 index 0000000..5edd6b2 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/dto/InfraFileInfoDTO.java @@ -0,0 +1,9 @@ +package cn.iocoder.yudao.module.infra.api.file.dto; + +import lombok.Data; + +@Data +public class InfraFileInfoDTO { + private String url; + private Long id; +} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApiImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApiImpl.java index 467574a..ec278a4 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApiImpl.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/api/file/FileApiImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.infra.api.file; +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.infra.service.file.FileService; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -21,14 +22,20 @@ public class FileApiImpl implements FileApi { private FileService fileService; @Override - public Map createFile(String name, String path, byte[] content) { + public InfraFileInfoDTO createFile(String name, String path, byte[] content) { return fileService.createFile(name, path, content); } @Override - public List> listFile(List ids) { + public List listFile(List ids) { return fileService.listFile(ids); } + @Override + public void deleteFile(Long id) throws Exception { + fileService.deleteFile(id); + } + + } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java index 9dfc7ab..6e62fb0 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java @@ -6,6 +6,7 @@ import cn.hutool.core.util.URLUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.*; import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO; import cn.iocoder.yudao.module.infra.service.file.FileService; @@ -42,7 +43,7 @@ public class FileController { @PostMapping("/upload") @Operation(summary = "上传文件", description = "模式一:后端上传文件") - public CommonResult> uploadFile(FileUploadReqVO uploadReqVO) throws Exception { + public CommonResult uploadFile(FileUploadReqVO uploadReqVO) throws Exception { MultipartFile file = uploadReqVO.getFile(); String path = uploadReqVO.getPath(); return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream()))); diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/app/file/AppFileController.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/app/file/AppFileController.java index 4b46573..8de0e49 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/app/file/AppFileController.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/app/file/AppFileController.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.infra.controller.app.file; import cn.hutool.core.io.IoUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileCreateReqVO; import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePresignedUrlRespVO; import cn.iocoder.yudao.module.infra.controller.app.file.vo.AppFileUploadReqVO; @@ -17,6 +18,7 @@ import javax.annotation.Resource; import javax.annotation.security.PermitAll; import javax.validation.Valid; +import java.util.List; import java.util.Map; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -34,7 +36,7 @@ public class AppFileController { @PostMapping("/upload") @Operation(summary = "上传文件") @PermitAll - public CommonResult> uploadFile(AppFileUploadReqVO uploadReqVO) throws Exception { + public CommonResult uploadFile(AppFileUploadReqVO uploadReqVO) throws Exception { MultipartFile file = uploadReqVO.getFile(); String path = uploadReqVO.getPath(); return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream()))); diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileService.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileService.java index e9078f3..fe70ccd 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileService.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileService.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.infra.service.file; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FileCreateReqVO; import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePageReqVO; import cn.iocoder.yudao.module.infra.controller.admin.file.vo.file.FilePresignedUrlRespVO; @@ -32,7 +33,7 @@ public interface FileService { * @param content 文件内容 * @return 文件路径 */ - Map createFile(String name, String path, byte[] content); + InfraFileInfoDTO createFile(String name, String path, byte[] content); /** * 创建文件 @@ -66,5 +67,5 @@ public interface FileService { */ FilePresignedUrlRespVO getFilePresignedUrl(String path) throws Exception; - List> listFile(List ids); + List listFile(List ids); } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java index 67a56eb..a25883e 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.io.FileUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.infra.framework.file.core.client.FileClient; import cn.iocoder.yudao.module.infra.framework.file.core.client.s3.FilePresignedUrlRespDTO; import cn.iocoder.yudao.module.infra.framework.file.core.utils.FileTypeUtils; @@ -23,7 +24,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import java.util.stream.Stream; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.FILE_NOT_EXISTS; @@ -49,7 +49,7 @@ public class FileServiceImpl implements FileService { @Override @SneakyThrows - public Map createFile(String name, String path, byte[] content) { + public InfraFileInfoDTO createFile(String name, String path, byte[] content) { // 计算默认的 path 名 String type = FileTypeUtils.getMineType(content, name); if (StrUtil.isEmpty(path)) { @@ -75,9 +75,9 @@ public class FileServiceImpl implements FileService { file.setSize(content.length); fileMapper.insert(file); - Map map = new HashMap<>(); - map.put("url", url); - map.put("file_id", file.getId().toString()); + InfraFileInfoDTO map = new InfraFileInfoDTO(); + map.setUrl( url); + map.setId(file.getId()); return map; } @@ -126,15 +126,15 @@ public class FileServiceImpl implements FileService { } @Override - public List> listFile(List ids) { + public List listFile(List ids) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.in(FileDO::getId, ids); final List fileDOS = fileMapper.selectList(wrapper); return fileDOS.stream().map(fileDO -> { - Map map = new HashMap<>(); - map.put("id", fileDO.getId().toString()); - map.put("url", fileDO.getUrl()); + InfraFileInfoDTO map = new InfraFileInfoDTO(); + map.setId(fileDO.getId()); + map.setUrl(fileDO.getUrl()); return map; }).collect(Collectors.toList()); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/EnterpriseController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/EnterpriseController.java index c2f9d4c..a2aaee4 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/EnterpriseController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/EnterpriseController.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.controller.admin.enterprise; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.infra.api.file.FileApi; +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.system.controller.admin.taglibrary.vo.TagLibraryPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.taglibrary.vo.TagLibraryRespVO; import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; @@ -16,6 +17,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.enterprisetag.EnterpriseTagMappe import cn.iocoder.yudao.module.system.dal.mysql.fileInfo.FileInfoMapper; import cn.iocoder.yudao.module.system.dal.mysql.qualification.EnterpriseQualificationMapper; import cn.iocoder.yudao.module.system.dal.mysql.taglibrary.TagLibraryMapper; +import cn.iocoder.yudao.module.system.service.enterprise.EnterpriseServiceImpl; import cn.iocoder.yudao.module.system.service.enterprisetag.EnterpriseTagService; import cn.iocoder.yudao.module.system.service.fileInfo.FileInfoService; import cn.iocoder.yudao.module.system.service.qualification.EnterpriseQualificationService; @@ -124,16 +126,17 @@ public class EnterpriseController { @Parameter(name = "id", description = "编号", required = true, example = "1024") // @PreAuthorize("@ss.hasPermission('system:enterprise:query')") public CommonResult getEnterprise(@RequestParam("id") Long id) { - EnterpriseDO enterprise = enterpriseService.getEnterprise(id); + EnterpriseDO bean = enterpriseService.getEnterprise(id); + EnterpriseRespVO enterprise= BeanUtils.toBean(bean, EnterpriseRespVO.class); if (enterprise != null) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(FileInfoDO::getDictType, 644l); - wrapper.eq(FileInfoDO::getDictData, 1l); + wrapper.eq(FileInfoDO::getDictType, EnterpriseServiceImpl.DEFAULT_DICT_TYPE); + wrapper.eq(FileInfoDO::getDictData, EnterpriseServiceImpl.DEFAULT_DICT_DATA_QY); wrapper.eq(FileInfoDO::getUnitId, enterprise.getId()); final List collect = fileInfoMapper.selectList(wrapper).stream().map(res -> res.getInfraFileId()).collect(Collectors.toList()); if (!collect.isEmpty()) { - final List> list = fileApi.listFile(collect); + final List list = fileApi.listFile(collect); enterprise.setFiles(list); } @@ -153,7 +156,6 @@ public class EnterpriseController { } - //通过userID获取专管人 if (enterprise.getUserId() != null) { final AdminUserDO user = adminUserService.getUser(Long.valueOf(enterprise.getUserId())); @@ -186,7 +188,7 @@ public class EnterpriseController { } - return success(BeanUtils.toBean(enterprise, EnterpriseRespVO.class)); + return success(enterprise); } @GetMapping("/pcpage") @@ -208,7 +210,7 @@ public class EnterpriseController { PageResult pageResult = enterpriseService.getEnterprisePage(pageReqVO); pageResult.getList().forEach(item->{ //企业图片 - final List> fileList = fileInfoService.getFileList("664", "1", item.getId().toString()); + final List fileList = fileInfoService.getFileList(EnterpriseServiceImpl.DEFAULT_DICT_TYPE, EnterpriseServiceImpl.DEFAULT_DICT_DATA_QY, item.getId().toString()); item.setFiles(fileList); // 企业标签 @@ -228,7 +230,7 @@ public class EnterpriseController { final PageResult pageResult = enterpriseService.getEnterpriseByUserId(pageReqVO); pageResult.getList().forEach(item->{ //企业图片 - final List> fileList = fileInfoService.getFileList("664", "1", item.getId().toString()); + final List fileList = fileInfoService.getFileList(EnterpriseServiceImpl.DEFAULT_DICT_TYPE, EnterpriseServiceImpl.DEFAULT_DICT_DATA_QY, item.getId().toString()); item.setFiles(fileList); // 企业标签 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseRespVO.java index 3ca2a74..61ae3af 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseRespVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.controller.admin.enterprise.vo; +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.system.dal.dataobject.qualification.EnterpriseQualificationDO; import cn.iocoder.yudao.module.system.dal.dataobject.taglibrary.TagLibraryDO; import io.swagger.v3.oas.annotations.media.Schema; @@ -101,7 +102,7 @@ public class EnterpriseRespVO { private Integer audit; @Schema(description = "企业图片", example = "26433") - private List> files; + private List files; @Schema(description = "企业资质列表", example = "26433") private List qualificationList; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/inspectionslog/InspectionsLogController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/inspectionslog/InspectionsLogController.java index 4fe29c9..593d584 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/inspectionslog/InspectionsLogController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/inspectionslog/InspectionsLogController.java @@ -1,6 +1,8 @@ package cn.iocoder.yudao.module.system.controller.admin.inspectionslog; +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo.PassOnSaveVO; +import cn.iocoder.yudao.module.system.service.enterprise.EnterpriseServiceImpl; import cn.iocoder.yudao.module.system.service.fileInfo.FileInfoService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import lombok.extern.slf4j.Slf4j; @@ -91,7 +93,7 @@ public class InspectionsLogController { public CommonResult getInspectionsLog(@RequestParam("id") Long id) { InspectionsLogDO inspectionsLog = inspectionsLogService.getInspectionsLog(id); //查图片 - final List> fileList = fileInfoService.getFileList("644", "2", inspectionsLog.getId().toString()); + final List fileList = fileInfoService.getFileList(EnterpriseServiceImpl.DEFAULT_DICT_TYPE, 2L,inspectionsLog.getId().toString()); inspectionsLog.setFileList(fileList); return success(BeanUtils.toBean(inspectionsLog, InspectionsLogRespVO.class)); @@ -114,7 +116,7 @@ public class InspectionsLogController { if (pageResult != null && pageResult.size() > 0) { pageResult.forEach(item->{ //图片相关 - final List> fileList = fileInfoService.getFileList("644", "2", item.getId().toString()); + final List fileList = fileInfoService.getFileList(644l, 2l, item.getId().toString()); item.setFileList(fileList); }); } @@ -130,7 +132,7 @@ public class InspectionsLogController { if (list != null && list.size() > 0) { list.forEach(item->{ //图片相关 - final List> fileList = fileInfoService.getFileList("644", "2", item.getId().toString()); + final List fileList = fileInfoService.getFileList(644l, 2l, item.getId().toString()); item.setFileList(fileList); }); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/inspectionslog/vo/InspectionsLogSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/inspectionslog/vo/InspectionsLogSaveReqVO.java index c236801..6d91184 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/inspectionslog/vo/InspectionsLogSaveReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/inspectionslog/vo/InspectionsLogSaveReqVO.java @@ -42,7 +42,7 @@ public class InspectionsLogSaveReqVO { private Long inspectId; @Schema(description = "文件id", example = "26433") - private Long[] fileIds; + private List fileIds; //整改截至日期 private LocalDateTime correctionTime; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java index 318fb38..6eb0cdc 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java @@ -1,7 +1,11 @@ package cn.iocoder.yudao.module.system.controller.admin.qualification; +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; import cn.iocoder.yudao.module.system.service.enterprise.EnterpriseService; +import cn.iocoder.yudao.module.system.service.enterprise.EnterpriseServiceImpl; +import cn.iocoder.yudao.module.system.service.fileInfo.FileInfoService; +import cn.iocoder.yudao.module.system.service.qualification.EnterpriseQualificationServiceImpl; import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated; import org.springframework.security.access.prepost.PreAuthorize; @@ -42,6 +46,9 @@ public class EnterpriseQualificationController { @Resource private EnterpriseService enterpriseService; + @Resource + private FileInfoService fileInfoService; + @PostMapping("/create") @Operation(summary = "创建企业资质") @@ -73,7 +80,10 @@ public class EnterpriseQualificationController { // @PreAuthorize("@ss.hasPermission('system:enterprise-qualification:query')") public CommonResult getEnterpriseQualification(@RequestParam("id") Long id) { EnterpriseQualificationDO enterpriseQualification = enterpriseQualificationService.getEnterpriseQualification(id); - return success(BeanUtils.toBean(enterpriseQualification, EnterpriseQualificationRespVO.class)); + EnterpriseQualificationRespVO bean = BeanUtils.toBean(enterpriseQualification, EnterpriseQualificationRespVO.class); + List fileList = fileInfoService.getFileList(EnterpriseServiceImpl.DEFAULT_DICT_TYPE, EnterpriseQualificationServiceImpl.DEFAULT_DICT_DATA_QYZZ, id.toString()); + bean.setFiles(fileList); + return success(bean); } @GetMapping("/page") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationRespVO.java index 1af2b1a..7b1384f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationRespVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.controller.admin.qualification.vo; +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; @@ -59,4 +60,6 @@ public class EnterpriseQualificationRespVO { @ExcelProperty("资质编号") private String enterpriseAuth; + @Schema(description = "企业图片", example = "26433") + private List files; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationSaveReqVO.java index 726b4e8..bed396a 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationSaveReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationSaveReqVO.java @@ -39,4 +39,7 @@ public class EnterpriseQualificationSaveReqVO { @Schema(description = "资质编号") private String enterpriseAuth; + @Schema(description = "图片信息") + private List files; + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterprise/EnterpriseDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterprise/EnterpriseDO.java index bff37ab..c4c6857 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterprise/EnterpriseDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterprise/EnterpriseDO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.dal.dataobject.enterprise; +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.system.dal.dataobject.qualification.EnterpriseQualificationDO; import cn.iocoder.yudao.module.system.dal.dataobject.taglibrary.TagLibraryDO; import io.swagger.v3.oas.annotations.media.Schema; @@ -94,7 +95,7 @@ public class EnterpriseDO extends BaseDO { private String signRadius; @TableField(exist = false) - private List> files; + private List files; @TableField(exist = false) private List qualificationList; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/inspectionslog/InspectionsLogDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/inspectionslog/InspectionsLogDO.java index 42793cc..729a25c 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/inspectionslog/InspectionsLogDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/inspectionslog/InspectionsLogDO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.dal.dataobject.inspectionslog; +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.system.controller.admin.inspectionslog.vo.InspectionsLogAppListVO; import com.sun.xml.bind.v2.TODO; import lombok.*; @@ -63,5 +64,5 @@ public class InspectionsLogDO extends BaseDO { //协同人员是否可以看到任务记录 //相关文件 @TableField(exist = false) - private List> fileList; + private List fileList; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java index 6d3f713..dd72604 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.service.enterprise; +import cn.iocoder.yudao.module.infra.api.file.FileApi; import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseauditlog.EnterpriseAuditLogDO; import cn.iocoder.yudao.module.system.dal.dataobject.enterprisetag.EnterpriseTagDO; @@ -65,6 +66,11 @@ public class EnterpriseServiceImpl implements EnterpriseService { private AdminUserService adminUserService; @Resource private AdminUserMapper adminUserMapper; + //企业图片 + public final static Long DEFAULT_DICT_DATA_QY = 1L; + + public final static Long DEFAULT_DICT_TYPE = 644L; + @Override @Transactional @@ -109,8 +115,8 @@ public class EnterpriseServiceImpl implements EnterpriseService { if (createReqVO.getFileIds() != null && createReqVO.getFileIds().length > 0) { for (Long fileId : createReqVO.getFileIds()) { FileInfoDO fileInfoDO = new FileInfoDO(); - fileInfoDO.setDictData(1l); //文件类型 - fileInfoDO.setDictType(644l); + fileInfoDO.setDictData(DEFAULT_DICT_DATA_QY); + fileInfoDO.setDictType(DEFAULT_DICT_TYPE); fileInfoDO.setUnitId(enterprise.getId().toString()); fileInfoDO.setInfraFileId(fileId); fileInfoMapper.insert(fileInfoDO); @@ -138,8 +144,8 @@ public class EnterpriseServiceImpl implements EnterpriseService { if (createReqVO.getFileIds() != null && createReqVO.getFileIds().length > 0) { for (Long fileId : createReqVO.getFileIds()) { FileInfoDO fileInfoDO = new FileInfoDO(); - fileInfoDO.setDictData(1l); //文件类型 - fileInfoDO.setDictType(644l); + fileInfoDO.setDictData(DEFAULT_DICT_DATA_QY); //文件类型 + fileInfoDO.setDictType(DEFAULT_DICT_TYPE); fileInfoDO.setUnitId(enterprise.getId().toString()); fileInfoDO.setInfraFileId(fileId); fileInfoMapper.insert(fileInfoDO); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoService.java index fe778be..8527967 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoService.java @@ -1,6 +1,8 @@ package cn.iocoder.yudao.module.system.service.fileInfo; import java.util.*; + +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.system.controller.admin.fileInfo.vo.*; import cn.iocoder.yudao.module.system.dal.dataobject.fileInfo.FileInfoDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -52,7 +54,7 @@ public interface FileInfoService { */ PageResult getFileInfoPage(FileInfoPageReqVO pageReqVO); - List> getFileList(String dictType, String dictData, String unitId); + List getFileList(Long dictType, Long dictData, String unitId); /** * 根据字典类型和字典数据保存附件信息 @@ -63,6 +65,8 @@ public interface FileInfoService { * @Author dx * @Date 2025-02-16 上午9:34 **/ - void saveFilesByDictData(Long[] fileIds, Long dictType, Long dictData, String unitId); + void saveFilesByDictData(Collection fileIds, Long dictType, Long dictData, String unitId); + + void deleteFilesByDictData(Long dictType, Long dictData, String unitId); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoServiceImpl.java index 4bbbc67..594547d 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoServiceImpl.java @@ -1,10 +1,12 @@ package cn.iocoder.yudao.module.system.service.fileInfo; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.infra.api.file.FileApi; +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import org.springframework.transaction.annotation.Transactional; import java.util.*; import java.util.stream.Collectors; @@ -12,7 +14,6 @@ import java.util.stream.Collectors; import cn.iocoder.yudao.module.system.controller.admin.fileInfo.vo.*; import cn.iocoder.yudao.module.system.dal.dataobject.fileInfo.FileInfoDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.system.dal.mysql.fileInfo.FileInfoMapper; @@ -80,9 +81,9 @@ public class FileInfoServiceImpl implements FileInfoService { } @Override - public List> getFileList(String dictType, String dictData, String unitId) { + public List getFileList(Long dictType, Long dictData, String unitId) { - List> mapList = new ArrayList<>(); + List mapList = new ArrayList<>(); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(FileInfoDO::getDictType, dictType); @@ -91,7 +92,7 @@ public class FileInfoServiceImpl implements FileInfoService { final List collect = fileInfoMapper.selectList(wrapper).stream().map(res -> res.getInfraFileId()).collect(Collectors.toList()); if (!collect.isEmpty()) { - final List> list = fileApi.listFile(collect); + final List list = fileApi.listFile(collect); mapList.addAll(list); } @@ -109,8 +110,8 @@ public class FileInfoServiceImpl implements FileInfoService { * @Date 2025-02-16 上午9:34 **/ @Override - public void saveFilesByDictData(Long[] fileIds, Long dictType, Long dictData, String unitId) { - if (fileIds != null && fileIds.length > 0) { + public void saveFilesByDictData(Collection fileIds, Long dictType, Long dictData, String unitId) { + if (!CollectionUtils.isAnyEmpty(fileIds)) { List list = new ArrayList<>(); for (Long fileId : fileIds) { FileInfoDO fileInfoDO = new FileInfoDO(); @@ -124,4 +125,13 @@ public class FileInfoServiceImpl implements FileInfoService { } } + @Override + public void deleteFilesByDictData(Long dictType, Long dictData, String unitId) { + LambdaQueryWrapperX list=new LambdaQueryWrapperX(); + list.eq(FileInfoDO::getDictType,dictType); + list.eq(FileInfoDO::getDictData,dictData); + list.eq(FileInfoDO::getUnitId,unitId); + fileInfoMapper.delete(list); + } + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/qualification/EnterpriseQualificationServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/qualification/EnterpriseQualificationServiceImpl.java index e760b63..b48f28b 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/qualification/EnterpriseQualificationServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/qualification/EnterpriseQualificationServiceImpl.java @@ -1,5 +1,10 @@ package cn.iocoder.yudao.module.system.service.qualification; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.module.system.dal.dataobject.fileInfo.FileInfoDO; +import cn.iocoder.yudao.module.system.dal.mysql.fileInfo.FileInfoMapper; +import cn.iocoder.yudao.module.system.service.enterprise.EnterpriseServiceImpl; +import cn.iocoder.yudao.module.system.service.fileInfo.FileInfoService; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import org.springframework.transaction.annotation.Transactional; @@ -17,6 +22,8 @@ import javax.annotation.Resource; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.module.system.service.enterprise.EnterpriseServiceImpl.DEFAULT_DICT_DATA_QY; +import static cn.iocoder.yudao.module.system.service.enterprise.EnterpriseServiceImpl.DEFAULT_DICT_TYPE; /** @@ -30,22 +37,38 @@ public class EnterpriseQualificationServiceImpl implements EnterpriseQualificati @Resource private EnterpriseQualificationMapper enterpriseQualificationMapper; + //企业资质 + public final static Long DEFAULT_DICT_DATA_QYZZ = 3L; + + @Resource + private FileInfoService fileInfoService; @Override public Long createEnterpriseQualification(EnterpriseQualificationSaveReqVO createReqVO) { // 插入 EnterpriseQualificationDO enterpriseQualification = BeanUtils.toBean(createReqVO, EnterpriseQualificationDO.class); enterpriseQualificationMapper.insert(enterpriseQualification); + + fileInfoService.saveFilesByDictData(createReqVO.getFiles(),DEFAULT_DICT_TYPE ,DEFAULT_DICT_DATA_QYZZ, enterpriseQualification.getId().toString()); + // 返回 return enterpriseQualification.getId(); } + + + + + @Override public void updateEnterpriseQualification(EnterpriseQualificationSaveReqVO updateReqVO) { // 校验存在 validateEnterpriseQualificationExists(updateReqVO.getId()); // 更新 EnterpriseQualificationDO updateObj = BeanUtils.toBean(updateReqVO, EnterpriseQualificationDO.class); + fileInfoService.deleteFilesByDictData(DEFAULT_DICT_TYPE ,DEFAULT_DICT_DATA_QYZZ, updateObj.getId().toString()); + + fileInfoService.saveFilesByDictData(updateReqVO.getFiles(), DEFAULT_DICT_TYPE ,DEFAULT_DICT_DATA_QYZZ, updateObj.getId().toString()); enterpriseQualificationMapper.updateById(updateObj); } @@ -53,6 +76,8 @@ public class EnterpriseQualificationServiceImpl implements EnterpriseQualificati public void deleteEnterpriseQualification(Long id) { // 校验存在 validateEnterpriseQualificationExists(id); + fileInfoService.deleteFilesByDictData(DEFAULT_DICT_TYPE ,DEFAULT_DICT_DATA_QYZZ, id.toString()); + // 删除 enterpriseQualificationMapper.deleteById(id); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java index d520824..1da2c0b 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java @@ -305,7 +305,7 @@ public class SocialClientServiceImpl implements SocialClientService { ObjUtil.defaultIfNull(reqVO.getCheckPath(), SocialWxQrcodeReqDTO.CHECK_PATH), envVersion, ObjUtil.defaultIfNull(reqVO.getWidth(), SocialWxQrcodeReqDTO.WIDTH), - ObjUtil.defaultIfNull(reqVO.getAutoColor(), SocialWxQrcodeReqDTO.AUTO_COLOR), + ObjUtil.defaultIfNull(reqVO.getAutoColor(), false), null, ObjUtil.defaultIfNull(reqVO.getHyaline(), SocialWxQrcodeReqDTO.HYALINE)); } catch (WxErrorException e) { diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java index 1240257..7bf0687 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java @@ -13,6 +13,7 @@ import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; import cn.iocoder.yudao.framework.datapermission.core.util.DataPermissionUtils; import cn.iocoder.yudao.module.infra.api.config.ConfigApi; import cn.iocoder.yudao.module.infra.api.file.FileApi; +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO; import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthRegisterReqVO; import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO; @@ -224,13 +225,13 @@ public class AdminUserServiceImpl implements AdminUserService { public String updateUserAvatar(Long id, InputStream avatarFile) { validateUserExists(id); // 存储文件 - final Map file = fileApi.createFile(IoUtil.readBytes(avatarFile)); + final InfraFileInfoDTO file = fileApi.createFile(IoUtil.readBytes(avatarFile)); // 更新路径 AdminUserDO sysUserDO = new AdminUserDO(); sysUserDO.setId(id); - sysUserDO.setAvatar(file.get("url")); + sysUserDO.setAvatar(file.getUrl()); userMapper.updateById(sysUserDO); - return file.get("url"); + return file.getUrl(); } @Override From 8481200198c52c4860f87aa0fd4ffd64ecc9e5d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E9=B9=8F?= Date: Sun, 23 Feb 2025 17:07:51 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E8=B5=84=E8=B4=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EnterpriseQualificationController.java | 30 ++++++++++++++- .../service/fileInfo/FileInfoService.java | 2 + .../service/fileInfo/FileInfoServiceImpl.java | 37 +++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java index 6eb0cdc..851f51a 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java @@ -1,11 +1,13 @@ package cn.iocoder.yudao.module.system.controller.admin.qualification; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; import cn.iocoder.yudao.module.system.service.enterprise.EnterpriseService; import cn.iocoder.yudao.module.system.service.enterprise.EnterpriseServiceImpl; import cn.iocoder.yudao.module.system.service.fileInfo.FileInfoService; import cn.iocoder.yudao.module.system.service.qualification.EnterpriseQualificationServiceImpl; +import io.reactivex.rxjava3.core.Single; import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated; import org.springframework.security.access.prepost.PreAuthorize; @@ -15,6 +17,7 @@ import io.swagger.v3.oas.annotations.Operation; import java.util.*; import java.io.IOException; +import java.util.stream.Collectors; import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -81,7 +84,7 @@ public class EnterpriseQualificationController { public CommonResult getEnterpriseQualification(@RequestParam("id") Long id) { EnterpriseQualificationDO enterpriseQualification = enterpriseQualificationService.getEnterpriseQualification(id); EnterpriseQualificationRespVO bean = BeanUtils.toBean(enterpriseQualification, EnterpriseQualificationRespVO.class); - List fileList = fileInfoService.getFileList(EnterpriseServiceImpl.DEFAULT_DICT_TYPE, EnterpriseQualificationServiceImpl.DEFAULT_DICT_DATA_QYZZ, id.toString()); + List fileList = fileInfoService.getFileList(EnterpriseServiceImpl.DEFAULT_DICT_TYPE, EnterpriseQualificationServiceImpl.DEFAULT_DICT_DATA_QYZZ, bean.getId().toString()); bean.setFiles(fileList); return success(bean); } @@ -94,9 +97,32 @@ public class EnterpriseQualificationController { pageResult.getList().forEach(item->{ item.setEnterpriseName(enterpriseService.getEnterprise(Long.valueOf(item.getEnterpriseId())).getEnterprisesName()); }); - return success(BeanUtils.toBean(pageResult, EnterpriseQualificationRespVO.class)); + PageResult bean = BeanUtils.toBean(pageResult, EnterpriseQualificationRespVO.class); + + return success(bean); } + + @GetMapping("/pageEnterprise") + @Operation(summary = "获得企业资质分页") +// @PreAuthorize("@ss.hasPermission('system:enterprise-qualification:query')") + public CommonResult> getEnterpriseQualificationEnterprisePage(EnterpriseQualificationPageReqVO pageReqVO) { + PageResult pageResult = enterpriseQualificationService.getEnterpriseQualificationPage(pageReqVO); + pageResult.getList().forEach(item -> { + item.setEnterpriseName(enterpriseService.getEnterprise(Long.valueOf(item.getEnterpriseId())).getEnterprisesName()); + }); + PageResult bean = BeanUtils.toBean(pageResult, EnterpriseQualificationRespVO.class); + List list = bean.getList(); + Map> longListMap = CollectionUtils.convertMultiMap(list, EnterpriseQualificationRespVO::getId); + List collect = longListMap.keySet().stream().map(x -> x.toString()).collect(Collectors.toList()); + Map> fileListMap = fileInfoService.getFileListMap(EnterpriseServiceImpl.DEFAULT_DICT_TYPE, EnterpriseQualificationServiceImpl.DEFAULT_DICT_DATA_QYZZ, collect); + + for (EnterpriseQualificationRespVO item : list) { + item.setFiles(fileListMap.get(item.getId().toString())); + } + + return success(bean); + } @GetMapping("/export-excel") @Operation(summary = "导出企业资质 Excel") @PreAuthorize("@ss.hasPermission('system:enterprise-qualification:export')") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoService.java index 8527967..6c3332c 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoService.java @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.system.controller.admin.fileInfo.vo.*; import cn.iocoder.yudao.module.system.dal.dataobject.fileInfo.FileInfoDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import org.apache.poi.ss.formula.functions.T; import javax.validation.Valid; @@ -55,6 +56,7 @@ public interface FileInfoService { PageResult getFileInfoPage(FileInfoPageReqVO pageReqVO); List getFileList(Long dictType, Long dictData, String unitId); + Map> getFileListMap(Long dictType, Long dictData, Collection unitId); /** * 根据字典类型和字典数据保存附件信息 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoServiceImpl.java index 594547d..6ac0fca 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoServiceImpl.java @@ -99,6 +99,43 @@ public class FileInfoServiceImpl implements FileInfoService { return mapList; } + @Override + public Map> getFileListMap(Long dictType, Long dictData, Collection unitId) { + + Map> result =new HashMap<>(); + LambdaQueryWrapperX wrapper = new LambdaQueryWrapperX(); + wrapper.eqIfPresent(FileInfoDO::getDictType, dictType); + wrapper.eqIfPresent(FileInfoDO::getDictData, dictData); + wrapper.inIfPresent(FileInfoDO::getUnitId, unitId); + List fileInfoDOS = fileInfoMapper.selectList(wrapper); + if(fileInfoDOS.isEmpty()){ + return result; + } + Map> stringListMap = CollectionUtils.convertMultiMap(fileInfoDOS, FileInfoDO::getUnitId,FileInfoDO::getInfraFileId); + List longs = CollectionUtils.convertList(fileInfoDOS, FileInfoDO::getInfraFileId); + + if (!longs.isEmpty()) { + List infraFileInfoDTOS = fileApi.listFile(longs); + + Map longInfraFileInfoDTOMap = CollectionUtils.convertMap(infraFileInfoDTOS, InfraFileInfoDTO::getId); + + for (Map.Entry> entry : stringListMap.entrySet()) { + List list = new ArrayList<>(); + for (Long aLong : entry.getValue()) { + InfraFileInfoDTO infraFileInfoDTO = longInfraFileInfoDTOMap.get(aLong); + if (infraFileInfoDTO != null) { + list.add(infraFileInfoDTO); + } + } + result.put(entry.getKey(),list); + } + + return result; + } + + return result; + } + /** * 根据字典类型和字典数据保存附件信息 *