Skip to content

Commit 7de3748

Browse files
committed
4月1号版更新
1 parent a0e3217 commit 7de3748

File tree

5 files changed

+66
-16
lines changed

5 files changed

+66
-16
lines changed

src/main/java/com/exam/controller/AnswerController.java

+14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.exam.controller;
22

33
import com.exam.entity.Answer;
4+
import com.exam.entity.ApiResult;
45
import com.exam.service.AnswerService;
6+
import com.exam.util.ApiResultHandler;
57
import org.springframework.web.bind.annotation.*;
68

79
import javax.annotation.Resource;
10+
import java.util.List;
811

912
/**
1013
* (Answer)表控制层
@@ -32,4 +35,15 @@ public Answer selectOne(Integer id) {
3235
return this.answerService.queryById(id);
3336
}
3437

38+
@PostMapping("/commit")
39+
public ApiResult commit(@RequestBody List<Answer> answer) {
40+
for (int i = 0; i < answer.size(); i++) {
41+
Answer res = answerService.insert(answer.get(i));
42+
if (res == null) {
43+
return ApiResultHandler.buildApiResult(400, "添加失败", null);
44+
}
45+
}
46+
return ApiResultHandler.buildApiResult(200, "添加成功", null);
47+
}
48+
3549
}

src/main/java/com/exam/entity/Answer.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class Answer implements Serializable {
2727
/**
2828
* 试题类型
2929
*/
30-
private String questype;
30+
private Integer questype;
3131
/**
3232
* 试题编号
3333
*/
@@ -37,5 +37,9 @@ public class Answer implements Serializable {
3737
*/
3838
private String answer;
3939

40+
private String rightAnswer;
41+
42+
private Integer score;
43+
4044

4145
}

src/main/java/com/exam/entity/Score.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public class Score implements Serializable {
2626
* 考试编号
2727
*/
2828
private Integer examid;
29+
30+
private String exname;
2931
/**
3032
* 学号
3133
*/
@@ -45,9 +47,11 @@ public class Score implements Serializable {
4547
/**
4648
* 总成绩
4749
*/
48-
4950
private Integer totalscore;
5051

52+
//交卷时间
53+
private String answerdate;
54+
5155
private String claname; //班级名称
5256

5357
private String major;//专业名称
@@ -63,4 +67,5 @@ public class Score implements Serializable {
6367
private Student student;//学生实体
6468

6569

70+
6671
}

src/main/resources/mapper/AnswerDao.xml

+21-6
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,34 @@
66
<result property="answerid" column="answerId" jdbcType="INTEGER"/>
77
<result property="examid" column="examId" jdbcType="INTEGER"/>
88
<result property="stuid" column="stuId" jdbcType="INTEGER"/>
9-
<result property="questype" column="quesType" jdbcType="VARCHAR"/>
9+
<result property="questype" column="quesType" jdbcType="INTEGER"/>
1010
<result property="quesid" column="quesId" jdbcType="INTEGER"/>
1111
<result property="answer" column="answer" jdbcType="VARCHAR"/>
12+
<result property="score" column="score" jdbcType="INTEGER"/>
13+
<result property="rightAnswer" column="rightAnswer" jdbcType="VARCHAR"/>
14+
1215
</resultMap>
1316

1417
<!--查询单个-->
1518
<select id="queryById" resultMap="AnswerMap">
1619
select
17-
answerId, examId, stuId, quesType, quesId, answer
20+
answerId, examId, stuId, quesType, quesId, answer,score,rightAnswer
1821
from cqc_exam.answer
1922
where answerId = #{answerid}
2023
</select>
2124

2225
<!--查询指定行数据-->
2326
<select id="queryAllByLimit" resultMap="AnswerMap">
2427
select
25-
answerId, examId, stuId, quesType, quesId, answer
28+
answerId, examId, stuId, quesType, quesId, answer,score,rightAnswer
2629
from cqc_exam.answer
2730
limit #{offset}, #{limit}
2831
</select>
2932

3033
<!--通过实体作为筛选条件查询-->
3134
<select id="queryAll" resultMap="AnswerMap">
3235
select
33-
answerId, examId, stuId, quesType, quesId, answer
36+
answerId, examId, stuId, quesType, quesId, answer,score,rightAnswer
3437
from cqc_exam.answer
3538
<where>
3639
<if test="answerid != null">
@@ -51,13 +54,19 @@
5154
<if test="answer != null and answer != ''">
5255
and answer = #{answer}
5356
</if>
57+
<if test="score != null">
58+
and score = #{score}
59+
</if>
60+
<if test="rightAnswer != null and rightAnswer != ''">
61+
and rightAnswer = #{rightAnswer}
62+
</if>
5463
</where>
5564
</select>
5665

5766
<!--新增所有列-->
5867
<insert id="insert" keyProperty="answerid" useGeneratedKeys="true">
59-
insert into cqc_exam.answer(examId, stuId, quesType, quesId, answer)
60-
values (#{examid}, #{stuid}, #{questype}, #{quesid}, #{answer})
68+
insert into cqc_exam.answer(examId, stuId, quesType, quesId, answer,score,rightAnswer)
69+
values (#{examid}, #{stuid}, #{questype}, #{quesid}, #{answer},#{score},#{rightAnswer})
6170
</insert>
6271

6372
<!--通过主键修改数据-->
@@ -79,6 +88,12 @@
7988
<if test="answer != null and answer != ''">
8089
answer = #{answer},
8190
</if>
91+
<if test="score != null">
92+
score = #{score},
93+
</if>
94+
<if test="rightAnswer != null and rightAnswer != ''">
95+
rightAnswer = #{rightAnswer},
96+
</if>
8297
</set>
8398
where answerId = #{answerid}
8499
</update>

src/main/resources/mapper/ScoreDao.xml

+20-8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
<result property="subscore" column="subScore" jdbcType="INTEGER"/>
1111
<result property="totalscore" column="totalScore" jdbcType="INTEGER"/>
1212
<result property="course" column="course" jdbcType="VARCHAR"/>
13+
<result property="answerdate" column="answerDate" jdbcType="VARCHAR"/>
14+
1315
</resultMap>
1416

1517

@@ -27,6 +29,9 @@
2729
<result property="grade" column="grade" jdbcType="VARCHAR"/>
2830
<result property="term" column="term" jdbcType="VARCHAR"/>
2931
<result property="description" column="description" jdbcType="VARCHAR"/>
32+
<result property="answerdate" column="answerDate" jdbcType="VARCHAR"/>
33+
<result property="exname" column="exname" jdbcType="VARCHAR"/>
34+
3035
<association property="student" javaType="com.exam.entity.Student">
3136
<result property="stuid" column="stuId" jdbcType="INTEGER"/>
3237
<result property="stuname" column="stuName" jdbcType="VARCHAR"/>
@@ -42,7 +47,7 @@
4247
<!--查询所有-->
4348
<select id="findAll" resultMap="ScoreResultMap">
4449
select
45-
scoreId, sc.examId, sc.stuId, objScore, subScore, totalScore,e.grade as grade,e.term as term,e.description as description,
50+
scoreId, sc.examId, sc.stuId, objScore, subScore, totalScore,answerDate,e.exname as exname,e.grade as grade,e.term as term,e.description as description,
4651
stu.sex,stu.tel,stu.stuname,cl.calName as claname,ma.major as major,co.couName as course,i.instituName as instituname
4752
from score sc,exam e ,student stu,institution i,course co,major ma,clazz cl
4853
where e.examId=sc.examId and sc.stuId=stu.stuId and stu.clazzId=cl.clazzId and cl.majorId=ma.majorId
@@ -52,7 +57,7 @@
5257
<!--查询单个-->
5358
<select id="queryById" resultMap="ScoreResultMap">
5459
select
55-
scoreId, sc.examId, sc.stuId, objScore, subScore, totalScore,e.grade as grade,e.term as term,e.description as description,
60+
scoreId, sc.examId, sc.stuId, objScore, subScore, totalScore,answerDate,e.exname as exname,e.grade as grade,e.term as term,e.description as description,
5661
stu.sex,stu.tel,stu.stuname,cl.calName as claname,ma.major as major,co.couName as course,i.instituName as instituname
5762
from score sc,exam e ,student stu,institution i,course co,major ma,clazz cl
5863
where e.examId=sc.examId and sc.stuId=stu.stuId and stu.clazzId=cl.clazzId and cl.majorId=ma.majorId
@@ -63,7 +68,7 @@
6368
<!--查询单个-->
6469
<select id="queryByStuId" resultMap="ScoreResultMap">
6570
select
66-
scoreId, sc.examId, sc.stuId, objScore, subScore, totalScore,e.grade as grade,e.term as term,e.description as description,
71+
scoreId, sc.examId, sc.stuId, objScore, subScore, totalScore,answerDate,e.exname as exname,e.grade as grade,e.term as term,e.description as description,
6772
stu.sex,stu.tel,stu.stuname,cl.calName as claname,ma.major as major,co.couName as course,i.instituName as instituname
6873
from score sc,exam e ,student stu,institution i,course co,major ma,clazz cl
6974
where e.examId=sc.examId and sc.stuId=stu.stuId and stu.clazzId=cl.clazzId and cl.majorId=ma.majorId
@@ -74,7 +79,7 @@
7479
<!--查询单个-->
7580
<select id="queryByExamId" resultMap="ScoreResultMap">
7681
select
77-
scoreId, sc.examId, sc.stuId, objScore, subScore, totalScore,e.grade as grade,e.term as term,e.description as description,
82+
scoreId, sc.examId, sc.stuId, objScore, subScore, totalScore,answerDate,e.exname as exname,e.grade as grade,e.term as term,e.description as description,
7883
stu.sex,stu.tel,stu.stuname,cl.calName as claname,ma.major as major,co.couName as course,i.instituName as instituname
7984
from score sc,exam e ,student stu,institution i,course co,major ma,clazz cl
8085
where e.examId=sc.examId and sc.stuId=stu.stuId and stu.clazzId=cl.clazzId and cl.majorId=ma.majorId
@@ -85,15 +90,15 @@
8590
<!--查询指定行数据-->
8691
<select id="queryAllByLimit" resultMap="ScoreMap">
8792
select
88-
scoreId, examId, stuId, course, objScore, subScore, totalScore
93+
scoreId, examId, stuId, course, objScore, subScore, totalScore,answerDate
8994
from cqc_exam.score
9095
limit #{offset}, #{limit}
9196
</select>
9297

9398
<!--通过实体作为筛选条件查询-->
9499
<select id="queryAll" resultMap="ScoreMap">
95100
select
96-
scoreId, examId, stuId, course, objScore, subScore, totalScore
101+
scoreId, examId, stuId, course, objScore, subScore, totalScore,answerDate
97102
from cqc_exam.score
98103
<where>
99104
<if test="scoreid != null">
@@ -117,13 +122,17 @@
117122
<if test="totalscore != null">
118123
and totalScore = #{totalscore}
119124
</if>
125+
<if test="answerdate != null">
126+
and answerDate = #{answerdate}
127+
</if>
128+
120129
</where>
121130
</select>
122131

123132
<!--新增所有列-->
124133
<insert id="insert" keyProperty="scoreid" useGeneratedKeys="true">
125-
insert into cqc_exam.score(examId, stuId, course, objScore, subScore, totalScore)
126-
values (#{examid}, #{stuid}, #{course}, #{objscore}, #{subscore}, #{totalscore})
134+
insert into cqc_exam.score(examId, stuId, course, objScore, subScore, totalScore,answerDate)
135+
values (#{examid}, #{stuid}, #{course}, #{objscore}, #{subscore}, #{totalscore},#{answerdate})
127136
</insert>
128137

129138
<!--通过主键修改数据-->
@@ -148,6 +157,9 @@
148157
<if test="totalscore != null">
149158
totalScore = #{totalscore},
150159
</if>
160+
<if test="answerdate != null">
161+
answerDate = #{answerdate},
162+
</if>
151163
</set>
152164
where scoreId = #{scoreid}
153165
</update>

0 commit comments

Comments
 (0)