Merge branch 'dev2' of http://110.42.96.64:19890/GoCo/OL-LearnPlatform-Backend into dev2
merge
This commit is contained in:
commit
10c03265d8
@ -334,16 +334,7 @@ public class AiolExamController extends JeecgController<AiolExam, IAiolExamServi
|
|||||||
return Result.error("该章节没有绑定练习");
|
return Result.error("该章节没有绑定练习");
|
||||||
}
|
}
|
||||||
List<String> examIds = list.stream().map(AiolEntityLink::getTargetId).collect(Collectors.toList());
|
List<String> examIds = list.stream().map(AiolEntityLink::getTargetId).collect(Collectors.toList());
|
||||||
List<AiolExam> exams = examService.listByIds(examIds);
|
return Result.OK(examService.listByIds(examIds));
|
||||||
List<String> paperIds = exams.stream().map(AiolExam::getPaperId).collect(Collectors.toList());
|
|
||||||
ArrayList<Object> objects = new ArrayList<>();
|
|
||||||
for (String paperId : paperIds) {
|
|
||||||
Result<?> result = paperQuestionController.paperDetail(paperId);
|
|
||||||
if (result.getCode() == 200) {
|
|
||||||
objects.add(result.getResult());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Result.OK(objects);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/submitExam")
|
@PostMapping("/submitExam")
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
package org.jeecg.modules.aiol.controller;
|
package org.jeecg.modules.aiol.controller;
|
||||||
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLDecoder;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
@ -14,22 +10,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
import com.jeecg.qywx.api.user.vo.User;
|
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.constant.CommonConstant;
|
import org.jeecg.common.constant.CommonConstant;
|
||||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||||
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
import org.jeecg.common.system.query.QueryRuleEnum;
|
|
||||||
import org.jeecg.common.system.util.JwtUtil;
|
import org.jeecg.common.system.util.JwtUtil;
|
||||||
import org.jeecg.common.system.vo.LoginUser;
|
import org.jeecg.common.system.vo.LoginUser;
|
||||||
import org.jeecg.common.util.UUIDGenerator;
|
|
||||||
import org.jeecg.common.util.oConvertUtils;
|
|
||||||
import org.jeecg.modules.aiol.constant.EntityLinkConst;
|
import org.jeecg.modules.aiol.constant.EntityLinkConst;
|
||||||
import org.jeecg.modules.aiol.dto.CourseWithTeacherInfo;
|
import org.jeecg.modules.aiol.dto.*;
|
||||||
import org.jeecg.modules.aiol.dto.QuestionAnswerDTO;
|
|
||||||
import org.jeecg.modules.aiol.dto.QuestionExcelDTO;
|
|
||||||
import org.jeecg.modules.aiol.dto.UserPermission;
|
|
||||||
import org.jeecg.modules.aiol.entity.*;
|
import org.jeecg.modules.aiol.entity.*;
|
||||||
import org.jeecg.modules.aiol.mapper.AiolRepoMapper;
|
import org.jeecg.modules.aiol.mapper.AiolRepoMapper;
|
||||||
import org.jeecg.modules.aiol.service.*;
|
import org.jeecg.modules.aiol.service.*;
|
||||||
@ -43,18 +32,15 @@ import org.jeecg.modules.system.entity.SysUser;
|
|||||||
import org.jeecg.modules.system.service.ISysUserService;
|
import org.jeecg.modules.system.service.ISysUserService;
|
||||||
import org.jeecgframework.poi.excel.ExcelExportUtil;
|
import org.jeecgframework.poi.excel.ExcelExportUtil;
|
||||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
||||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
@ -418,7 +404,7 @@ public class AiolRepoController extends JeecgController<AiolRepo, IAiolRepoServi
|
|||||||
|
|
||||||
@GetMapping("/questionList/{repoId}")
|
@GetMapping("/questionList/{repoId}")
|
||||||
@Operation(summary = "查询题库下题目")
|
@Operation(summary = "查询题库下题目")
|
||||||
public Result<List<AiolQuestion>> questionList(@PathVariable String repoId) {
|
public Result<List<QuestionWithCreator>> questionList(@PathVariable String repoId) {
|
||||||
// 获取题库中的题目ID列表
|
// 获取题库中的题目ID列表
|
||||||
List<String> repoQuestionIds = questionRepoService.questionList(repoId);
|
List<String> repoQuestionIds = questionRepoService.questionList(repoId);
|
||||||
if (repoQuestionIds.isEmpty()) {
|
if (repoQuestionIds.isEmpty()) {
|
||||||
@ -429,6 +415,27 @@ public class AiolRepoController extends JeecgController<AiolRepo, IAiolRepoServi
|
|||||||
if (questions.isEmpty()) {
|
if (questions.isEmpty()) {
|
||||||
return Result.error("题目不存在");
|
return Result.error("题目不存在");
|
||||||
}
|
}
|
||||||
|
//获取所有创建人id
|
||||||
|
List<String> createIds = questions.stream()
|
||||||
|
.map(AiolQuestion::getCreateBy)
|
||||||
|
.collect(Collectors.toSet())
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 根据ID列表查询用户信息
|
||||||
|
Map<String, String> createIdToUsernameMap = new HashMap<>();
|
||||||
|
if (!createIds.isEmpty()) {
|
||||||
|
List<SysUser> users = sysUserService.list(
|
||||||
|
new LambdaQueryWrapper<SysUser>()
|
||||||
|
.in(SysUser::getUsername, createIds)
|
||||||
|
);
|
||||||
|
// 创建ID到用户名的映射
|
||||||
|
createIdToUsernameMap = users.stream()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
SysUser::getUsername,
|
||||||
|
SysUser::getRealname,
|
||||||
|
(existing, replacement) -> existing
|
||||||
|
));
|
||||||
|
}
|
||||||
//获取复选题id
|
//获取复选题id
|
||||||
List<String> type5Ids = questions.stream()
|
List<String> type5Ids = questions.stream()
|
||||||
.filter(question -> question.getType() == 5)
|
.filter(question -> question.getType() == 5)
|
||||||
@ -446,15 +453,45 @@ public class AiolRepoController extends JeecgController<AiolRepo, IAiolRepoServi
|
|||||||
Map<String, List<AiolQuestion>> parentToChildrenMap = type5Questions.stream()
|
Map<String, List<AiolQuestion>> parentToChildrenMap = type5Questions.stream()
|
||||||
.collect(Collectors.groupingBy(AiolQuestion::getParentId));
|
.collect(Collectors.groupingBy(AiolQuestion::getParentId));
|
||||||
|
|
||||||
// 将子题目添加到原始列表中,保持原有顺序
|
|
||||||
List<AiolQuestion> resultQuestions = new ArrayList<>();
|
|
||||||
|
// 构建结果列表
|
||||||
|
List<QuestionWithCreator> resultQuestions = new ArrayList<>();
|
||||||
for (AiolQuestion question : questions) {
|
for (AiolQuestion question : questions) {
|
||||||
resultQuestions.add(question);
|
// 创建扩展对象
|
||||||
|
QuestionWithCreator questionWithCreator = new QuestionWithCreator();
|
||||||
|
BeanUtils.copyProperties(question, questionWithCreator);
|
||||||
|
|
||||||
|
// 设置创建人用户名
|
||||||
|
String createBy = question.getCreateBy();
|
||||||
|
if (StringUtils.isNotBlank(createBy)) {
|
||||||
|
questionWithCreator.setCreateByName(createIdToUsernameMap.getOrDefault(createBy, ""));
|
||||||
|
} else {
|
||||||
|
questionWithCreator.setCreateByName("");
|
||||||
|
}
|
||||||
|
|
||||||
|
resultQuestions.add(questionWithCreator);
|
||||||
|
|
||||||
if (question.getType() == 5) {
|
if (question.getType() == 5) {
|
||||||
List<AiolQuestion> children = parentToChildrenMap.getOrDefault(question.getId(), Collections.emptyList());
|
List<AiolQuestion> children = parentToChildrenMap.getOrDefault(question.getId(), Collections.emptyList());
|
||||||
resultQuestions.addAll(children);
|
for (AiolQuestion child : children) {
|
||||||
|
// 创建子题目的扩展对象
|
||||||
|
QuestionWithCreator childWithCreator = new QuestionWithCreator();
|
||||||
|
BeanUtils.copyProperties(child, childWithCreator);
|
||||||
|
|
||||||
|
// 设置子题目的创建人用户名
|
||||||
|
String childCreateBy = child.getCreateBy();
|
||||||
|
if (StringUtils.isNotBlank(childCreateBy)) {
|
||||||
|
childWithCreator.setCreateByName(createIdToUsernameMap.getOrDefault(childCreateBy, ""));
|
||||||
|
} else {
|
||||||
|
childWithCreator.setCreateByName("");
|
||||||
|
}
|
||||||
|
|
||||||
|
resultQuestions.add(childWithCreator);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.ok(resultQuestions);
|
return Result.ok(resultQuestions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package org.jeecg.modules.aiol.dto;
|
||||||
|
|
||||||
|
import org.jeecg.modules.aiol.entity.AiolQuestion;
|
||||||
|
|
||||||
|
public class QuestionWithCreator extends AiolQuestion {
|
||||||
|
private String createByName;
|
||||||
|
|
||||||
|
public String getCreateByName() {
|
||||||
|
return createByName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateByName(String createByName) {
|
||||||
|
this.createByName = createByName;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user