Procházet zdrojové kódy

试验-规范管理-规范文件管理-文件管理查询

LHB před 2 měsíci
rodič
revize
c6d6780bad

+ 8 - 3
blade-service/blade-business/src/main/java/org/springblade/business/controller/PrivateStandardController.java

@@ -3,6 +3,7 @@ package org.springblade.business.controller;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.annotations.Api;
@@ -19,6 +20,7 @@ import org.springblade.core.secure.BladeUser;
 import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.core.tool.utils.CollectionUtil;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -59,12 +61,15 @@ public class PrivateStandardController {
             Page page = new Page(query.getCurrent(), query.getSize());
             IPage<PrivateStandardDTO> resultPage = this.privateStandardService.page(page, new QueryWrapper<>(privateStandard));
             if(privateStandard.getType() != null && privateStandard.getType() == 2){
-                for (PrivateStandardDTO record : resultPage.getRecords()) {
+                List<PrivateStandardDTO> privateStandardDTOS = BeanUtil.copyProperties(resultPage.getRecords(), PrivateStandardDTO.class);
+                for (PrivateStandardDTO record : privateStandardDTOS) {
                     List<StandardFile> list = standardFileService.list(Wrappers.<StandardFile>lambdaQuery()
                             .eq(StandardFile::getStandardId, record.getId())
-                            .eq(StandardFile::getIsDeleted, 0));
-                    record.setStandardFiles(list);
+                            .eq(StandardFile::getIsDeleted, 0)
+                            .last("limit 1"));
+                    record.setStandardFile(CollectionUtils.isNotEmpty(list) ? list.get(0) : null);
                 }
+                resultPage.setRecords(privateStandardDTOS);
             }
             return R.data(resultPage);
         } catch (Exception e) {