|
|
@@ -20,6 +20,7 @@ import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -68,18 +69,25 @@ public class RecordController {
|
|
|
List<String> ids = recordPage.getContent().stream()
|
|
|
.map(Record::getQuestionId)
|
|
|
.collect(Collectors.toList());
|
|
|
- final List<QuestionVO> questionVOS = questionService.findAllByIdIn(ids).stream()
|
|
|
- .map(QuestionVO::of)
|
|
|
- .collect(Collectors.toList());
|
|
|
- final List<RecordVO> recordVOS=recordPage.getContent().stream()
|
|
|
- .map(RecordVO::fromEntity)
|
|
|
- .collect(Collectors.toList());
|
|
|
final PageVO page=PageVO.builder()
|
|
|
.size(recordPage.getSize())
|
|
|
.totalPages(recordPage.getTotalPages())
|
|
|
.totalElements(recordPage.getTotalElements())
|
|
|
.number(recordPage.getNumber())
|
|
|
.build();
|
|
|
+ if(ids.size()==0){
|
|
|
+ body.put("page",page);
|
|
|
+ body.put("questions",new ArrayList<>(0));
|
|
|
+ body.put("records",new ArrayList<>(0));
|
|
|
+ return body;
|
|
|
+ }
|
|
|
+ final List<QuestionVO> questionVOS = questionService.findAllByIdIn(ids).stream()
|
|
|
+ .map(QuestionVO::of)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ final List<RecordVO> recordVOS=recordPage.getContent().stream()
|
|
|
+ .map(RecordVO::fromEntity)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
body.put("page",page);
|
|
|
body.put("questions",questionVOS);
|
|
|
body.put("records",recordVOS);
|