完成试卷生成的方法--By Ternece

This commit is contained in:
wushaofeng 2020-12-29 16:42:57 +08:00
parent 78435af514
commit e4b01330ae
6 changed files with 122 additions and 3 deletions

View File

@ -0,0 +1,26 @@
package com.mindskip.xzs.controller.student;
import com.mindskip.xzs.base.BaseApiController;
import com.mindskip.xzs.base.RestResponse;
import com.mindskip.xzs.domain.Question;
import com.mindskip.xzs.service.ExaminationPaperProductionService;
import com.mindskip.xzs.viewmodel.student.exam.ExaminationProductionVM;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
@RestController("ExaminationPaperProductionController")
@RequestMapping(value = "/api/student/examination/paper")
@AllArgsConstructor
public class ExaminationPaperProductionController extends BaseApiController {
private final ExaminationPaperProductionService examinationPaperProductionService;
@RequestMapping(value = "/production", method = RequestMethod.GET)
public RestResponse paperProduction(@RequestBody @Valid ExaminationProductionVM examinationProductionVM){
List<Question> questionList = examinationPaperProductionService.generation(examinationProductionVM);
return RestResponse.ok(questionList);
}
}

View File

@ -1,8 +1,9 @@
package com.mindskip.xzs.repository; package com.mindskip.xzs.repository;
import com.mindskip.xzs.domain.other.KeyValue;
import com.mindskip.xzs.domain.Question; import com.mindskip.xzs.domain.Question;
import com.mindskip.xzs.domain.other.KeyValue;
import com.mindskip.xzs.viewmodel.admin.question.QuestionPageRequestVM; import com.mindskip.xzs.viewmodel.admin.question.QuestionPageRequestVM;
import com.mindskip.xzs.viewmodel.student.exam.ExaminationProductionVM;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -30,4 +31,6 @@ public interface QuestionMapper extends BaseMapper<Question> {
Integer selectAllCount(); Integer selectAllCount();
List<KeyValue> selectCountByDate(@Param("startTime") Date startTime, @Param("endTime") Date endTime); List<KeyValue> selectCountByDate(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
List<Question> selectQuestionsByQuestionsNumber(ExaminationProductionVM examinationProductionVM);
} }

View File

@ -0,0 +1,12 @@
package com.mindskip.xzs.service;
import com.mindskip.xzs.domain.Question;
import com.mindskip.xzs.viewmodel.student.exam.ExaminationProductionVM;
import java.util.List;
public interface ExaminationPaperProductionService extends BaseService<Question>{
List<Question> generation(ExaminationProductionVM examinationProductionVM);
}

View File

@ -0,0 +1,33 @@
package com.mindskip.xzs.service.impl;
import com.github.pagehelper.PageHelper;
import com.mindskip.xzs.domain.Question;
import com.mindskip.xzs.repository.BaseMapper;
import com.mindskip.xzs.repository.QuestionMapper;
import com.mindskip.xzs.service.ExaminationPaperProductionService;
import com.mindskip.xzs.viewmodel.student.exam.ExaminationProductionVM;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ExaminationPaperProductionServiceImpl extends BaseServiceImpl<Question> implements ExaminationPaperProductionService {
private final QuestionMapper questionMapper;
@Autowired
public ExaminationPaperProductionServiceImpl(BaseMapper<Question> baseMapper, QuestionMapper questionMapper) {
super(baseMapper);
this.questionMapper = questionMapper;
}
@Override
public List<Question> generation(ExaminationProductionVM examinationProductionVM) {
return PageHelper.startPage(examinationProductionVM.getPageIndex(),examinationProductionVM.getPageSize()).doSelectPage(()->
questionMapper.selectQuestionsByQuestionsNumber(examinationProductionVM));
}
}

View File

@ -0,0 +1,18 @@
package com.mindskip.xzs.viewmodel.student.exam;
import com.mindskip.xzs.base.BasePage;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class ExaminationProductionVM extends BasePage {
@NotNull
private int questionNumber;
private Integer difficult;
private List<Integer> skillIds;
private Integer industryId;
}

View File

@ -209,7 +209,7 @@
<include refid="Page_Column_List"/> <include refid="Page_Column_List"/>
FROM t_question AS q LEFT JOIN t_industry AS i ON q.industry_id = i.id LEFT JOIN t_skill AS s ON s.id = q.skill_id FROM t_question AS q LEFT JOIN t_industry AS i ON q.industry_id = i.id LEFT JOIN t_skill AS s ON s.id = q.skill_id
<where> <where>
and q.deleted=0 q.deleted=0
<if test="id != null "> <if test="id != null ">
and q.id= #{id} and q.id= #{id}
</if> </if>
@ -231,6 +231,33 @@
</where> </where>
</select> </select>
<select id="selectQuestionsByQuestionsNumber"
parameterType="com.mindskip.xzs.viewmodel.student.exam.ExaminationProductionVM"
resultMap="BaseResultMap"
>
select
<include refid="Base_Column_List"/>
from t_question
<where>
q.deleted=0
<if test="difficult != null">
and difficult = #{difficult}
</if>
<if test="industryId != null">
and industry_id= #{industryId}
</if>
<if test="skillIds != null">
and skill_id in
<foreach collection="skillIds" item="skillId" open="(" separator=","
close=")">
#{skillId}
</foreach>
</if>
</where>
group by skill_id
limit #{questionNumber}
</select>
<select id="selectByIds" resultMap="BaseResultMap" > <select id="selectByIds" resultMap="BaseResultMap" >