龚焕茏
2024-05-17 6d05f0dc6e96ead24bb7e035e16f18031b1ede78
feat:看题新增查询条件
9个文件已修改
93 ■■■■ 已修改文件
src/main/java/com/mindskip/xzs/controller/student/QuestionAnswerController.java 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/repository/ExamPaperQuestionCustomerAnswerMapper.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/service/ExamPaperQuestionCustomerAnswerService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/service/impl/ExamPaperQuestionCustomerAnswerServiceImpl.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/viewmodel/student/question/answer/QuestionPageStudentRequestVM.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/ExamPaperQuestionCustomerAnswerMapper.xml 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/QuestionMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mindskip/xzs/controller/student/QuestionAnswerController.java
@@ -1,27 +1,17 @@
package com.mindskip.xzs.controller.student;
import com.github.pagehelper.PageInfo;
import com.mindskip.xzs.base.BaseApiController;
import com.mindskip.xzs.base.RestResponse;
import com.mindskip.xzs.domain.*;
import com.mindskip.xzs.domain.question.QuestionObject;
import com.mindskip.xzs.domain.ExamPaperQuestionCustomerAnswer;
import com.mindskip.xzs.service.*;
import com.mindskip.xzs.utility.DateTimeUtil;
import com.mindskip.xzs.utility.HtmlUtil;
import com.mindskip.xzs.utility.JsonUtil;
import com.mindskip.xzs.utility.PageInfoHelper;
import com.mindskip.xzs.viewmodel.admin.question.ExamQuestionVO;
import com.mindskip.xzs.viewmodel.admin.question.QuestionEditRequestVM;
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperSubmitItemVM;
import com.mindskip.xzs.viewmodel.student.question.answer.QuestionAnswerVM;
import com.mindskip.xzs.viewmodel.student.question.answer.QuestionAnswerVO;
import com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentRequestVM;
import com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentResponseVM;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.stream.Collectors;
@RestController("StudentQuestionAnswerController")
@RequestMapping(value = "/api/student/question/answer")
@@ -45,26 +35,8 @@
    @RequestMapping(value = "/page", method = RequestMethod.POST)
    public RestResponse<PageInfo<QuestionPageStudentResponseVM>> pageList(@RequestBody QuestionPageStudentRequestVM model) {
        model.setCreateUser(getCurrentUser().getId());
        PageInfo<ExamPaperQuestionCustomerAnswer> pageInfo = examPaperQuestionCustomerAnswerService.studentPage(model);
        PageInfo<QuestionPageStudentResponseVM> page = PageInfoHelper.copyMap(pageInfo, q -> {
//            Subject subject = subjectService.selectById(q.getSubjectId());
            Integer[] ids = questionSubjectService.getQuestion(q.getQuestionId())
                    .stream().map(QuestionSubject::getSubjectId).toArray(Integer[]::new);
            String name = "";
            if (ids.length > 0) {
                name = subjectService.selectByIds(ids)
                        .stream().map(Subject::getName).collect(Collectors.joining(","));
            }
            QuestionPageStudentResponseVM vm = modelMapper.map(q, QuestionPageStudentResponseVM.class);
            vm.setCreateTime(DateTimeUtil.dateFormat(q.getCreateTime()));
            TextContent textContent = textContentService.selectById(q.getQuestionTextContentId());
            QuestionObject questionObject = JsonUtil.toJsonObject(textContent.getContent(), QuestionObject.class);
            String clearHtml = HtmlUtil.clear(questionObject.getTitleContent());
            vm.setShortTitle(clearHtml);
            vm.setSubjectName(name);
            return vm;
        });
        return RestResponse.ok(page);
        PageInfo<QuestionPageStudentResponseVM> pageInfo = examPaperQuestionCustomerAnswerService.studentPage(model);
        return RestResponse.ok(pageInfo);
    }
src/main/java/com/mindskip/xzs/repository/ExamPaperQuestionCustomerAnswerMapper.java
@@ -4,6 +4,7 @@
import com.mindskip.xzs.domain.other.ExamPaperAnswerUpdate;
import com.mindskip.xzs.domain.other.KeyValue;
import com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentRequestVM;
import com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentResponseVM;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -15,7 +16,7 @@
    List<ExamPaperQuestionCustomerAnswer> selectListByPaperAnswerId(Integer id);
    List<ExamPaperQuestionCustomerAnswer> studentPage(QuestionPageStudentRequestVM requestVM);
    List<QuestionPageStudentResponseVM> studentPage(QuestionPageStudentRequestVM requestVM);
    int insertList(List<ExamPaperQuestionCustomerAnswer> list);
src/main/java/com/mindskip/xzs/service/ExamPaperQuestionCustomerAnswerService.java
@@ -5,12 +5,13 @@
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperSubmitItemVM;
import com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentRequestVM;
import com.github.pagehelper.PageInfo;
import com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentResponseVM;
import java.util.List;
public interface ExamPaperQuestionCustomerAnswerService extends BaseService<ExamPaperQuestionCustomerAnswer> {
    PageInfo<ExamPaperQuestionCustomerAnswer> studentPage(QuestionPageStudentRequestVM requestVM);
    PageInfo<QuestionPageStudentResponseVM> studentPage(QuestionPageStudentRequestVM requestVM);
    List<ExamPaperQuestionCustomerAnswer> selectListByPaperAnswerId(Integer id);
src/main/java/com/mindskip/xzs/service/impl/ExamPaperQuestionCustomerAnswerServiceImpl.java
@@ -10,11 +10,13 @@
import com.mindskip.xzs.service.TextContentService;
import com.mindskip.xzs.utility.DateTimeUtil;
import com.mindskip.xzs.utility.ExamUtil;
import com.mindskip.xzs.utility.HtmlUtil;
import com.mindskip.xzs.utility.JsonUtil;
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperSubmitItemVM;
import com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentRequestVM;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentResponseVM;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -37,9 +39,11 @@
    @Override
    public PageInfo<ExamPaperQuestionCustomerAnswer> studentPage(QuestionPageStudentRequestVM requestVM) {
        return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() ->
                examPaperQuestionCustomerAnswerMapper.studentPage(requestVM)
    public PageInfo<QuestionPageStudentResponseVM> studentPage(QuestionPageStudentRequestVM requestVM) {
        return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize()).doSelectPageInfo(() ->
                examPaperQuestionCustomerAnswerMapper.studentPage(requestVM).stream().peek(
                        q -> q.setShortTitle(HtmlUtil.clear(q.getShortTitle()))
                ).collect(Collectors.toList())
        );
    }
src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java
@@ -161,6 +161,9 @@
                .flatMap(t -> t.getQuestionItems().stream()
                        .map(q -> q.getId()))
                .collect(Collectors.toList());
        if (ObjectUtils.isEmpty(questionIds)) {
            throw new RuntimeException("该试卷没有题目");
        }
        List<Question> questions = questionMapper.selectByIds(questionIds);
        //单选数量
        Integer singleChoice = questions.stream().filter(e -> e.getQuestionType() == 1).collect(Collectors.toList()).size();
src/main/java/com/mindskip/xzs/service/impl/QuestionServiceImpl.java
@@ -265,7 +265,7 @@
    @Override
    public PageInfo<QuestionPageStudentResponseVM> selectQuestion(QuestionPageStudentRequestVM model) {
        return PageHelper.startPage(model.getPageIndex(), model.getPageSize(), "id desc").doSelectPageInfo(() ->
        return PageHelper.startPage(model.getPageIndex(), model.getPageSize()).doSelectPageInfo(() ->
                questionMapper.selectQuestion(model).stream().peek(
                        q -> q.setShortTitle(HtmlUtil.clear(q.getShortTitle()))
                ).collect(Collectors.toList())
src/main/java/com/mindskip/xzs/viewmodel/student/question/answer/QuestionPageStudentRequestVM.java
@@ -7,6 +7,16 @@
    private String subjectName;
    private String shortTitle;
    public String getShortTitle() {
        return shortTitle;
    }
    public void setShortTitle(String shortTitle) {
        this.shortTitle = shortTitle;
    }
    public String getSubjectName() {
        return subjectName;
    }
src/main/resources/mapper/ExamPaperQuestionCustomerAnswerMapper.xml
@@ -228,14 +228,23 @@
  </select>
  <select id="studentPage" resultMap="BaseResultMap" parameterType="com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentRequestVM">
    SELECT
    <include refid="Base_Column_List"/>
    FROM t_exam_paper_question_customer_answer
    <where>
      and do_right=FALSE
      and create_user=#{createUser}
    </where>
  <select id="studentPage" resultType="com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentResponseVM" parameterType="com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentRequestVM">
    select a.id,
           a.question_type,
           JSON_VALUE(d.content, '$.titleContent') as shortTitle,
           GROUP_CONCAT(DISTINCT c.name)                    as subjectName,
           a.create_time
    from t_exam_paper_question_customer_answer a
           inner join t_question_subject b on a.question_id = b.question_id and b.deleted = 0
           inner join t_subject c on b.subject_id = c.id and c.deleted = 0
           inner join t_text_content d on a.question_text_content_id = d.id
    where
      a.do_right = FALSE
      and a.create_user = #{createUser}
      and JSON_VALUE(d.content, '$.titleContent') like concat('%', #{shortTitle}, '%')
    group by a.question_id, question_type
    HAVING GROUP_CONCAT(c.name) like concat('%',  #{subjectName}, '%')
    order by a.question_id desc
  </select>
src/main/resources/mapper/QuestionMapper.xml
@@ -307,6 +307,7 @@
                 inner join t_subject c on b.subject_id = c.id and c.deleted = 0
                 inner join t_text_content d on a.info_text_content_id = d.id
        where a.deleted = 0
        AND JSON_VALUE(d.content, '$.titleContent') like concat('%', #{shortTitle}, '%')
        group by a.id, question_type, a.create_time
        HAVING GROUP_CONCAT(c.name) like concat('%', #{subjectName}, '%')
        order by a.create_time