优化代码新增xml

newBigdata
xiaoCJ 11 months ago
parent 3e34331f8b
commit 9999ae5511

@ -3,7 +3,6 @@ package com.sztzjy.financial_bigdata.controller.tea;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sztzjy.financial_bigdata.annotation.AnonymousAccess;
import com.sztzjy.financial_bigdata.config.Constant;
import com.sztzjy.financial_bigdata.entity.*;
import com.sztzjy.financial_bigdata.entity.tea_dto.TeaExamManageCountDto;
import com.sztzjy.financial_bigdata.entity.tea_dto.TeaExamManageDto;
@ -22,7 +21,10 @@ import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @Author xcj
@ -54,15 +56,8 @@ public class TeaExamManageController {
@PostMapping("/getSelectCountAndScore")
@ApiOperation("新增考试--获取选题量和分数")
public ResultEntity<Map<Integer, BigDecimal>> getsingleId(@RequestBody @ApiParam("所有ID用,隔开一次传过来") List<String> ids) {
Map<Integer, BigDecimal> map = new HashMap<>();
int i = 0;
BigDecimal score = BigDecimal.ZERO;
for (String id : ids) {
SysObjectiveQuestion sysObjectiveQuestion = sysObjectiveQuestionMapper.selectByPrimaryKey(id);
i++;
score = sysObjectiveQuestion.getScore().add(score);
}
map.put(i, score);
List<String> list = new ArrayList<>(ids);
Map<Integer, BigDecimal> map = sysObjectiveQuestionMapper.selectByList(list);
return new ResultEntity<>(map);
}
@ -79,12 +74,8 @@ public class TeaExamManageController {
@ApiOperation("新增考试--选择客观题时展示")
public ResultEntity<List<SysObjectiveQuestion>> selectObjectivityByType(@ApiParam("0单选 1多选 2判断") @RequestParam String type,
@RequestParam String schoolId) {
SysObjectiveQuestionExample sysObjectiveQuestionExample = new SysObjectiveQuestionExample();
List<String> l = new ArrayList<>();
l.add(schoolId);
l.add(Constant.BUILT_IN_SCHOOL_ID);
sysObjectiveQuestionExample.createCriteria().andTypeEqualTo(type).andSchoolIdIn(l);
return new ResultEntity<List<SysObjectiveQuestion>>(sysObjectiveQuestionMapper.selectByExample(sysObjectiveQuestionExample));
List<SysObjectiveQuestion> list = sysObjectiveQuestionMapper.selectObjectivityByType(type, schoolId);
return new ResultEntity<>(list);
}
@ -224,8 +215,8 @@ public class TeaExamManageController {
@AnonymousAccess
@PostMapping("/reloadExamById")
@ApiOperation("考试管理--指定人重考")
public ResultEntity<String> reloadExamById (@ApiParam("考试管理ID") @RequestParam String
examId, @RequestParam String userId){
public ResultEntity<String> reloadExamById(@ApiParam("考试管理ID") @RequestParam String
examId, @RequestParam String userId) {
StuStudentExamExample studentExamExample = new StuStudentExamExample();
studentExamExample.createCriteria().andUseridEqualTo(userId).andExamManageIdEqualTo(examId);
List<StuStudentExamWithBLOBs> stuStudentExamWithBLOBs = studentExamMapper.selectByExampleWithBLOBs(studentExamExample);
@ -237,7 +228,7 @@ public class TeaExamManageController {
return new ResultEntity(HttpStatus.OK, "指定重考成功!");
}
}
}
}

@ -3,7 +3,10 @@ package com.sztzjy.financial_bigdata.mapper;
import com.sztzjy.financial_bigdata.entity.SysCaseQuestion;
import com.sztzjy.financial_bigdata.entity.SysObjectiveQuestion;
import com.sztzjy.financial_bigdata.entity.SysObjectiveQuestionExample;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import com.sztzjy.financial_bigdata.entity.tea_dto.TeaExamManageCountDto;
import org.apache.ibatis.annotations.Mapper;
@ -50,4 +53,8 @@ public interface SysObjectiveQuestionMapper {
List<SysObjectiveQuestion> selectRandomObjectiveJudge();
List<SysObjectiveQuestion> getGradeReportObjective(@Param("list") List<String> list);
Map<Integer, BigDecimal> selectByList(@Param("list") List<String> list);
List<SysObjectiveQuestion> selectObjectivityByType(@Param("type")String type, @Param("schoolId")String schoolId);
}

@ -2,23 +2,23 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sztzjy.financial_bigdata.mapper.SysObjectiveQuestionMapper">
<resultMap id="BaseResultMap" type="com.sztzjy.financial_bigdata.entity.SysObjectiveQuestion">
<id column="objective_id" jdbcType="VARCHAR" property="objectiveId" />
<result column="course_id" jdbcType="VARCHAR" property="courseId" />
<result column="course_name" jdbcType="VARCHAR" property="courseName" />
<result column="chapter_id" jdbcType="VARCHAR" property="chapterId" />
<result column="chapter_name" jdbcType="VARCHAR" property="chapterName" />
<result column="input_type" jdbcType="VARCHAR" property="inputType" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="score" jdbcType="DECIMAL" property="score" />
<result column="content" jdbcType="VARCHAR" property="content" />
<result column="question_a" jdbcType="VARCHAR" property="questionA" />
<result column="question_b" jdbcType="VARCHAR" property="questionB" />
<result column="question_c" jdbcType="VARCHAR" property="questionC" />
<result column="question_d" jdbcType="VARCHAR" property="questionD" />
<result column="question_e" jdbcType="VARCHAR" property="questionE" />
<result column="answer" jdbcType="VARCHAR" property="answer" />
<result column="analysis" jdbcType="VARCHAR" property="analysis" />
<result column="school_id" jdbcType="VARCHAR" property="schoolId" />
<id column="objective_id" jdbcType="VARCHAR" property="objectiveId"/>
<result column="course_id" jdbcType="VARCHAR" property="courseId"/>
<result column="course_name" jdbcType="VARCHAR" property="courseName"/>
<result column="chapter_id" jdbcType="VARCHAR" property="chapterId"/>
<result column="chapter_name" jdbcType="VARCHAR" property="chapterName"/>
<result column="input_type" jdbcType="VARCHAR" property="inputType"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="score" jdbcType="DECIMAL" property="score"/>
<result column="content" jdbcType="VARCHAR" property="content"/>
<result column="question_a" jdbcType="VARCHAR" property="questionA"/>
<result column="question_b" jdbcType="VARCHAR" property="questionB"/>
<result column="question_c" jdbcType="VARCHAR" property="questionC"/>
<result column="question_d" jdbcType="VARCHAR" property="questionD"/>
<result column="question_e" jdbcType="VARCHAR" property="questionE"/>
<result column="answer" jdbcType="VARCHAR" property="answer"/>
<result column="analysis" jdbcType="VARCHAR" property="analysis"/>
<result column="school_id" jdbcType="VARCHAR" property="schoolId"/>
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -38,7 +38,8 @@
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
@ -67,7 +68,8 @@
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
@ -79,19 +81,21 @@
</where>
</sql>
<sql id="Base_Column_List">
objective_id, course_id, course_name, chapter_id, chapter_name, input_type, type,
objective_id
, course_id, course_name, chapter_id, chapter_name, input_type, type,
score, content, question_a, question_b, question_c, question_d, question_e, answer,
analysis, school_id
</sql>
<select id="selectByExample" parameterType="com.sztzjy.financial_bigdata.entity.SysObjectiveQuestionExample" resultMap="BaseResultMap">
<select id="selectByExample" parameterType="com.sztzjy.financial_bigdata.entity.SysObjectiveQuestionExample"
resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
<include refid="Base_Column_List"/>
from sys_objective_question
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
@ -99,18 +103,19 @@
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
<include refid="Base_Column_List"/>
from sys_objective_question
where objective_id = #{objectiveId,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from sys_objective_question
delete
from sys_objective_question
where objective_id = #{objectiveId,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="com.sztzjy.financial_bigdata.entity.SysObjectiveQuestionExample">
delete from sys_objective_question
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
<include refid="Example_Where_Clause"/>
</if>
</delete>
<insert id="insert" parameterType="com.sztzjy.financial_bigdata.entity.SysObjectiveQuestion">
@ -236,10 +241,11 @@
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.sztzjy.financial_bigdata.entity.SysObjectiveQuestionExample" resultType="java.lang.Long">
<select id="countByExample" parameterType="com.sztzjy.financial_bigdata.entity.SysObjectiveQuestionExample"
resultType="java.lang.Long">
select count(*) from sys_objective_question
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
<include refid="Example_Where_Clause"/>
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
@ -298,7 +304,7 @@
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByExample" parameterType="map">
@ -321,7 +327,7 @@
analysis = #{record.analysis,jdbcType=VARCHAR},
school_id = #{record.schoolId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.financial_bigdata.entity.SysObjectiveQuestion">
@ -400,19 +406,31 @@
</update>
<select id="selectRandomObjective" parameterType="map" resultMap="BaseResultMap">
SELECT
objective_id, course_id, course_name, chapter_id, chapter_name, input_type, type,
score, content, question_a, question_b, question_c, question_d, question_e, answer, school_id
SELECT objective_id,
course_id,
course_name,
chapter_id,
chapter_name,
input_type,
type,
score,
content,
question_a,
question_b,
question_c,
question_d,
question_e,
answer,
school_id
FROM sys_objective_question
WHERE chapter_id = #{chapterId,jdbcType=VARCHAR}
ORDER BY RAND()
LIMIT 10
ORDER BY RAND() LIMIT 10
</select>
<select id="selectRandomObjectiveSingle" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
<include refid="Base_Column_List"/>
FROM
sys_objective_question
WHERE
@ -425,7 +443,7 @@
<select id="selectRandomObjectiveMany" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
<include refid="Base_Column_List"/>
FROM
sys_objective_question
WHERE
@ -438,7 +456,7 @@
<select id="selectRandomObjectiveJudge" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List" />
<include refid="Base_Column_List"/>
FROM
sys_objective_question
WHERE
@ -459,4 +477,19 @@
</foreach>
</select>
<select id="selectByList" parameterType="java.util.List" resultType="java.util.Map">
SELECT count(*),sum(score)FROM sys_objective_question
WHERE objective_id IN
<foreach collection="list" separator="," item="id" open="(" close=")">
#{id}
</foreach>
</select>
<select id="selectObjectivityByType" parameterType="java.lang.String" resultMap="BaseResultMap">
SELECT objective_id,content,chapter_name,course_name FROM sys_objective_question
WHERE school_id IN(#{schoolId},'999999999')
AND type = #{type}
</select>
</mapper>
Loading…
Cancel
Save