|
|
@@ -81,7 +81,7 @@ public class CourseQuestionAnswerController {
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
@ApiOperation("获取课程问答分页")
|
|
|
@GetMapping("/disk/answer/page")
|
|
|
- public CommonResult<Page<Map<String,Object>>> page(QuestionAnswerPageParam questionAnswerPageParam, HttpServletRequest req) {
|
|
|
+ public CommonResult<Page<QuestionAnswerVo>> page(QuestionAnswerPageParam questionAnswerPageParam, HttpServletRequest req) {
|
|
|
Map param =new HashMap();
|
|
|
param.put("courseId", req.getParameter("courseId"));
|
|
|
param.put("hourId", req.getParameter("hourId"));
|
|
|
@@ -93,38 +93,38 @@ public class CourseQuestionAnswerController {
|
|
|
if(StringUtils.isNotEmpty(req.getParameter("eduIdentity")))eduIdentity=req.getParameter("eduIdentity");
|
|
|
param.put("eduIdentity", eduIdentity);
|
|
|
//查询一级评论问题
|
|
|
- Page<Map<String,Object>> page=questionAnswerService.queryList(param);
|
|
|
- List<Map<String,Object>> recordList=page.getRecords();
|
|
|
- List<String> recordIdList= recordList.stream().map(map -> (String) map.get("id")).collect(Collectors.toList());
|
|
|
+ Page<QuestionAnswerVo> page=questionAnswerService.queryList(param);
|
|
|
+ List<QuestionAnswerVo> recordList=page.getRecords();
|
|
|
+ List<String> recordIdList= recordList.stream().map(map -> (String) map.getId()).collect(Collectors.toList());
|
|
|
|
|
|
param.clear();
|
|
|
param.put("isPid", "0");
|
|
|
param.put("pidList", recordIdList);
|
|
|
//查询二级评论问题
|
|
|
- List<Map<String,Object>> recordTwoList=questionAnswerService.queryMapList(param);
|
|
|
+ List<QuestionAnswerVo> recordTwoList=questionAnswerService.queryMapList(param);
|
|
|
// 1. 准备结果:为每个章节添加classHours字段
|
|
|
- for (Map<String, Object> record : recordList) {
|
|
|
+ for (QuestionAnswerVo record : recordList) {
|
|
|
//预留是否有子集字段,0否1是
|
|
|
String haveAnswer="0";
|
|
|
- if (record == null || record.get("id") == null) continue;
|
|
|
+ if (record == null || record.getId() == null) continue;
|
|
|
|
|
|
- String recordId = record.get("id").toString();
|
|
|
- List<Map<String, Object>> recordChildList = new ArrayList<>();
|
|
|
+ String recordId = record.getId().toString();
|
|
|
+ List<QuestionAnswerVo> recordChildList = new ArrayList<>();
|
|
|
|
|
|
// 2. 倒序遍历课程列表(关键点!)
|
|
|
for (int i = recordTwoList.size() - 1; i >= 0; i--) {
|
|
|
- Map<String, Object> recordTwo = recordTwoList.get(i);
|
|
|
- if (recordTwo == null || recordTwo.get("pid") == null) continue;
|
|
|
+ QuestionAnswerVo recordTwo = recordTwoList.get(i);
|
|
|
+ if (recordTwo == null || recordTwo.getPid() == null) continue;
|
|
|
|
|
|
// 3. 匹配当前章节
|
|
|
- if (recordId.equals(recordTwo.get("pid").toString())) {
|
|
|
+ if (recordId.equals(recordTwo.getPid().toString())) {
|
|
|
recordChildList.add(recordTwo); // 添加到章节
|
|
|
recordTwoList.remove(i); // 从原列表删除(安全操作)
|
|
|
}
|
|
|
}
|
|
|
if(recordChildList.size()>0)haveAnswer="1";
|
|
|
- record.put("haveAnswer", haveAnswer);
|
|
|
- record.put("recordChildList", recordChildList);
|
|
|
+ record.setHaveAnswer(haveAnswer);
|
|
|
+ record.setRecordChildList(recordChildList);
|
|
|
}
|
|
|
|
|
|
return CommonResult.data(page);
|
|
|
@@ -216,7 +216,7 @@ public class CourseQuestionAnswerController {
|
|
|
Map param =new HashMap();
|
|
|
param.put("id", req.getParameter("id"));
|
|
|
Map<String,Object> result=new HashMap<>();
|
|
|
- Map<String,Object> studentAnswer=questionAnswerService.queryInfo(param);
|
|
|
+ QuestionAnswerVo studentAnswer=questionAnswerService.queryInfo(param);
|
|
|
param.clear();
|
|
|
param.put("isPid", "0");
|
|
|
param.put("pid", req.getParameter("id"));
|
|
|
@@ -230,8 +230,8 @@ public class CourseQuestionAnswerController {
|
|
|
param.clear();
|
|
|
param.put("isPid", "0");
|
|
|
param.put("pid", req.getParameter("id"));
|
|
|
- List<Map<String, Object>> recordList = new ArrayList<>();
|
|
|
- List<Map<String,Object>> recordTwoList=questionAnswerService.queryMapList(param);
|
|
|
+ List<QuestionAnswerVo> recordList = new ArrayList<>();
|
|
|
+ List<QuestionAnswerVo> recordTwoList=questionAnswerService.queryMapList(param);
|
|
|
recordList.add(studentAnswer);
|
|
|
recordList.addAll(recordTwoList);
|
|
|
result.put("recordList", recordList);
|