From 1963b6df29889163479bd8701e0745ad14f8d1ec Mon Sep 17 00:00:00 2001 From: Lqc Date: Tue, 23 Sep 2025 11:32:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=AB=A0=E8=8A=82=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E7=BB=83=E4=B9=A0=E8=AF=A6=E6=83=85=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/aiol/controller/AiolExamController.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/controller/AiolExamController.java b/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/controller/AiolExamController.java index 0b18baaa..0bc01687 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/controller/AiolExamController.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/controller/AiolExamController.java @@ -334,16 +334,7 @@ public class AiolExamController extends JeecgController examIds = list.stream().map(AiolEntityLink::getTargetId).collect(Collectors.toList()); - List exams = examService.listByIds(examIds); - List paperIds = exams.stream().map(AiolExam::getPaperId).collect(Collectors.toList()); - ArrayList objects = new ArrayList<>(); - for (String paperId : paperIds) { - Result result = paperQuestionController.paperDetail(paperId); - if (result.getCode() == 200) { - objects.add(result.getResult()); - } - } - return Result.OK(objects); + return Result.OK(examService.listByIds(examIds)); } @PostMapping("/submitExam") From af808a80b7bbbea611ddc43ab5a79b7a62e86aba Mon Sep 17 00:00:00 2001 From: Lqc Date: Tue, 23 Sep 2025 11:49:07 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=A2=98=E7=9B=AE=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E4=BA=BA=E7=94=A8=E6=88=B7=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aiol/controller/AiolRepoController.java | 79 ++++++++++++++----- .../modules/aiol/dto/QuestionWithCreator.java | 15 ++++ 2 files changed, 73 insertions(+), 21 deletions(-) create mode 100644 jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/dto/QuestionWithCreator.java diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/controller/AiolRepoController.java b/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/controller/AiolRepoController.java index 52ed7576..a182476e 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/controller/AiolRepoController.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/controller/AiolRepoController.java @@ -1,12 +1,8 @@ package org.jeecg.modules.aiol.controller; -import java.io.ObjectOutputStream; import java.net.URLEncoder; import java.util.*; 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.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.IdWorker; import com.baomidou.mybatisplus.core.toolkit.StringUtils; -import com.jeecg.qywx.api.user.vo.User; import org.apache.poi.ss.usermodel.Workbook; import org.jeecg.common.api.vo.Result; import org.jeecg.common.constant.CommonConstant; import org.jeecg.common.system.api.ISysBaseAPI; 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.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.dto.CourseWithTeacherInfo; -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.dto.*; import org.jeecg.modules.aiol.entity.*; import org.jeecg.modules.aiol.mapper.AiolRepoMapper; 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.jeecgframework.poi.excel.ExcelExportUtil; 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.ImportParams; -import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.jeecg.common.system.base.controller.JeecgController; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.multipart.MultipartHttpServletRequest; 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.Operation; import org.jeecg.common.aspect.annotation.AutoLog; @@ -418,7 +404,7 @@ public class AiolRepoController extends JeecgController> questionList(@PathVariable String repoId) { + public Result> questionList(@PathVariable String repoId) { // 获取题库中的题目ID列表 List repoQuestionIds = questionRepoService.questionList(repoId); if (repoQuestionIds.isEmpty()) { @@ -429,6 +415,27 @@ public class AiolRepoController extends JeecgController createIds = questions.stream() + .map(AiolQuestion::getCreateBy) + .collect(Collectors.toSet()) + .stream() + .collect(Collectors.toList()); + // 根据ID列表查询用户信息 + Map createIdToUsernameMap = new HashMap<>(); + if (!createIds.isEmpty()) { + List users = sysUserService.list( + new LambdaQueryWrapper() + .in(SysUser::getUsername, createIds) + ); + // 创建ID到用户名的映射 + createIdToUsernameMap = users.stream() + .collect(Collectors.toMap( + SysUser::getUsername, + SysUser::getRealname, + (existing, replacement) -> existing + )); + } //获取复选题id List type5Ids = questions.stream() .filter(question -> question.getType() == 5) @@ -446,15 +453,45 @@ public class AiolRepoController extends JeecgController> parentToChildrenMap = type5Questions.stream() .collect(Collectors.groupingBy(AiolQuestion::getParentId)); - // 将子题目添加到原始列表中,保持原有顺序 - List resultQuestions = new ArrayList<>(); + + + // 构建结果列表 + List resultQuestions = new ArrayList<>(); 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) { List 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); } diff --git a/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/dto/QuestionWithCreator.java b/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/dto/QuestionWithCreator.java new file mode 100644 index 00000000..e1f53977 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module/jeecg-module-aiol/src/main/java/org/jeecg/modules/aiol/dto/QuestionWithCreator.java @@ -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; + } +} \ No newline at end of file