From 4afe249ce4b695ef196dc104aa65fdc3d95cc30a Mon Sep 17 00:00:00 2001 From: wangxy <1356089412@qq.com> Date: Fri, 5 Jul 2024 14:27:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/exam/PaperController.java | 11 +++++++++++ .../web/controller/manager/PaperManager.java | 17 +++++++++++++++++ .../ruoyi/system/mapper/ElPaperQuMapper.java | 7 +++++++ .../ruoyi/system/service/ElPaperQuService.java | 15 +++++++++++++++ .../service/impl/ElPaperQuServiceImpl.java | 7 +++++++ .../resources/mapper/system/ElPaperQuMapper.xml | 7 +++++++ 6 files changed, 64 insertions(+) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/exam/PaperController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/exam/PaperController.java index 896244a..bf05fe4 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/exam/PaperController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/exam/PaperController.java @@ -101,6 +101,17 @@ public class PaperController extends BaseController { } + @ApiOperation("详情") + @GetMapping("/paperResult/{paperId}") + @ResponseBody + public AjaxResult paperResult(@PathVariable("paperId") String paperId) { + return AjaxResult.success(paperManager.paperResult(paperId)); + } + + + + + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/manager/PaperManager.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/manager/PaperManager.java index 5b12040..f998490 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/manager/PaperManager.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/manager/PaperManager.java @@ -21,6 +21,7 @@ import com.ruoyi.system.domain.paper.dto.ext.PaperQuDetailDTO; import com.ruoyi.system.domain.paper.dto.request.PaperAnswerDTO; import com.ruoyi.system.domain.paper.dto.request.PaperListReqDTO; import com.ruoyi.system.domain.paper.dto.response.ExamDetailRespDTO; +import com.ruoyi.system.domain.paper.dto.response.ExamResultRespDTO; import com.ruoyi.system.domain.paper.dto.response.PaperListRespDTO; import com.ruoyi.system.domain.paper.enums.PaperState; import com.ruoyi.system.domain.qu.ElQu; @@ -326,6 +327,9 @@ public class PaperManager { public ExamDetailRespDTO paperDetail(String paperId) { // 试题基本信息 ElPaper paper = paperService.getById(paperId); + if(Objects.isNull(paper)){ + throw new ServiceException("试题基本信息为空"); + } ExamDetailRespDTO respDTO = Convert.convert(ExamDetailRespDTO.class, paper); //查询条件 QueryWrapper wrapper = new QueryWrapper<>(); @@ -365,6 +369,9 @@ public class PaperManager { public PaperQuDetailDTO findQuDetail(String paperId, String quId) { // 问题 ElQu qu = quService.getById(quId); + if(Objects.isNull(qu)){ + throw new ServiceException("问题信息为空"); + } // 基本信息 QueryWrapper wrapper = new QueryWrapper<>(); wrapper.lambda().eq(ElPaperQu::getPaperId, paperId) @@ -478,5 +485,15 @@ public class PaperManager { } + public ExamResultRespDTO paperResult(String paperId) { + // 试题基本信息 + ElPaper paper = paperService.getById(paperId); + ExamResultRespDTO respDTO = Convert.convert(ExamResultRespDTO.class, paper); + List quList = paperQuService.listForPaperResult(paperId); + respDTO.setQuList(quList); + return respDTO; + } + + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ElPaperQuMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ElPaperQuMapper.java index 7851c89..216b1a6 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ElPaperQuMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/ElPaperQuMapper.java @@ -2,8 +2,11 @@ package com.ruoyi.system.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.system.domain.paper.ElPaperQu; +import com.ruoyi.system.domain.paper.dto.ext.PaperQuDetailDTO; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * @author 13560 * @description 针对表【el_paper_qu(考试记录考题)】的数据库操作Mapper @@ -21,6 +24,10 @@ public interface ElPaperQuMapper extends BaseMapper { */ int sumObjective(String paperId); + + + List listForPaperResult(String paperId); + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ElPaperQuService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ElPaperQuService.java index c8caabb..73ddf23 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ElPaperQuService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ElPaperQuService.java @@ -2,6 +2,9 @@ package com.ruoyi.system.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.system.domain.paper.ElPaperQu; +import com.ruoyi.system.domain.paper.dto.ext.PaperQuDetailDTO; + +import java.util.List; /** * @author 13560 @@ -18,4 +21,16 @@ public interface ElPaperQuService extends IService { int sumObjective(String paperId); + + /** + * 找出全部试题列表 + * @param paperId + * @return + */ + List listForPaperResult(String paperId); + + + + + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ElPaperQuServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ElPaperQuServiceImpl.java index d2df82a..a2863a6 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ElPaperQuServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ElPaperQuServiceImpl.java @@ -2,11 +2,13 @@ package com.ruoyi.system.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.system.domain.paper.ElPaperQu; +import com.ruoyi.system.domain.paper.dto.ext.PaperQuDetailDTO; import com.ruoyi.system.mapper.ElPaperQuMapper; import com.ruoyi.system.service.ElPaperQuService; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.List; /** * @author 13560 @@ -24,6 +26,11 @@ public class ElPaperQuServiceImpl extends ServiceImpl listForPaperResult(String paperId) { + return paperQuMapper.listForPaperResult(paperId); + } } diff --git a/ruoyi-system/src/main/resources/mapper/system/ElPaperQuMapper.xml b/ruoyi-system/src/main/resources/mapper/system/ElPaperQuMapper.xml index 9e9bbfe..76cb9fe 100644 --- a/ruoyi-system/src/main/resources/mapper/system/ElPaperQuMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/ElPaperQuMapper.xml @@ -33,4 +33,11 @@ AND is_right=true AND qu_type < 4 +