Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-microservice-exam
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
汪想
spring-microservice-exam
Commits
fb1bdf99
Commit
fb1bdf99
authored
May 08, 2019
by
tangyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
功能优化
parent
c138889a
Show whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
765 additions
and
164 deletions
+765
-164
README.md
README.md
+8
-0
MqConstant.java
...va/com/github/tangyi/common/core/constant/MqConstant.java
+5
-0
BaseEntity.java
...com/github/tangyi/common/core/persistence/BaseEntity.java
+5
-4
DateUtils.java
...n/java/com/github/tangyi/common/core/utils/DateUtils.java
+37
-0
ExcelToolUtil.java
...va/com/github/tangyi/common/core/utils/ExcelToolUtil.java
+12
-7
auth-service.yml
config-service/src/main/resources/config/auth-service.yml
+3
-3
exam-service.yml
config-service/src/main/resources/config/exam-service.yml
+3
-3
gateway-service.yml
config-service/src/main/resources/config/gateway-service.yml
+3
-3
user-service.yml
config-service/src/main/resources/config/user-service.yml
+5
-5
microservice-auth.sql
doc/deploy/mysql/microservice-auth.sql
+6
-6
microservice-exam.sql
doc/deploy/mysql/microservice-exam.sql
+43
-19
microservice-user.sql
doc/deploy/mysql/microservice-user.sql
+15
-15
docker-compose.env
docker-compose.env
+3
-3
ExaminationInitConfig.java
.../com/github/tangyi/exam/config/ExaminationInitConfig.java
+45
-0
RabbitSubmitExaminationConfig.java
...hub/tangyi/exam/config/RabbitSubmitExaminationConfig.java
+26
-0
AnswerController.java
...a/com/github/tangyi/exam/controller/AnswerController.java
+23
-16
ExamRecordController.java
...m/github/tangyi/exam/controller/ExamRecordController.java
+38
-3
ExaminationController.java
.../github/tangyi/exam/controller/ExaminationController.java
+3
-11
IncorrectAnswerController.java
...hub/tangyi/exam/controller/IncorrectAnswerController.java
+3
-0
SubjectBankController.java
.../github/tangyi/exam/controller/SubjectBankController.java
+2
-3
SubjectController.java
.../com/github/tangyi/exam/controller/SubjectController.java
+7
-37
AnswerMapper.java
...main/java/com/github/tangyi/exam/mapper/AnswerMapper.java
+1
-0
RabbitSubmitExaminationReceiver.java
...ithub/tangyi/exam/mq/RabbitSubmitExaminationReceiver.java
+68
-0
AnswerService.java
...in/java/com/github/tangyi/exam/service/AnswerService.java
+77
-3
ExamRecordService.java
...ava/com/github/tangyi/exam/service/ExamRecordService.java
+89
-1
ExaminationService.java
...va/com/github/tangyi/exam/service/ExaminationService.java
+2
-1
SubjectService.java
...n/java/com/github/tangyi/exam/service/SubjectService.java
+54
-1
AnswerMapper.xml
...l/exam-service/src/main/resources/mapper/AnswerMapper.xml
+1
-1
ExamRecodeMapper.xml
...am-service/src/main/resources/mapper/ExamRecodeMapper.xml
+10
-0
MenuController.java
...ava/com/github/tangyi/user/controller/MenuController.java
+6
-3
UserController.java
...ava/com/github/tangyi/user/controller/UserController.java
+2
-3
ExamRecordConstant.java
.../github/tangyi/exam/api/constants/ExamRecordConstant.java
+28
-0
SubjectConstant.java
...com/github/tangyi/exam/api/constants/SubjectConstant.java
+13
-0
ExamRecordDto.java
...in/java/com/github/tangyi/exam/api/dto/ExamRecordDto.java
+39
-0
StartExamDto.java
...ain/java/com/github/tangyi/exam/api/dto/StartExamDto.java
+54
-0
Answer.java
...c/main/java/com/github/tangyi/exam/api/module/Answer.java
+13
-0
ExamRecord.java
...in/java/com/github/tangyi/exam/api/module/ExamRecord.java
+13
-0
Examination.java
...n/java/com/github/tangyi/exam/api/module/Examination.java
+0
-13
No files found.
README.md
View file @
fb1bdf99
...
...
@@ -2,6 +2,8 @@
交流QQ群:996208878
如果您觉得有帮助,请点右上角 "Star" 或者项目底部的“捐助”支持一下,谢谢!
## 简介
-
重写
[
spring-cloud-online-exam
](
https://gitee.com/wells2333/spring-cloud-online-exam
)
...
...
@@ -16,6 +18,12 @@
-
在线体验-后台:
[
http://www.it99.club:81
](
http://www.it99.club:81
)
默认账号:
1.
管理员:admin/123456
2.
学生:student/123456
3.
教师:teacher/123456
## 技术选型
-
服务注册与发现:
`Consul`
...
...
common/common-core/src/main/java/com/github/tangyi/common/core/constant/MqConstant.java
View file @
fb1bdf99
...
...
@@ -20,4 +20,9 @@ public class MqConstant {
* 刷新路由
*/
public
static
final
String
REFRESH_GATEWAY_ROUTE_QUEUE
=
"refresh_gateway_route_queue"
;
/**
* 提交考试
*/
public
static
final
String
SUBMIT_EXAMINATION_QUEUE
=
"submit_examination_queue"
;
}
common/common-core/src/main/java/com/github/tangyi/common/core/persistence/BaseEntity.java
View file @
fb1bdf99
package
com
.
github
.
tangyi
.
common
.
core
.
persistence
;
import
com.github.tangyi.common.core.constant.CommonConstant
;
import
com.github.tangyi.common.core.utils.DateUtils
;
import
com.github.tangyi.common.core.utils.IdGen
;
import
org.apache.commons.lang.StringUtils
;
import
java.io.Serializable
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.time.LocalDateTime
;
/**
* Entity基类
...
...
@@ -63,14 +63,15 @@ public class BaseEntity<T> implements Serializable {
* @param applicationCode 系统编号
*/
public
void
setCommonValue
(
String
userCode
,
String
applicationCode
)
{
String
currentDate
=
DateUtils
.
localDateToString
(
LocalDateTime
.
now
());
if
(
this
.
isNewRecord
())
{
this
.
setId
(
IdGen
.
snowflakeId
());
this
.
setNewRecord
(
true
);
this
.
creator
=
userCode
;
this
.
createDate
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
new
Date
())
;
this
.
createDate
=
currentDate
;
}
this
.
modifier
=
userCode
;
this
.
modifyDate
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
new
Date
())
;
this
.
modifyDate
=
currentDate
;
this
.
delFlag
=
0
;
this
.
applicationCode
=
applicationCode
;
}
...
...
common/common-core/src/main/java/com/github/tangyi/common/core/utils/DateUtils.java
0 → 100644
View file @
fb1bdf99
package
com
.
github
.
tangyi
.
common
.
core
.
utils
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
/**
* 日期工具类
*
* @author tangyi
* @date 2019/4/28 16:03
*/
public
class
DateUtils
{
private
static
final
DateTimeFormatter
FORMATTER
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
private
static
final
DateTimeFormatter
FORMATTER_MILLIS
=
DateTimeFormatter
.
ofPattern
(
"yyyyMMddhhmmssSSS"
);
/**
* 日期转string
*
* @param date date
* @return String
*/
public
static
String
localDateToString
(
LocalDateTime
date
)
{
return
date
!=
null
?
date
.
format
(
FORMATTER
)
:
""
;
}
/**
* 日期转string
*
* @param date date
* @return String
*/
public
static
String
localDateMillisToString
(
LocalDateTime
date
)
{
return
date
!=
null
?
date
.
format
(
FORMATTER_MILLIS
)
:
""
;
}
}
common/common-core/src/main/java/com/github/tangyi/common/core/utils/ExcelToolUtil.java
View file @
fb1bdf99
...
...
@@ -8,7 +8,9 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
/**
...
...
@@ -17,6 +19,10 @@ import java.util.*;
*/
public
class
ExcelToolUtil
{
private
static
final
DateTimeFormatter
FORMATTER
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
private
static
final
DateTimeFormatter
FORMATTER_DATE
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
/**
* 根据数据和标题封装excel数据输出流
*
...
...
@@ -36,10 +42,7 @@ public class ExcelToolUtil {
// 创建首行标题,设置高度
Row
rowHeader
=
sh
.
createRow
(
0
);
rowHeader
.
setHeightInPoints
(
16
);
Iterator
<
String
>
keys
=
keys2titlesMap
.
keySet
().
iterator
();
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
int
i
=
0
;
List
<
String
>
keyList
=
new
ArrayList
<
String
>();
while
(
keys
.
hasNext
())
{
...
...
@@ -71,11 +74,13 @@ public class ExcelToolUtil {
if
(
dataMap
.
get
(
key
)
instanceof
String
)
{
cell
.
setCellValue
(
MapUtil
.
getString
(
dataMap
,
key
));
}
else
if
(
dataMap
.
get
(
key
)
instanceof
Date
)
{
cell
.
setCellValue
(
simpleDateFormat
.
format
(
MapUtil
.
getDate
(
dataMap
,
key
)));
Date
date
=
MapUtil
.
getDate
(
dataMap
,
key
);
cell
.
setCellValue
(
date
==
null
?
""
:
FORMATTER
.
format
(
LocalDateTime
.
ofInstant
(
date
.
toInstant
(),
ZoneId
.
systemDefault
())));
}
else
if
(
dataMap
.
get
(
key
)
instanceof
Number
)
{
cell
.
setCellValue
(
MapUtil
.
getDouble
(
dataMap
,
key
));
}
else
if
(
dataMap
.
get
(
key
)
instanceof
Boolean
)
{
cell
.
setCellValue
(
MapUtil
.
getBooleanValue
(
dataMap
,
key
));
Boolean
value
=
MapUtil
.
getBooleanValue
(
dataMap
,
key
);
cell
.
setCellValue
(
value
==
null
?
Boolean
.
FALSE
:
value
);
}
}
else
if
(
key
.
contains
(
"."
))
{
// 标题的名称对应的可以是对象
...
...
@@ -214,7 +219,7 @@ public class ExcelToolUtil {
if
(
DateUtil
.
isCellDateFormatted
(
cell
))
{
// 用于转化为日期格式
Date
d
=
cell
.
getDateCellValue
();
map
.
put
(
keys
[
cellnum
],
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
(
d
));
map
.
put
(
keys
[
cellnum
],
FORMATTER_DATE
.
format
(
LocalDateTime
.
ofInstant
(
d
.
toInstant
(),
ZoneId
.
systemDefault
())
));
}
else
{
map
.
put
(
keys
[
cellnum
],
numToStringFormat
(
String
.
valueOf
(
cell
.
getNumericCellValue
())));
}
...
...
config-service/src/main/resources/config/auth-service.yml
View file @
fb1bdf99
...
...
@@ -2,13 +2,13 @@ server:
port
:
8090
spring
:
datasource
:
url
:
jdbc:mysql://${MYSQL_HOST:
192.168.0.144
}:${MYSQL_PORT:3306}/microservice-auth?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&characterEncoding=UTF-8
username
:
${MYSQL_USERNAME:
platform
}
url
:
jdbc:mysql://${MYSQL_HOST:
localhost
}:${MYSQL_PORT:3306}/microservice-auth?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&characterEncoding=UTF-8
username
:
${MYSQL_USERNAME:
root
}
password
:
${MYSQL_PASSWORD:11}
type
:
com.zaxxer.hikari.HikariDataSource
driver-class-name
:
com.mysql.jdbc.Driver
redis
:
host
:
${REDIS_HOST:
192.168.0.213
}
host
:
${REDIS_HOST:
localhost
}
port
:
${REDIS_PORT:6379}
rabbitmq
:
host
:
${RABBIT_HOST:localhost}
...
...
config-service/src/main/resources/config/exam-service.yml
View file @
fb1bdf99
...
...
@@ -2,13 +2,13 @@ server:
port
:
8098
spring
:
datasource
:
url
:
jdbc:mysql://${MYSQL_HOST:
192.168.0.144
}:${MYSQL_PORT:3306}/microservice-exam?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&characterEncoding=UTF-8
username
:
${MYSQL_USERNAME:
platform
}
url
:
jdbc:mysql://${MYSQL_HOST:
localhost
}:${MYSQL_PORT:3306}/microservice-exam?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&characterEncoding=UTF-8
username
:
${MYSQL_USERNAME:
root
}
password
:
${MYSQL_PASSWORD:11}
type
:
com.zaxxer.hikari.HikariDataSource
driver-class-name
:
com.mysql.jdbc.Driver
redis
:
host
:
${REDIS_HOST:
192.168.0.213
}
host
:
${REDIS_HOST:
localhost
}
port
:
${REDIS_PORT:6379}
rabbitmq
:
host
:
${RABBIT_HOST:localhost}
...
...
config-service/src/main/resources/config/gateway-service.yml
View file @
fb1bdf99
...
...
@@ -2,7 +2,7 @@ server:
port
:
8000
spring
:
redis
:
host
:
${REDIS_HOST:
192.168.0.213
}
host
:
${REDIS_HOST:
localhost
}
port
:
${REDIS_PORT:6379}
rabbitmq
:
host
:
${RABBIT_HOST:localhost}
...
...
@@ -68,8 +68,8 @@ preview:
enabled
:
${PREVIEW_ENABLED:
false
}
ignores
:
-
token
-
examRecord
-
save
OrUpdate
-
start
-
save
AndNext
-
register
-
submit
-
checkExist
...
...
config-service/src/main/resources/config/user-service.yml
View file @
fb1bdf99
...
...
@@ -8,13 +8,13 @@ spring:
# 单次请求的文件的总大小
max-request-size
:
100MB
datasource
:
url
:
jdbc:mysql://${MYSQL_HOST:
192.168.0.144
}:${MYSQL_PORT:3306}/microservice-user?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&characterEncoding=UTF-8
username
:
${MYSQL_USERNAME:
platform
}
url
:
jdbc:mysql://${MYSQL_HOST:
localhost
}:${MYSQL_PORT:3306}/microservice-user?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&characterEncoding=UTF-8
username
:
${MYSQL_USERNAME:
root
}
password
:
${MYSQL_PASSWORD:11}
type
:
com.zaxxer.hikari.HikariDataSource
driver-class-name
:
com.mysql.jdbc.Driver
redis
:
host
:
${REDIS_HOST:
192.168.0.213
}
host
:
${REDIS_HOST:
localhost
}
port
:
${REDIS_PORT:6379}
rabbitmq
:
host
:
${RABBIT_HOST:localhost}
...
...
@@ -79,11 +79,11 @@ fdfs:
width
:
150
height
:
150
tracker-list
:
#TrackerList参数,支持多个
-
${FDFS_HOST:1
92.168.0.9
5}:${FDFS_PORT:22122}
-
${FDFS_HOST:1
82.254.233.12
5}:${FDFS_PORT:22122}
# 系统配置
sys
:
fdfsHttpHost
:
${ATTACHMENT_HOST:http://1
92.168.0.9
5}:${ATTACHMENT_PORT:80}
# fastDfs的HTTP配置
fdfsHttpHost
:
${ATTACHMENT_HOST:http://1
82.254.233.12
5}:${ATTACHMENT_PORT:80}
# fastDfs的HTTP配置
uploadUrl
:
api/user/v1/attachment/upload
defaultAvatar
:
https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif?imageView2/1/w/80/h/80
...
...
doc/deploy/mysql/microservice-auth.sql
View file @
fb1bdf99
/*
Navicat Premium Data Transfer
Source Server :
144
Source Server :
mysql_localhost
Source Server Type : MySQL
Source Server Version : 50
710
Source Host :
192.168.0.144
:3306
Source Server Version : 50
617
Source Host :
localhost
:3306
Source Schema : microservice-auth
Target Server Type : MySQL
Target Server Version : 50
710
Target Server Version : 50
617
File Encoding : 65001
Date:
26/04/2019 23:22:30
Date:
03/05/2019 14:21:18
*/
SET
NAMES
utf8mb4
;
...
...
@@ -42,7 +42,7 @@ CREATE TABLE `oauth_client_details` (
`del_flag`
varchar
(
20
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'删除标记'
,
`application_code`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'系统编号'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Records of oauth_client_details
...
...
doc/deploy/mysql/microservice-exam.sql
View file @
fb1bdf99
/*
Navicat Premium Data Transfer
Source Server :
144
Source Server :
mysql_localhost
Source Server Type : MySQL
Source Server Version : 50
710
Source Host :
192.168.0.144
:3306
Source Server Version : 50
617
Source Host :
localhost
:3306
Source Schema : microservice-exam
Target Server Type : MySQL
Target Server Version : 50
710
Target Server Version : 50
617
File Encoding : 65001
Date:
26/04/2019 23:22:19
Date:
08/05/2019 22:28:38
*/
SET
NAMES
utf8mb4
;
...
...
@@ -36,8 +36,8 @@ CREATE TABLE `answer` (
`del_flag`
varchar
(
20
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'删除标记'
,
`application_code`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'系统编号'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
,
INDEX
`index_answer`
(
`user_id`
,
`examination_id`
,
`subject_id`
)
USING
BTREE
COMMENT
'答题索引'
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Dynamic
;
INDEX
`index_answer`
(
`user_id`
,
`examination_id`
,
`
exam_record_id`
,
`
subject_id`
)
USING
BTREE
COMMENT
'答题索引'
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Table structure for course
...
...
@@ -57,12 +57,13 @@ CREATE TABLE `course` (
`del_flag`
varchar
(
20
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'删除标记'
,
`application_code`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'系统编号'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Records of course
-- ----------------------------
INSERT
INTO
`course`
VALUES
(
'571449673634680832'
,
'大学语文'
,
'信息学院'
,
'软件工程'
,
'陈老师'
,
'大学语文'
,
'admin'
,
'2019-04-26 21:36:59'
,
'admin'
,
'2019-04-26 21:36:59'
,
'0'
,
'EXAM'
);
INSERT
INTO
`course`
VALUES
(
'573843243792470016'
,
'计算机基础'
,
'信息学院'
,
'软件工程'
,
''
,
''
,
'admin'
,
'2019-05-03 12:08:10'
,
'admin'
,
'2019-05-03 12:08:10'
,
'0'
,
'EXAM'
);
-- ----------------------------
-- Table structure for exam_record
...
...
@@ -79,6 +80,7 @@ CREATE TABLE `exam_record` (
`score`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'成绩'
,
`correct_number`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'正确题目数量'
,
`incorrect_number`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'错误题目数量'
,
`submit_status`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'提交状态 1-已提交 0-未提交'
,
`creator`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'创建人'
,
`create_date`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'创建时间'
,
`modifier`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'修改人'
,
...
...
@@ -86,7 +88,7 @@ CREATE TABLE `exam_record` (
`del_flag`
varchar
(
20
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'删除标记'
,
`application_code`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'系统编号'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Table structure for examination
...
...
@@ -116,13 +118,14 @@ CREATE TABLE `examination` (
`del_flag`
varchar
(
20
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'删除标记'
,
`application_code`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'系统编号'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Records of examination
-- ----------------------------
INSERT
INTO
`examination`
VALUES
(
'571450640874737664'
,
'四川省2016年普通高考文科综合能力测试-语文部分'
,
'0'
,
'注意事项:
\n
1.本试卷分第工卷(选择题)和第II卷(非选择题)两部分。答卷前,考生务必将白己的姓名、准考证号填写在答题卡上。
\n
2.回答第Ⅰ卷时,选出每小题答案后,用铅笔把答题卡上对应题目的答案标号涂黑。如需改动,用橡皮擦干净后,再选涂其它答案标号。写在本试卷上无效。
\n
3.回答第Ⅱ卷时,将答案写在答题卡上。写在本试卷上无效。
\n
4.考试结束后,将本试卷和答题卡一并交回。'
,
'2019-04-26 21:40'
,
'2019-04-26 23:50'
,
''
,
'48'
,
'12'
,
'0'
,
''
,
NULL
,
'信息学院'
,
'软件工程'
,
'571449673634680832'
,
'四川省2016年普通高考-文科综合能力测试'
,
'admin'
,
'2019-04-26 21:40:49'
,
'admin'
,
'2019-04-26 23:17:53'
,
'0'
,
'EXAM'
);
INSERT
INTO
`examination`
VALUES
(
'571460951203778560'
,
'四川省2016年普通高考文科综合能力测试-地理部分'
,
'0'
,
'本卷共35个小题,每小题4分,共140分。在每小题给出的四个选项中,只有一项是符合题目要求的。'
,
'2019-04-26 22:21'
,
'2019-04-26 22:21'
,
''
,
'200'
,
'0'
,
'0'
,
''
,
NULL
,
'信息学院'
,
'软件工程'
,
'571449673634680832'
,
'四川省2016年普通高考文科综合能力测试-地理部分'
,
'admin'
,
'2019-04-26 22:21:47'
,
'admin'
,
'2019-04-26 22:21:47'
,
'1'
,
'EXAM'
);
INSERT
INTO
`examination`
VALUES
(
'571450640874737664'
,
'四川省2016年普通高考文科综合能力测试-语文部分'
,
'0'
,
'注意事项:
\n
1.本试卷分第工卷(选择题)和第II卷(非选择题)两部分。答卷前,考生务必将白己的姓名、准考证号填写在答题卡上。
\n
2.回答第Ⅰ卷时,选出每小题答案后,用铅笔把答题卡上对应题目的答案标号涂黑。如需改动,用橡皮擦干净后,再选涂其它答案标号。写在本试卷上无效。
\n
3.回答第Ⅱ卷时,将答案写在答题卡上。写在本试卷上无效。
\n
4.考试结束后,将本试卷和答题卡一并交回。'
,
'2019-05-08 15:40'
,
'2019-05-08 23:40'
,
''
,
'48'
,
'12'
,
'0'
,
''
,
NULL
,
'信息学院'
,
'软件工程'
,
'571449673634680832'
,
'四川省2016年普通高考-文科综合能力测试'
,
'admin'
,
'2019-04-26 21:40:49'
,
'admin'
,
'2019-05-08 21:12:21'
,
'0'
,
'EXAM'
);
INSERT
INTO
`examination`
VALUES
(
'571460951203778560'
,
'四川省2016年普通高考文科综合能力测试-地理部分'
,
'0'
,
'本卷共35个小题,每小题4分,共140分。在每小题给出的四个选项中,只有一项是符合题目要求的。'
,
'2019-05-07 15:40'
,
'2019-05-07 23:40'
,
''
,
'200'
,
'0'
,
'0'
,
''
,
NULL
,
'信息学院'
,
'软件工程'
,
'571449673634680832'
,
'四川省2016年普通高考文科综合能力测试-地理部分'
,
'admin'
,
'2019-04-26 22:21:47'
,
'admin'
,
'2019-04-26 22:21:47'
,
'1'
,
'EXAM'
);
INSERT
INTO
`examination`
VALUES
(
'573841891515305984'
,
'全国计算机统考练习题10道'
,
'2'
,
'练习'
,
'2019-05-08 15:40'
,
'2019-05-08 23:40'
,
''
,
'40'
,
'10'
,
'0'
,
''
,
NULL
,
'测试学院'
,
'软件工程'
,
'573843243792470016'
,
'全国计算机统考练习题10道'
,
'admin'
,
'2019-05-03 12:02:48'
,
'admin'
,
'2019-05-08 21:12:10'
,
'0'
,
'EXAM'
);
-- ----------------------------
-- Table structure for incorrect_answer
...
...
@@ -134,7 +137,7 @@ CREATE TABLE `incorrect_answer` (
`examination_id`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'考试ID'
,
`exam_record_id`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'考试记录ID'
,
`subject_id`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'题目ID'
,
`serial_number`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'题目序号'
,
`serial_number`
int
(
64
)
NULL
DEFAULT
NULL
COMMENT
'题目序号'
,
`incorrect_answer`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'错误答案'
,
`creator`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'创建人'
,
`create_date`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'创建时间'
,
...
...
@@ -143,7 +146,7 @@ CREATE TABLE `incorrect_answer` (
`del_flag`
varchar
(
20
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'删除标记'
,
`application_code`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'系统编号'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Table structure for knowledge
...
...
@@ -162,7 +165,7 @@ CREATE TABLE `knowledge` (
`del_flag`
varchar
(
20
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'删除标记'
,
`application_code`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'系统编号'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Table structure for subject
...
...
@@ -192,12 +195,12 @@ CREATE TABLE `subject` (
`del_flag`
varchar
(
20
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'删除标记'
,
`application_code`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'系统编号'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Records of subject
-- ----------------------------
INSERT
INTO
`subject`
VALUES
(
'571452549010427904'
,
'571450640874737664'
,
1
,
'《小雅·鹿鸣
>
本是西周贵族宣扬宴飨之仪的乐歌,后扩散到民间,在乡人宴会上也可传唱。这表明西周时期'
,
'0'
,
''
,
'周人生活较为富足'
,
'礼乐文明得到广泛认同'
,
'乡人社会地位提高'
,
'贵族奢靡之风波及民间'
,
''
,
''
,
'B'
,
4
,
''
,
2
,
'admin'
,
'2019-04-26 21:48:24'
,
'admin'
,
'2019-04-26 21:48:24'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject`
VALUES
(
'571452549010427904'
,
'571450640874737664'
,
1
,
'《小雅·鹿鸣
》
本是西周贵族宣扬宴飨之仪的乐歌,后扩散到民间,在乡人宴会上也可传唱。这表明西周时期'
,
'0'
,
''
,
'周人生活较为富足'
,
'礼乐文明得到广泛认同'
,
'乡人社会地位提高'
,
'贵族奢靡之风波及民间'
,
''
,
''
,
'B'
,
4
,
''
,
2
,
'admin'
,
'2019-04-26 21:48:24'
,
'admin'
,
'2019-04-26 21:48:24'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject`
VALUES
(
'571453252617506816'
,
'571450640874737664'
,
2
,
'公元前 212 年,秦始皇坑杀“术士”,长子扶苏劝谏说:“远方黔首未集,诸生皆诵法孔子,今上皆重法绳之,臣恐天下不安,唯上察之”。这反映当时'
,
'0'
,
''
,
'统一进程曲折'
,
'地方治理不畅'
,
'始皇灭儒崇法'
,
'儒学影响较大'
,
''
,
''
,
'D'
,
4
,
''
,
2
,
'admin'
,
'2019-04-26 21:51:12'
,
'admin'
,
'2019-04-26 21:51:12'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject`
VALUES
(
'571453393525149696'
,
'571450640874737664'
,
3
,
'唐前期的政治人物多为北方人,北宋时政治人物多出生于江西、福建、苏南等地。
\n
这一变化主要反映了'
,
'0'
,
''
,
'官僚集团重视本地域人才'
,
'南北方士人志向差异'
,
'科举制改变人才地域分布'
,
'政治中心转移到南方'
,
''
,
''
,
'C'
,
4
,
''
,
2
,
'admin'
,
'2019-04-26 21:51:46'
,
'admin'
,
'2019-04-26 21:51:46'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject`
VALUES
(
'571453523254972416'
,
'571450640874737664'
,
5
,
'《荆楚岁时记》云:“社日,四邻并结宗会社,宰牲牢,为屋于树下,先祭神,然后食其胙。”据此可知,社日的民俗功能主要是'
,
'0'
,
''
,
'联谊乡邻'
,
'颂扬盛世'
,
'缅怀先祖'
,
'助危济困'
,
''
,
''
,
'A'
,
4
,
''
,
2
,
'admin'
,
'2019-04-26 21:52:17'
,
'admin'
,
'2019-04-26 22:08:03'
,
'0'
,
'EXAM'
);
...
...
@@ -210,6 +213,16 @@ INSERT INTO `subject` VALUES ('571458049324224512', '571450640874737664', 10, '1
INSERT
INTO
`subject`
VALUES
(
'571458149744250880'
,
'571450640874737664'
,
11
,
'1920–1921 年,苏俄许多工人流往农村,还有一些则自谋生路成了小手工业者。据此推知当时苏俄'
,
'0'
,
''
,
'战时共产主义政策有所突破'
,
'新经济政策成效显著'
,
'国营农庄吸引了大量劳动力'
,
'政府重视日用品生产'
,
''
,
''
,
'A'
,
4
,
''
,
2
,
'admin'
,
'2019-04-26 22:10:40'
,
'admin'
,
'2019-04-26 22:10:40'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject`
VALUES
(
'571458244669739008'
,
'571450640874737664'
,
12
,
'1964 年 6 月,美国《时代》杂志发表社论指出:“从北约到联合国,从拉丁美洲到红色中国,几乎在世界政治中的每一个问题或地区上,法国都采取和美国政策不一致的态度。”这一社论'
,
'0'
,
''
,
'揭示了法国倒向社会主义阵营'
,
'反映了法国推行独立外交'
,
'体现了两大阵营对抗趋于缓和'
,
'体现了两大阵营对抗趋于缓和'
,
''
,
''
,
'B'
,
4
,
''
,
2
,
'admin'
,
'2019-04-26 22:11:02'
,
'admin'
,
'2019-04-26 22:11:02'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject`
VALUES
(
'571461232968732672'
,
'571460951203778560'
,
1
,
'若下列城市都安装了“风光互补路灯”,北半球夏至日这一天太阳能板左右摆动幅度最大的地点是'
,
'0'
,
''
,
'哈尔滨'
,
'北京'
,
'广州'
,
'海口'
,
''
,
''
,
'A'
,
4
,
''
,
2
,
'admin'
,
'2019-04-26 22:22:55'
,
'admin'
,
'2019-04-26 22:22:55'
,
'1'
,
'EXAM'
);
INSERT
INTO
`subject`
VALUES
(
'573843792789114880'
,
'573841891515305984'
,
1
,
'自计算机问世至今已经经历了四个时代,划分时代的主要依据是计算机的_'
,
'0'
,
''
,
'规模'
,
'功能'
,
'性能'
,
'构成元件'
,
''
,
''
,
'D'
,
4
,
''
,
2
,
'admin'
,
'2019-05-03 12:10:21'
,
'admin'
,
'2019-05-03 12:10:21'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject`
VALUES
(
'573843833855545344'
,
'573841891515305984'
,
2
,
'第一台计算机是在1946年在美国诞生,该机的英文缩写是_'
,
'0'
,
''
,
'ENIAC'
,
'EDVAC'
,
'EDVAE'
,
'MARK'
,
''
,
''
,
'A'
,
4
,
''
,
2
,
'admin'
,
'2019-05-03 12:10:31'
,
'admin'
,
'2019-05-03 12:10:31'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject`
VALUES
(
'573843857750495232'
,
'573841891515305984'
,
3
,
'当前的计算机一般被认为是第四代计算机,它所采用的逻辑元件是_'
,
'0'
,
''
,
'集成电路'
,
'晶体管'
,
'大规模集成电路'
,
'电子管'
,
''
,
''
,
'C'
,
4
,
''
,
2
,
'admin'
,
'2019-05-03 12:10:37'
,
'admin'
,
'2019-05-03 12:10:37'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject`
VALUES
(
'573843879313412096'
,
'573841891515305984'
,
4
,
'当前计算机的应用最广泛的领域是_'
,
'0'
,
''
,
'辅助设计'
,
'科学计算'
,
'数据处理'
,
'过程控制'
,
''
,
''
,
'C'
,
4
,
''
,
2
,
'admin'
,
'2019-05-03 12:10:42'
,
'admin'
,
'2019-05-03 12:10:42'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject`
VALUES
(
'573843899269910528'
,
'573841891515305984'
,
5
,
'早期的计算机体积大、耗电多、速度慢,其主要原因是制约于_'
,
'0'
,
''
,
'元材料'
,
'工艺水平'
,
'设计水平'
,
'元器件'
,
''
,
''
,
'D'
,
4
,
''
,
2
,
'admin'
,
'2019-05-03 12:10:47'
,
'admin'
,
'2019-05-03 12:10:47'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject`
VALUES
(
'573843926826487808'
,
'573841891515305984'
,
6
,
'现代计算机之所以能够自动、连续地进行数据处理,主要是因为_'
,
'0'
,
''
,
'采用了开关电路'
,
'采用了半导体器件'
,
'采用了二进制'
,
'具有存储程序的功能'
,
''
,
''
,
'D'
,
4
,
''
,
2
,
'admin'
,
'2019-05-03 12:10:53'
,
'admin'
,
'2019-05-03 12:10:53'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject`
VALUES
(
'573843944526450688'
,
'573841891515305984'
,
7
,
'电子计算机按规模和处理能力划分,可以分为_'
,
'0'
,
''
,
'数字电子计算机和模拟电子计算机'
,
'通用计算机和专用计算机'
,
'巨型计算机、中小型计算机和微型计算机'
,
'科学与过程计算计算机、工业控制计算机和数据计算机'
,
''
,
''
,
'C'
,
4
,
''
,
2
,
'admin'
,
'2019-05-03 12:10:57'
,
'admin'
,
'2019-05-03 12:10:57'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject`
VALUES
(
'573843961102340096'
,
'573841891515305984'
,
8
,
'将计算机分为通用计算机、专用计算机两类的分类标准是_'
,
'0'
,
''
,
'计算机处理数据的方式'
,
'计算机使用范围'
,
'机器的规模'
,
'计算机的功能和处理能力'
,
''
,
''
,
'B'
,
4
,
''
,
2
,
'admin'
,
'2019-05-03 12:11:01'
,
'admin'
,
'2019-05-03 12:11:01'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject`
VALUES
(
'573843978617753600'
,
'573841891515305984'
,
9
,
'既可以接收、处理和输出模拟量,也可以接收、处理和输出数字量的计算机是_'
,
'0'
,
''
,
'电子数字计算机'
,
'电子模拟计算机'
,
'数模混合计算机'
,
'专用计算机'
,
''
,
''
,
'C'
,
4
,
''
,
2
,
'admin'
,
'2019-05-03 12:11:06'
,
'admin'
,
'2019-05-03 12:11:06'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject`
VALUES
(
'573843994983927808'
,
'573841891515305984'
,
10
,
'至今日,计算机仍采用存储程序原理,原理的提出者是_'
,
'0'
,
''
,
'莫尔'
,
'比尔·盖次'
,
'冯·诺依曼'
,
'科得'
,
''
,
''
,
'C'
,
4
,
''
,
2
,
'admin'
,
'2019-05-03 12:11:09'
,
'admin'
,
'2019-05-03 12:11:09'
,
'0'
,
'EXAM'
);
-- ----------------------------
-- Table structure for subject_bank
...
...
@@ -239,7 +252,7 @@ CREATE TABLE `subject_bank` (
`del_flag`
varchar
(
20
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'删除标记'
,
`application_code`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'系统编号'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
COMMENT
=
'题库表'
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
COMMENT
=
'题库表'
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Records of subject_bank
...
...
@@ -249,6 +262,16 @@ INSERT INTO `subject_bank` VALUES ('571467576304078848', '571450070935932928', 2
INSERT
INTO
`subject_bank`
VALUES
(
'571467771968360448'
,
'571450070935932928'
,
3
,
'我国干热岩最主要分布在'
,
'0'
,
''
,
'东南沿海'
,
'华北地区'
,
'西北内陆'
,
'青藏高原'
,
''
,
''
,
'D'
,
4
,
''
,
'2'
,
'admin'
,
'2019-04-26 22:48:54'
,
'admin'
,
'2019-04-26 22:52:01'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_bank`
VALUES
(
'571467945222475776'
,
'571450070935932928'
,
4
,
'与传统地热资源相比,干热岩'
,
'0'
,
''
,
'开发难度小、成本低'
,
'埋藏较浅、分布广'
,
'无季节变化、污染少'
,
'产业链短、效率低'
,
''
,
''
,
'C'
,
4
,
''
,
'2'
,
'admin'
,
'2019-04-26 22:49:35'
,
'admin'
,
'2019-04-26 22:52:15'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_bank`
VALUES
(
'571468124784824320'
,
'571450070935932928'
,
5
,
'草场恢复促使光伏发电量大增的最主要原因是'
,
'0'
,
''
,
'蒸发增强,湿度增加'
,
'气温升高,风力减小'
,
'沙尘减少,晴天增多'
,
'降水增加,气温降低'
,
''
,
''
,
'C'
,
4
,
''
,
'2'
,
'admin'
,
'2019-04-26 22:50:18'
,
'admin'
,
'2019-04-26 22:52:37'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_bank`
VALUES
(
'573839142304223232'
,
'573838899969921024'
,
1
,
'自计算机问世至今已经经历了四个时代,划分时代的主要依据是计算机的_'
,
'0'
,
''
,
'规模'
,
'功能'
,
'性能'
,
'构成元件'
,
''
,
''
,
'D'
,
4
,
''
,
'2'
,
'admin'
,
'2019-05-03 11:51:52'
,
'admin'
,
'2019-05-03 12:01:13'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_bank`
VALUES
(
'573839858523574272'
,
'573838899969921024'
,
2
,
'第一台计算机是在1946年在美国诞生,该机的英文缩写是_'
,
'0'
,
''
,
'ENIAC'
,
'EDVAC'
,
'EDVAE'
,
'MARK'
,
''
,
''
,
'A'
,
4
,
''
,
'2'
,
'admin'
,
'2019-05-03 11:54:43'
,
'admin'
,
'2019-05-03 11:54:43'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_bank`
VALUES
(
'573840018745987072'
,
'573838899969921024'
,
3
,
'当前的计算机一般被认为是第四代计算机,它所采用的逻辑元件是_'
,
'0'
,
''
,
'集成电路'
,
'晶体管'
,
'大规模集成电路'
,
'电子管'
,
''
,
''
,
'C'
,
4
,
''
,
'2'
,
'admin'
,
'2019-05-03 11:55:21'
,
'admin'
,
'2019-05-03 11:55:21'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_bank`
VALUES
(
'573840173176066048'
,
'573838899969921024'
,
4
,
'当前计算机的应用最广泛的领域是_'
,
'0'
,
''
,
'辅助设计'
,
'科学计算'
,
'数据处理'
,
'过程控制'
,
''
,
''
,
'C'
,
4
,
''
,
'2'
,
'admin'
,
'2019-05-03 11:55:58'
,
'admin'
,
'2019-05-03 11:55:58'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_bank`
VALUES
(
'573840411693551616'
,
'573838899969921024'
,
5
,
'早期的计算机体积大、耗电多、速度慢,其主要原因是制约于_'
,
'0'
,
''
,
'元材料'
,
'工艺水平'
,
'设计水平'
,
'元器件'
,
''
,
''
,
'D'
,
4
,
''
,
'2'
,
'admin'
,
'2019-05-03 11:56:55'
,
'admin'
,
'2019-05-03 11:56:55'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_bank`
VALUES
(
'573840623543652352'
,
'573838899969921024'
,
6
,
'现代计算机之所以能够自动、连续地进行数据处理,主要是因为_'
,
'0'
,
''
,
'采用了开关电路'
,
'采用了半导体器件'
,
'采用了二进制'
,
'具有存储程序的功能'
,
''
,
''
,
'D'
,
4
,
''
,
'2'
,
'admin'
,
'2019-05-03 11:57:46'
,
'admin'
,
'2019-05-03 11:57:46'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_bank`
VALUES
(
'573840833552453632'
,
'573838899969921024'
,
7
,
'电子计算机按规模和处理能力划分,可以分为_'
,
'0'
,
''
,
'数字电子计算机和模拟电子计算机'
,
'通用计算机和专用计算机'
,
'巨型计算机、中小型计算机和微型计算机'
,
'科学与过程计算计算机、工业控制计算机和数据计算机'
,
''
,
''
,
'C'
,
4
,
''
,
'2'
,
'admin'
,
'2019-05-03 11:58:36'
,
'admin'
,
'2019-05-03 11:58:36'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_bank`
VALUES
(
'573841001802764288'
,
'573838899969921024'
,
8
,
'将计算机分为通用计算机、专用计算机两类的分类标准是_'
,
'0'
,
''
,
'计算机处理数据的方式'
,
'计算机使用范围'
,
'机器的规模'
,
'计算机的功能和处理能力'
,
''
,
''
,
'B'
,
4
,
''
,
'2'
,
'admin'
,
'2019-05-03 11:59:16'
,
'admin'
,
'2019-05-03 11:59:16'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_bank`
VALUES
(
'573841215032791040'
,
'573838899969921024'
,
9
,
'既可以接收、处理和输出模拟量,也可以接收、处理和输出数字量的计算机是_'
,
'0'
,
''
,
'电子数字计算机'
,
'电子模拟计算机'
,
'数模混合计算机'
,
'专用计算机'
,
''
,
''
,
'C'
,
4
,
''
,
'2'
,
'admin'
,
'2019-05-03 12:00:07'
,
'admin'
,
'2019-05-03 12:00:07'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_bank`
VALUES
(
'573841445803397120'
,
'573838899969921024'
,
10
,
'至今日,计算机仍采用存储程序原理,原理的提出者是_'
,
'0'
,
''
,
'莫尔'
,
'比尔·盖次'
,
'冯·诺依曼'
,
'科得'
,
''
,
''
,
'C'
,
4
,
''
,
'2'
,
'admin'
,
'2019-05-03 12:01:02'
,
'admin'
,
'2019-05-03 12:01:02'
,
'0'
,
'EXAM'
);
-- ----------------------------
-- Table structure for subject_category
...
...
@@ -267,7 +290,7 @@ CREATE TABLE `subject_category` (
`del_flag`
varchar
(
20
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'删除标记'
,
`application_code`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'系统编号'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Records of subject_category
...
...
@@ -280,5 +303,6 @@ INSERT INTO `subject_category` VALUES ('571449994326970368', '数据结构', '
INSERT
INTO
`subject_category`
VALUES
(
'571450070935932928'
,
'地理'
,
'地理'
,
'-1'
,
'33'
,
'admin'
,
'2019-04-26 21:38:33'
,
'admin'
,
'2019-04-26 22:24:16'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_category`
VALUES
(
'571450122261630976'
,
'大学四级'
,
NULL
,
'571449792375427072'
,
'1'
,
'admin'
,
'2019-04-26 21:38:46'
,
'admin'
,
'2019-04-26 21:38:46'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_category`
VALUES
(
'571450172626833408'
,
'大学六级'
,
'大学六级'
,
'571449792375427072'
,
'2'
,
'admin'
,
'2019-04-26 21:38:58'
,
'admin'
,
'2019-04-26 21:38:58'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_category`
VALUES
(
'573838899969921024'
,
'计算机基础'
,
NULL
,
'571449735345475584'
,
'4'
,
'admin'
,
'2019-05-03 11:50:55'
,
'admin'
,
'2019-05-03 11:50:55'
,
'0'
,
'EXAM'
);
SET
FOREIGN_KEY_CHECKS
=
1
;
doc/deploy/mysql/microservice-user.sql
View file @
fb1bdf99
/*
Navicat Premium Data Transfer
Source Server :
144
Source Server :
mysql_localhost
Source Server Type : MySQL
Source Server Version : 50
710
Source Host :
192.168.0.144
:3306
Source Server Version : 50
617
Source Host :
localhost
:3306
Source Schema : microservice-user
Target Server Type : MySQL
Target Server Version : 50
710
Target Server Version : 50
617
File Encoding : 65001
Date:
26/04/2019 23:21:27
Date:
08/05/2019 22:29:02
*/
SET
NAMES
utf8mb4
;
...
...
@@ -37,7 +37,7 @@ CREATE TABLE `sys_attachment` (
`del_flag`
varchar
(
20
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
COMMENT
'删除标记'
,
`application_code`
varchar
(
64
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
COMMENT
'系统编号'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Records of sys_attachment
...
...
@@ -65,7 +65,7 @@ CREATE TABLE `sys_dept` (
`dept_desc`
varchar
(
255
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
COMMENT
'部门描述'
,
`dept_leader`
varchar
(
255
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
COMMENT
'部门负责人'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Records of sys_dept
...
...
@@ -95,7 +95,7 @@ CREATE TABLE `sys_log` (
`del_flag`
varchar
(
20
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
COMMENT
'删除标记'
,
`application_code`
varchar
(
64
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
COMMENT
'系统编号'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Table structure for sys_menu
...
...
@@ -121,7 +121,7 @@ CREATE TABLE `sys_menu` (
`redirect`
varchar
(
255
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
COMMENT
'重定向url'
,
`remark`
varchar
(
255
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Records of sys_menu
...
...
@@ -216,7 +216,7 @@ CREATE TABLE `sys_role` (
`application_code`
varchar
(
64
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
COMMENT
'系统编号'
,
`status`
varchar
(
20
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NOT
NULL
COMMENT
'状态 0-启用,1-禁用'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Records of sys_role
...
...
@@ -234,7 +234,7 @@ CREATE TABLE `sys_role_dept` (
`role_id`
varchar
(
64
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
,
`dept_id`
varchar
(
64
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Records of sys_role_dept
...
...
@@ -252,7 +252,7 @@ CREATE TABLE `sys_role_menu` (
`role_id`
varchar
(
64
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
,
`menu_id`
varchar
(
64
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Records of sys_role_menu
...
...
@@ -381,7 +381,7 @@ CREATE TABLE `sys_route` (
`del_flag`
varchar
(
20
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'删除标记'
,
`application_code`
varchar
(
64
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'系统编号'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Records of sys_route
...
...
@@ -416,7 +416,7 @@ CREATE TABLE `sys_user` (
`remark`
varchar
(
255
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
COMMENT
'备注'
,
`dept_id`
varchar
(
64
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
COMMENT
'部门ID'
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Records of sys_user
...
...
@@ -434,7 +434,7 @@ CREATE TABLE `sys_user_role` (
`user_id`
varchar
(
64
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
,
`role_id`
varchar
(
64
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_general_ci
NULL
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Dynamic
;
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_general_ci
ROW_FORMAT
=
Compact
;
-- ----------------------------
-- Records of sys_user_role
...
...
docker-compose.env
View file @
fb1bdf99
...
...
@@ -16,17 +16,17 @@ REDIS_HOST=redis
REDIS_PORT=6379
// 数据库配置
MYSQL_HOST=
192.168.0.144
MYSQL_HOST=
localhost
MYSQL_PORT=3306
MYSQL_USERNAME=platform
MYSQL_PASSWORD=11
// FDFS配置
FDFS_HOST=
192.168.0.95
FDFS_HOST=
localhost
FDFS_PORT=22122
// 附件服务器配置
ATTACHMENT_HOST=http://
192.168.0.95
ATTACHMENT_HOST=http://
localhost
ATTACHMENT_PORT=80
// 各服务host配置
...
...
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/config/ExaminationInitConfig.java
0 → 100644
View file @
fb1bdf99
package
com
.
github
.
tangyi
.
exam
.
config
;
import
com.github.tangyi.common.core.constant.CommonConstant
;
import
com.github.tangyi.exam.api.module.Examination
;
import
com.github.tangyi.exam.service.ExaminationService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
javax.annotation.PostConstruct
;
import
java.util.Optional
;
import
java.util.stream.Stream
;
/**
* 考试初始化
* 启动时加载已发布的考试到缓存
*
* @author tangyi
* @date 2019/4/30 16:02
*/
@Configuration
public
class
ExaminationInitConfig
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ExaminationInitConfig
.
class
);
@Autowired
private
RedisTemplate
redisTemplate
;
@Autowired
private
ExaminationService
examinationService
;
@PostConstruct
public
void
initExamination
()
{
logger
.
info
(
"开始加载考试信息."
);
// 查询已发布的考试
Examination
examination
=
new
Examination
();
examination
.
setStatus
(
CommonConstant
.
STATUS_NORMAL
);
Stream
<
Examination
>
examinationStream
=
examinationService
.
findList
(
examination
).
stream
();
if
(
Optional
.
ofNullable
(
examinationStream
).
isPresent
())
examinationStream
.
forEach
(
tempExamination
->
redisTemplate
.
opsForValue
().
set
(
"examination::"
+
tempExamination
.
getId
(),
tempExamination
));
logger
.
info
(
"考试信息加载完成."
);
}
}
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/config/RabbitSubmitExaminationConfig.java
0 → 100644
View file @
fb1bdf99
package
com
.
github
.
tangyi
.
exam
.
config
;
import
com.github.tangyi.common.core.constant.MqConstant
;
import
org.springframework.amqp.core.Queue
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* MQ配置
*
* @author tangyi
* @date 2019/5/3 14:53
*/
@Configuration
public
class
RabbitSubmitExaminationConfig
{
/**
* 提交考试队列
*
* @return Queue
*/
@Bean
public
Queue
submitExaminationQueue
()
{
return
new
Queue
(
MqConstant
.
SUBMIT_EXAMINATION_QUEUE
);
}
}
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/controller/AnswerController.java
View file @
fb1bdf99
...
...
@@ -8,8 +8,10 @@ import com.github.tangyi.common.core.utils.SysUtil;
import
com.github.tangyi.common.core.web.BaseController
;
import
com.github.tangyi.common.log.annotation.Log
;
import
com.github.tangyi.common.security.utils.SecurityUtil
;
import
com.github.tangyi.exam.api.dto.SubjectDto
;
import
com.github.tangyi.exam.api.module.Answer
;
import
com.github.tangyi.exam.service.AnswerService
;
import
com.github.tangyi.exam.service.SubjectService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
...
...
@@ -17,7 +19,6 @@ import io.swagger.annotations.ApiOperation;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -38,6 +39,9 @@ public class AnswerController extends BaseController {
@Autowired
private
AnswerService
answerService
;
@Autowired
private
SubjectService
subjectService
;
/**
* 根据ID获取
*
...
...
@@ -155,24 +159,27 @@ public class AnswerController extends BaseController {
* @author tangyi
* @date 2018/12/24 20:06
*/
@PostMapping
(
"save
OrUpdate
"
)
@PostMapping
(
"save"
)
@ApiOperation
(
value
=
"保存答题"
,
notes
=
"保存答题"
)
@ApiImplicitParam
(
name
=
"answer"
,
value
=
"答题信息"
,
dataType
=
"Answer"
)
@Log
(
"保存答题"
)
public
ResponseBean
<
Boolean
>
saveOrUpdate
(
@RequestBody
Answer
answer
)
{
boolean
success
;
Answer
search
=
new
Answer
();
BeanUtils
.
copyProperties
(
answer
,
search
);
search
=
answerService
.
getAnswer
(
search
);
if
(
search
==
null
)
{
answer
.
setCommonValue
(
SecurityUtil
.
getCurrentUsername
(),
SysUtil
.
getSysCode
());
success
=
answerService
.
insert
(
answer
)
>
0
;
}
else
{
search
.
setCommonValue
(
SecurityUtil
.
getCurrentUsername
(),
SysUtil
.
getSysCode
());
search
.
setAnswer
(
answer
.
getAnswer
());
success
=
answerService
.
update
(
search
)
>
0
;
public
ResponseBean
<
Boolean
>
save
(
@RequestBody
Answer
answer
)
{
return
new
ResponseBean
<>(
answerService
.
save
(
answer
)
>
0
);
}
return
new
ResponseBean
<>(
success
);
/**
* 保存答题,返回下一题信息
*
* @param answer answer
* @return ResponseBean
* @author tangyi
* @date 2019/04/30 18:06
*/
@PostMapping
(
"saveAndNext"
)
@ApiOperation
(
value
=
"保存答题"
,
notes
=
"保存答题"
)
@ApiImplicitParam
(
name
=
"answer"
,
value
=
"答题信息"
,
dataType
=
"Answer"
)
public
ResponseBean
<
SubjectDto
>
saveAndNext
(
@RequestBody
Answer
answer
)
{
return
new
ResponseBean
<>(
answerService
.
saveAndNext
(
answer
));
}
/**
...
...
@@ -188,6 +195,6 @@ public class AnswerController extends BaseController {
@ApiImplicitParam
(
name
=
"answer"
,
value
=
"答卷信息"
,
dataType
=
"Answer"
)
@Log
(
"提交答题"
)
public
ResponseBean
<
Boolean
>
submit
(
@RequestBody
Answer
answer
)
{
return
new
ResponseBean
<>(
answerService
.
submit
(
answer
));
return
new
ResponseBean
<>(
answerService
.
submit
Async
(
answer
));
}
}
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/controller/ExamRecordController.java
View file @
fb1bdf99
...
...
@@ -12,6 +12,7 @@ import com.github.tangyi.common.log.annotation.Log;
import
com.github.tangyi.common.security.constant.SecurityConstant
;
import
com.github.tangyi.common.security.utils.SecurityUtil
;
import
com.github.tangyi.exam.api.dto.ExamRecordDto
;
import
com.github.tangyi.exam.api.dto.StartExamDto
;
import
com.github.tangyi.exam.api.module.ExamRecord
;
import
com.github.tangyi.exam.api.module.Examination
;
import
com.github.tangyi.exam.service.ExamRecordService
;
...
...
@@ -34,8 +35,11 @@ import org.springframework.web.bind.annotation.*;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Stream
;
/**
...
...
@@ -136,6 +140,11 @@ public class ExamRecordController extends BaseController {
examRecordDto
.
setEndTime
(
tempExamRecord
.
getEndTime
());
examRecordDto
.
setScore
(
tempExamRecord
.
getScore
());
examRecordDto
.
setUserId
(
tempExamRecord
.
getUserId
());
// 正确题目数
examRecordDto
.
setCorrectNumber
(
tempExamRecord
.
getCorrectNumber
());
examRecordDto
.
setInCorrectNumber
(
tempExamRecord
.
getInCorrectNumber
());
// 提交状态
examRecordDto
.
setSubmitStatus
(
tempExamRecord
.
getSubmitStatus
());
examRecordDtoList
.
add
(
examRecordDto
);
}
});
...
...
@@ -265,7 +274,7 @@ public class ExamRecordController extends BaseController {
// 配置response
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"multipart/form-data"
);
response
.
setHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
Servlets
.
getDownName
(
request
,
"考试成绩"
+
new
SimpleDateFormat
(
"yyyyMMddhhmmssSSS"
).
format
(
new
Date
())
+
".xlsx"
));
response
.
setHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
Servlets
.
getDownName
(
request
,
"考试成绩"
+
DateUtils
.
localDateMillisToString
(
LocalDateTime
.
now
())
+
".xlsx"
));
List
<
ExamRecord
>
examRecordList
;
if
(
StringUtils
.
isNotEmpty
(
examRecordDto
.
getIdString
()))
{
ExamRecord
examRecord
=
new
ExamRecord
();
...
...
@@ -339,4 +348,30 @@ public class ExamRecordController extends BaseController {
logger
.
error
(
"导出成绩数据失败!"
,
e
);
}
}
/**
* 开始考试
*
* @param examRecord examRecord
* @return ResponseBean
* @author tangyi
* @date 2019/04/30 16:45
*/
@PostMapping
(
"start"
)
@Log
(
"开始考试"
)
public
ResponseBean
<
StartExamDto
>
start
(
@RequestBody
ExamRecord
examRecord
)
{
return
new
ResponseBean
<>(
examRecordService
.
start
(
examRecord
));
}
/**
* 获取服务器当前时间
*
* @return ResponseBean
* @author tangyi
* @date 2019/05/07 22:03
*/
@GetMapping
(
"currentTime"
)
public
ResponseBean
<
String
>
currentTime
()
{
return
new
ResponseBean
<>(
DateUtils
.
localDateToString
(
LocalDateTime
.
now
()));
}
}
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/controller/ExaminationController.java
View file @
fb1bdf99
...
...
@@ -3,6 +3,7 @@ package com.github.tangyi.exam.controller;
import
com.github.pagehelper.PageInfo
;
import
com.github.tangyi.common.core.constant.CommonConstant
;
import
com.github.tangyi.common.core.model.ResponseBean
;
import
com.github.tangyi.common.core.utils.DateUtils
;
import
com.github.tangyi.common.core.utils.PageUtil
;
import
com.github.tangyi.common.core.utils.SysUtil
;
import
com.github.tangyi.common.core.web.BaseController
;
...
...
@@ -27,8 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -67,9 +67,6 @@ public class ExaminationController extends BaseController {
if
(
StringUtils
.
isNotBlank
(
id
))
{
examination
.
setId
(
id
);
examination
=
examinationService
.
get
(
examination
);
// 获取当前时间
if
(
examination
!=
null
)
examination
.
setCurrentTime
(
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
new
Date
()));
}
return
new
ResponseBean
<>(
examination
);
}
...
...
@@ -108,17 +105,12 @@ public class ExaminationController extends BaseController {
// 流处理获取课程ID集合,转成字符串数组
course
.
setIds
(
page
.
getList
().
stream
().
map
(
Examination:
:
getCourseId
).
distinct
().
toArray
(
String
[]::
new
));
List
<
Course
>
courses
=
courseService
.
findListById
(
course
);
// 当前时间
String
currentTime
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
new
Date
());
// 流处理转成Dto集合
List
<
ExaminationDto
>
examinationDtos
=
page
.
getList
().
stream
().
map
(
exam
->
{
ExaminationDto
examinationDto
=
new
ExaminationDto
();
BeanUtils
.
copyProperties
(
exam
,
examinationDto
);
examinationDto
.
setCurrentTime
(
currentTime
);
// 设置考试所属课程
Course
examinationCourse
=
courses
.
stream
().
filter
(
tempCourse
->
tempCourse
.
getId
().
equals
(
exam
.
getCourseId
())).
findFirst
().
orElse
(
null
);
if
(
examinationCourse
!=
null
)
examinationDto
.
setCourse
(
examinationCourse
);
courses
.
stream
().
filter
(
tempCourse
->
tempCourse
.
getId
().
equals
(
exam
.
getCourseId
())).
findFirst
().
ifPresent
(
examinationDto:
:
setCourse
);
return
examinationDto
;
}).
collect
(
Collectors
.
toList
());
examinationDtoPageInfo
.
setList
(
examinationDtos
);
...
...
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/controller/IncorrectAnswerController.java
View file @
fb1bdf99
...
...
@@ -116,6 +116,9 @@ public class IncorrectAnswerController extends BaseController {
});
}
}
pageInfo
.
setPageSize
(
incorrectAnswerPageInfo
.
getPageSize
());
pageInfo
.
setPageNum
(
incorrectAnswerPageInfo
.
getPageNum
());
pageInfo
.
setTotal
(
incorrectAnswerPageInfo
.
getTotal
());
pageInfo
.
setList
(
incorrectAnswerDtoList
);
return
pageInfo
;
}
...
...
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/controller/SubjectBankController.java
View file @
fb1bdf99
...
...
@@ -27,9 +27,8 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.t
ext.SimpleDateFormat
;
import
java.t
ime.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
/**
...
...
@@ -201,7 +200,7 @@ public class SubjectBankController extends BaseController {
// 配置response
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"multipart/form-data"
);
response
.
setHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
Servlets
.
getDownName
(
request
,
"题目信息"
+
new
SimpleDateFormat
(
"yyyyMMddhhmmssSSS"
).
format
(
new
Date
())
+
".xlsx"
));
response
.
setHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
Servlets
.
getDownName
(
request
,
"题目信息"
+
DateUtils
.
localDateMillisToString
(
LocalDateTime
.
now
())
+
".xlsx"
));
List
<
SubjectBank
>
subjectBanks
=
new
ArrayList
<>();
// 根据题目id导出
if
(
StringUtils
.
isNotEmpty
(
subjectBankDto
.
getIdString
()))
{
...
...
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/controller/SubjectController.java
View file @
fb1bdf99
...
...
@@ -9,8 +9,6 @@ import com.github.tangyi.common.log.annotation.Log;
import
com.github.tangyi.common.security.constant.SecurityConstant
;
import
com.github.tangyi.common.security.utils.SecurityUtil
;
import
com.github.tangyi.exam.api.dto.SubjectDto
;
import
com.github.tangyi.exam.api.module.Answer
;
import
com.github.tangyi.exam.api.module.ExamRecord
;
import
com.github.tangyi.exam.api.module.Examination
;
import
com.github.tangyi.exam.api.module.Subject
;
import
com.github.tangyi.exam.service.AnswerService
;
...
...
@@ -20,11 +18,9 @@ import com.github.tangyi.exam.service.SubjectService;
import
com.github.tangyi.exam.utils.SubjectUtil
;
import
com.google.common.net.HttpHeaders
;
import
io.swagger.annotations.*
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -32,8 +28,11 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
...
...
@@ -210,7 +209,7 @@ public class SubjectController extends BaseController {
// 配置response
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"multipart/form-data"
);
response
.
setHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
Servlets
.
getDownName
(
request
,
"题目信息"
+
new
SimpleDateFormat
(
"yyyyMMddhhmmssSSS"
).
format
(
new
Date
())
+
".xlsx"
));
response
.
setHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
Servlets
.
getDownName
(
request
,
"题目信息"
+
DateUtils
.
localDateMillisToString
(
LocalDateTime
.
now
())
+
".xlsx"
));
List
<
Subject
>
subjects
=
new
ArrayList
<>();
// 根据题目id导出
if
(
StringUtils
.
isNotEmpty
(
subjectDto
.
getIdString
()))
{
...
...
@@ -336,35 +335,6 @@ public class SubjectController extends BaseController {
public
ResponseBean
<
SubjectDto
>
subjectAnswer
(
@RequestParam
(
"serialNumber"
)
String
serialNumber
,
@RequestParam
(
"examRecordId"
)
String
examRecordId
,
@RequestParam
(
value
=
"userId"
,
required
=
false
)
String
userId
)
{
SubjectDto
subjectDto
=
null
;
ExamRecord
examRecord
=
new
ExamRecord
();
examRecord
.
setId
(
examRecordId
);
// 查找考试记录
examRecord
=
examRecordService
.
get
(
examRecord
);
if
(
examRecord
!=
null
)
{
// 查找题目
Subject
subject
=
new
Subject
();
subject
.
setExaminationId
(
examRecord
.
getExaminationId
());
subject
.
setSerialNumber
(
serialNumber
);
subject
=
subjectService
.
getByExaminationIdAndSerialNumber
(
subject
);
if
(
subject
!=
null
)
{
subjectDto
=
new
SubjectDto
();
// 查找答题
Answer
answer
=
new
Answer
();
answer
.
setSubjectId
(
subject
.
getId
());
answer
.
setExaminationId
(
examRecord
.
getExaminationId
());
answer
.
setExamRecordId
(
examRecordId
);
answer
.
setUserId
(
userId
);
List
<
Answer
>
answerList
=
answerService
.
findList
(
answer
);
if
(
answerList
!=
null
&&
answerList
.
size
()
==
1
)
{
answer
=
answerList
.
get
(
0
);
}
BeanUtils
.
copyProperties
(
subject
,
subjectDto
);
// 设置答题
subjectDto
.
setAnswer
(
answer
);
subjectDto
.
setExaminationRecordId
(
examRecordId
);
}
}
return
new
ResponseBean
<>(
subjectDto
);
return
new
ResponseBean
<>(
subjectService
.
subjectAnswer
(
serialNumber
,
examRecordId
,
userId
));
}
}
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/mapper/AnswerMapper.java
View file @
fb1bdf99
...
...
@@ -15,6 +15,7 @@ public interface AnswerMapper extends CrudMapper<Answer> {
/**
* 根据用户ID、考试ID、考试记录ID、题目ID查找答题
*
* @param answer answer
* @return Answer
* @author tangyi
...
...
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/mq/RabbitSubmitExaminationReceiver.java
0 → 100644
View file @
fb1bdf99
package
com
.
github
.
tangyi
.
exam
.
mq
;
import
com.github.tangyi.common.core.constant.MqConstant
;
import
com.github.tangyi.common.core.exceptions.CommonException
;
import
com.github.tangyi.exam.api.constants.ExamRecordConstant
;
import
com.github.tangyi.exam.api.module.Answer
;
import
com.github.tangyi.exam.api.module.ExamRecord
;
import
com.github.tangyi.exam.service.AnswerService
;
import
com.github.tangyi.exam.service.ExamRecordService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
* 提交考试消息消费者
*
* @author tangyi
* @date 2019/5/3 14:55
*/
@Service
public
class
RabbitSubmitExaminationReceiver
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RabbitSubmitExaminationReceiver
.
class
);
@Autowired
private
AnswerService
answerService
;
@Autowired
private
ExamRecordService
examRecordService
;
/**
* 处理提交考试逻辑:统计错题,计算成绩等
* 1. 先更新考试记录的状态为正在计算
* 2. 更新成功则执行提交逻辑
*
* @param answer answer
* @author tangyi
* @date 2019/05/03 14:56
*/
@RabbitListener
(
queues
=
{
MqConstant
.
SUBMIT_EXAMINATION_QUEUE
})
public
void
submitExamination
(
Answer
answer
)
{
logger
.
debug
(
"处理考试提交ID:{}, 提交人:{}"
,
answer
.
getExamRecordId
(),
answer
.
getModifier
());
try
{
ExamRecord
examRecord
=
new
ExamRecord
();
examRecord
.
setId
(
answer
.
getExamRecordId
());
examRecord
=
examRecordService
.
get
(
examRecord
);
if
(
examRecord
==
null
)
return
;
if
(
ExamRecordConstant
.
STATUS_NOT_SUBMITTED
.
equals
(
examRecord
.
getSubmitStatus
()))
logger
.
warn
(
"考试:{}未提交"
,
examRecord
.
getId
());
if
(
ExamRecordConstant
.
STATUS_CALCULATE
.
equals
(
examRecord
.
getSubmitStatus
()))
logger
.
warn
(
"考试:{}正在统计成绩,请勿重复提交"
,
examRecord
.
getId
());
// 更新状态为正在统计
examRecord
.
setSubmitStatus
(
ExamRecordConstant
.
STATUS_CALCULATE
);
// 更新成功
if
(
examRecordService
.
update
(
examRecord
)
>
0
)
{
logger
.
debug
(
"考试:{}更新状态为正在统计成功"
,
examRecord
.
getId
());
answerService
.
submit
(
answer
);
}
else
{
logger
.
warn
(
"考试:{}更新状态为正在统计失败"
,
examRecord
.
getId
());
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/service/AnswerService.java
View file @
fb1bdf99
package
com
.
github
.
tangyi
.
exam
.
service
;
import
com.github.tangyi.common.core.constant.MqConstant
;
import
com.github.tangyi.common.core.service.CrudService
;
import
com.github.tangyi.common.core.utils.SysUtil
;
import
com.github.tangyi.common.security.utils.SecurityUtil
;
import
com.github.tangyi.exam.api.constants.ExamRecordConstant
;
import
com.github.tangyi.exam.api.dto.SubjectDto
;
import
com.github.tangyi.exam.api.module.Answer
;
import
com.github.tangyi.exam.api.module.ExamRecord
;
import
com.github.tangyi.exam.api.module.IncorrectAnswer
;
import
com.github.tangyi.exam.api.module.Subject
;
import
com.github.tangyi.exam.mapper.AnswerMapper
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.amqp.core.AmqpTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
...
...
@@ -28,6 +32,9 @@ import java.util.List;
public
class
AnswerService
extends
CrudService
<
AnswerMapper
,
Answer
>
{
@Autowired
private
AmqpTemplate
amqpTemplate
;
@Autowired
private
SubjectService
subjectService
;
@Autowired
...
...
@@ -108,8 +115,43 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
}
/**
* 保存
*
* @param answer answer
* @return int
* @author tangyi
* @date 2019/04/30 18:03
*/
@Transactional
public
int
save
(
Answer
answer
)
{
answer
.
setCommonValue
(
SecurityUtil
.
getCurrentUsername
(),
SysUtil
.
getSysCode
());
return
super
.
save
(
answer
);
}
/**
* 保存答题,返回下一题信息
*
* @param answer answer
* @return SubjectDto
* @author tangyi
* @date 2019/05/01 11:42
*/
@Transactional
public
SubjectDto
saveAndNext
(
Answer
answer
)
{
Answer
tempAnswer
=
this
.
getAnswer
(
answer
);
if
(
tempAnswer
!=
null
)
{
tempAnswer
.
setCommonValue
(
SecurityUtil
.
getCurrentUsername
(),
SysUtil
.
getSysCode
());
tempAnswer
.
setAnswer
(
answer
.
getAnswer
());
this
.
update
(
tempAnswer
);
}
else
{
answer
.
setCommonValue
(
SecurityUtil
.
getCurrentUsername
(),
SysUtil
.
getSysCode
());
this
.
insert
(
answer
);
}
return
subjectService
.
subjectAnswer
(
answer
.
getSerialNumber
(),
answer
.
getExamRecordId
(),
answer
.
getUserId
());
}
/**
* 提交答卷
* TODO 通过mq异步处理
*
* @param answer answer
* @return boolean
...
...
@@ -120,7 +162,7 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
public
boolean
submit
(
Answer
answer
)
{
long
start
=
System
.
currentTimeMillis
();
boolean
success
=
false
;
String
currentUsername
=
SecurityUtil
.
getCurrentUsername
();
String
currentUsername
=
answer
.
getModifier
();
// 查找已提交的题目
List
<
Answer
>
answerList
=
findList
(
answer
);
if
(
CollectionUtils
.
isNotEmpty
(
answerList
))
{
...
...
@@ -166,12 +208,14 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
});
// 保存成绩
ExamRecord
examRecord
=
new
ExamRecord
();
examRecord
.
setCommonValue
(
SecurityUtil
.
getCurrentUsername
()
,
SysUtil
.
getSysCode
());
examRecord
.
setCommonValue
(
currentUsername
,
SysUtil
.
getSysCode
());
examRecord
.
setId
(
answer
.
getExamRecordId
());
examRecord
.
setEndTime
(
examRecord
.
getCreateDate
());
examRecord
.
setScore
(
Integer
.
toString
(
totalScore
));
examRecord
.
setCorrectNumber
(
String
.
valueOf
(
rightScore
.
size
()));
examRecord
.
setInCorrectNumber
(
String
.
valueOf
(
incorrectAnswers
.
size
()));
// 更新状态为统计完成
examRecord
.
setSubmitStatus
(
ExamRecordConstant
.
STATUS_CALCULATED
);
success
=
examRecordService
.
update
(
examRecord
)
>
0
;
// 保存错题
ExamRecord
searchExamRecord
=
new
ExamRecord
();
...
...
@@ -189,4 +233,34 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
logger
.
debug
(
"提交答卷,用户名:{},考试ID:{},耗时:{}ms"
,
currentUsername
,
answer
.
getExaminationId
(),
System
.
currentTimeMillis
()
-
start
);
return
success
;
}
/**
* 通过mq异步处理
* 1. 先发送消息
* 2. 发送消息成功,更新提交状态,发送失败,返回提交失败
* 3. 消费消息,计算成绩
*
* @param answer answer
* @return boolean
* @author tangyi
* @date 2019/05/03 14:35
*/
@Transactional
public
boolean
submitAsync
(
Answer
answer
)
{
long
start
=
System
.
currentTimeMillis
();
String
currentUsername
=
SecurityUtil
.
getCurrentUsername
();
answer
.
setModifier
(
currentUsername
);
ExamRecord
examRecord
=
new
ExamRecord
();
examRecord
.
setCommonValue
(
currentUsername
,
SysUtil
.
getSysCode
());
examRecord
.
setId
(
answer
.
getExamRecordId
());
// 提交时间
examRecord
.
setEndTime
(
examRecord
.
getCreateDate
());
examRecord
.
setSubmitStatus
(
ExamRecordConstant
.
STATUS_SUBMITTED
);
// 1. 发送消息
amqpTemplate
.
convertAndSend
(
MqConstant
.
SUBMIT_EXAMINATION_QUEUE
,
answer
);
// 2. 更新考试状态
boolean
success
=
examRecordService
.
update
(
examRecord
)
>
0
;
logger
.
debug
(
"异步提交答卷成功,提交人:{},考试ID:{},耗时:{}ms"
,
currentUsername
,
answer
.
getExaminationId
(),
System
.
currentTimeMillis
()
-
start
);
return
success
;
}
}
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/service/ExamRecordService.java
View file @
fb1bdf99
package
com
.
github
.
tangyi
.
exam
.
service
;
import
com.github.tangyi.common.core.exceptions.CommonException
;
import
com.github.tangyi.common.core.service.CrudService
;
import
com.github.tangyi.exam.mapper.ExamRecordMapper
;
import
com.github.tangyi.common.core.utils.SysUtil
;
import
com.github.tangyi.common.security.utils.SecurityUtil
;
import
com.github.tangyi.exam.api.constants.ExamRecordConstant
;
import
com.github.tangyi.exam.api.constants.SubjectConstant
;
import
com.github.tangyi.exam.api.dto.StartExamDto
;
import
com.github.tangyi.exam.api.dto.SubjectDto
;
import
com.github.tangyi.exam.api.module.Answer
;
import
com.github.tangyi.exam.api.module.ExamRecord
;
import
com.github.tangyi.exam.api.module.Examination
;
import
com.github.tangyi.exam.api.module.Subject
;
import
com.github.tangyi.exam.mapper.ExamRecordMapper
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
...
...
@@ -17,6 +30,18 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public
class
ExamRecordService
extends
CrudService
<
ExamRecordMapper
,
ExamRecord
>
{
@Autowired
private
SubjectService
subjectService
;
@Autowired
private
AnswerService
answerService
;
@Autowired
private
ExamRecordService
examRecordService
;
@Autowired
private
ExaminationService
examinationService
;
/**
* 查询考试记录
*
...
...
@@ -87,4 +112,67 @@ public class ExamRecordService extends CrudService<ExamRecordMapper, ExamRecord>
public
int
deleteAll
(
String
[]
ids
)
{
return
super
.
deleteAll
(
ids
);
}
/**
* 开始考试
*
* @param examRecord examRecord
* @return StartExamDto
* @author tangyi
* @date 2019/04/30 23:06
*/
@Transactional
public
StartExamDto
start
(
ExamRecord
examRecord
)
{
StartExamDto
startExamDto
=
new
StartExamDto
();
String
currentUsername
=
SecurityUtil
.
getCurrentUsername
(),
applicationCode
=
SysUtil
.
getSysCode
();
// 创建考试记录
if
(
StringUtils
.
isEmpty
(
examRecord
.
getExaminationId
()))
throw
new
CommonException
(
"参数校验失败,考试id为空!"
);
if
(
StringUtils
.
isEmpty
(
examRecord
.
getUserId
()))
throw
new
CommonException
(
"参数校验失败,用户id为空!"
);
Examination
examination
=
new
Examination
();
examination
.
setId
(
examRecord
.
getExaminationId
());
// 查找考试信息
examination
=
examinationService
.
get
(
examination
);
if
(
examination
!=
null
)
{
examRecord
.
setExaminationName
(
examination
.
getExaminationName
());
examRecord
.
setCourseId
(
examination
.
getCourseId
());
}
examRecord
.
setCommonValue
(
currentUsername
,
applicationCode
);
examRecord
.
setStartTime
(
examRecord
.
getCreateDate
());
// 默认未提交状态
examRecord
.
setSubmitStatus
(
ExamRecordConstant
.
STATUS_NOT_SUBMITTED
);
// 保存考试记录
if
(
examRecordService
.
insert
(
examRecord
)
>
0
)
{
startExamDto
.
setExamination
(
examination
);
startExamDto
.
setExamRecord
(
examRecord
);
// 封装dto
SubjectDto
subjectDto
=
new
SubjectDto
();
startExamDto
.
setSubjectDto
(
subjectDto
);
// 查找第一题
Subject
subject
=
new
Subject
();
subject
.
setExaminationId
(
examRecord
.
getExaminationId
());
subject
.
setSerialNumber
(
SubjectConstant
.
DEFAULT_SERIAL_NUMBER
);
subject
=
subjectService
.
getByExaminationIdAndSerialNumber
(
subject
);
if
(
subject
==
null
)
throw
new
CommonException
(
"没有第一题"
);
// 获取题目信息
BeanUtils
.
copyProperties
(
subject
,
subjectDto
);
// 创建第一题的答题
Answer
answer
=
new
Answer
();
answer
.
setCommonValue
(
currentUsername
,
applicationCode
);
answer
.
setUserId
(
examRecord
.
getUserId
());
answer
.
setExaminationId
(
examRecord
.
getExaminationId
());
answer
.
setExamRecordId
(
examRecord
.
getId
());
answer
.
setSubjectId
(
subject
.
getId
());
// 默认题号为1
answer
.
setSerialNumber
(
subject
.
getSerialNumber
());
// 保存答题
answerService
.
save
(
answer
);
subjectDto
.
setAnswer
(
answer
);
}
return
startExamDto
;
}
}
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/service/ExaminationService.java
View file @
fb1bdf99
package
com
.
github
.
tangyi
.
exam
.
service
;
import
com.github.tangyi.common.core.service.CrudService
;
import
com.github.tangyi.exam.mapper.ExaminationMapper
;
import
com.github.tangyi.exam.api.module.Examination
;
import
com.github.tangyi.exam.api.module.Subject
;
import
com.github.tangyi.exam.mapper.ExaminationMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
...
...
@@ -89,6 +89,7 @@ public class ExaminationService extends CrudService<ExaminationMapper, Examinati
/**
* 查询考试数量
*
* @param examination examination
* @return int
* @author tangyi
...
...
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/service/SubjectService.java
View file @
fb1bdf99
package
com
.
github
.
tangyi
.
exam
.
service
;
import
com.github.tangyi.common.core.service.CrudService
;
import
com.github.tangyi.exam.mapper.SubjectMapper
;
import
com.github.tangyi.exam.api.dto.SubjectDto
;
import
com.github.tangyi.exam.api.module.Answer
;
import
com.github.tangyi.exam.api.module.ExamRecord
;
import
com.github.tangyi.exam.api.module.Subject
;
import
com.github.tangyi.exam.mapper.SubjectMapper
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
...
...
@@ -17,6 +22,12 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public
class
SubjectService
extends
CrudService
<
SubjectMapper
,
Subject
>
{
@Autowired
private
ExamRecordService
examRecordService
;
@Autowired
private
AnswerService
answerService
;
/**
* 查找题目
*
...
...
@@ -113,4 +124,46 @@ public class SubjectService extends CrudService<SubjectMapper, Subject> {
public
int
deleteAll
(
String
[]
ids
)
{
return
super
.
deleteAll
(
ids
);
}
/**
* 查询题目和答题
*
* @param serialNumber serialNumber
* @param examRecordId examRecordId
* @param userId userId
* @return SubjectDto
* @author tangyi
* @date 2019/04/30 17:10
*/
@Transactional
public
SubjectDto
subjectAnswer
(
String
serialNumber
,
String
examRecordId
,
String
userId
)
{
SubjectDto
subjectDto
=
null
;
ExamRecord
examRecord
=
new
ExamRecord
();
examRecord
.
setId
(
examRecordId
);
// 查找考试记录
examRecord
=
examRecordService
.
get
(
examRecord
);
if
(
examRecord
!=
null
)
{
// 查找题目
Subject
subject
=
new
Subject
();
subject
.
setExaminationId
(
examRecord
.
getExaminationId
());
subject
.
setSerialNumber
(
serialNumber
);
subject
=
this
.
getByExaminationIdAndSerialNumber
(
subject
);
if
(
subject
!=
null
)
{
subjectDto
=
new
SubjectDto
();
// 查找答题
Answer
answer
=
new
Answer
();
answer
.
setSubjectId
(
subject
.
getId
());
answer
.
setExaminationId
(
examRecord
.
getExaminationId
());
answer
.
setExamRecordId
(
examRecordId
);
answer
.
setUserId
(
userId
);
Answer
userAnswer
=
answerService
.
getAnswer
(
answer
);
// 设置答题
if
(
userAnswer
!=
null
)
subjectDto
.
setAnswer
(
userAnswer
);
BeanUtils
.
copyProperties
(
subject
,
subjectDto
);
subjectDto
.
setExaminationRecordId
(
examRecordId
);
}
}
return
subjectDto
;
}
}
service-api-impl/exam-service/src/main/resources/mapper/AnswerMapper.xml
View file @
fb1bdf99
...
...
@@ -67,7 +67,7 @@
and a.examination_id = #{examinationId}
and a.exam_record_id = #{examRecordId}
and a.subject_id = #{subjectId}
</select>
</select>
<select
id=
"findList"
resultMap=
"answerResultMap"
>
SELECT
...
...
service-api-impl/exam-service/src/main/resources/mapper/ExamRecodeMapper.xml
View file @
fb1bdf99
...
...
@@ -12,6 +12,7 @@
<result
column=
"score"
property=
"score"
/>
<result
column=
"correct_number"
property=
"correctNumber"
/>
<result
column=
"incorrect_number"
property=
"inCorrectNumber"
/>
<result
column=
"submit_status"
property=
"submitStatus"
/>
<result
column=
"creator"
property=
"creator"
/>
<result
column=
"create_date"
property=
"createDate"
/>
<result
column=
"modifier"
property=
"modifier"
/>
...
...
@@ -31,6 +32,7 @@
a.score,
a.correct_number,
a.incorrect_number,
a.submit_status,
a.creator,
a.create_date,
a.modifier,
...
...
@@ -53,6 +55,9 @@
<if
test=
"courseId != null and courseId != ''"
>
and a.course_id = #{courseId}
</if>
<if
test=
"submitStatus != null and submitStatus != ''"
>
and a.submit_status = #{submitStatus}
</if>
</sql>
<select
id=
"get"
resultMap=
"examRecordResultMap"
>
...
...
@@ -99,6 +104,7 @@
score,
correct_number,
incorrect_number,
submit_status,
creator,
create_date,
modifier,
...
...
@@ -116,6 +122,7 @@
#{score},
#{correctNumber},
#{inCorrectNumber},
#{submitStatus},
#{creator},
#{createDate},
#{modifier},
...
...
@@ -154,6 +161,9 @@
<if
test=
"inCorrectNumber != null"
>
incorrect_number = #{inCorrectNumber},
</if>
<if
test=
"submitStatus != null"
>
submit_status = #{submitStatus},
</if>
<if
test=
"delFlag != null"
>
del_flag = #{delFlag},
</if>
...
...
service-api-impl/user-service/src/main/java/com/github/tangyi/user/controller/MenuController.java
View file @
fb1bdf99
...
...
@@ -25,8 +25,11 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
...
...
@@ -264,7 +267,7 @@ public class MenuController extends BaseController {
// 配置response
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"multipart/form-data"
);
response
.
setHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
Servlets
.
getDownName
(
request
,
"菜单信息"
+
new
SimpleDateFormat
(
"yyyyMMddhhmmssSSS"
).
format
(
new
Date
())
+
".xlsx"
));
response
.
setHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
Servlets
.
getDownName
(
request
,
"菜单信息"
+
DateUtils
.
localDateMillisToString
(
LocalDateTime
.
now
())
+
".xlsx"
));
List
<
Menu
>
menus
;
// 导出所有
if
(
StringUtils
.
isEmpty
(
menuVo
.
getIdString
()))
{
...
...
service-api-impl/user-service/src/main/java/com/github/tangyi/user/controller/UserController.java
View file @
fb1bdf99
...
...
@@ -36,9 +36,8 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.security.Principal
;
import
java.t
ext.SimpleDateFormat
;
import
java.t
ime.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
...
...
@@ -304,7 +303,7 @@ public class UserController extends BaseController {
// 配置response
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"multipart/form-data"
);
response
.
setHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
Servlets
.
getDownName
(
request
,
"用户信息"
+
new
SimpleDateFormat
(
"yyyyMMddhhmmssSSS"
).
format
(
new
Date
())
+
".xlsx"
));
response
.
setHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
Servlets
.
getDownName
(
request
,
"用户信息"
+
DateUtils
.
localDateMillisToString
(
LocalDateTime
.
now
())
+
".xlsx"
));
List
<
User
>
users
;
if
(
StringUtils
.
isNotEmpty
(
userVo
.
getIdString
()))
{
User
user
=
new
User
();
...
...
service-api/exam-api/src/main/java/com/github/tangyi/exam/api/constants/ExamRecordConstant.java
0 → 100644
View file @
fb1bdf99
package
com
.
github
.
tangyi
.
exam
.
api
.
constants
;
/**
* @author tangyi
* @date 2019/5/3 14:41
*/
public
class
ExamRecordConstant
{
/**
* 未提交
*/
public
static
final
String
STATUS_NOT_SUBMITTED
=
"0"
;
/**
* 已提交
*/
public
static
final
String
STATUS_SUBMITTED
=
"1"
;
/**
* 正在统计
*/
public
static
final
String
STATUS_CALCULATE
=
"2"
;
/**
* 统计完成
*/
public
static
final
String
STATUS_CALCULATED
=
"3"
;
}
service-api/exam-api/src/main/java/com/github/tangyi/exam/api/constants/SubjectConstant.java
0 → 100644
View file @
fb1bdf99
package
com
.
github
.
tangyi
.
exam
.
api
.
constants
;
/**
* @author tangyi
* @date 2019/4/30 17:17
*/
public
class
SubjectConstant
{
/**
* 默认的题目序号
*/
public
static
final
String
DEFAULT_SERIAL_NUMBER
=
"1"
;
}
service-api/exam-api/src/main/java/com/github/tangyi/exam/api/dto/ExamRecordDto.java
View file @
fb1bdf99
...
...
@@ -105,6 +105,21 @@ public class ExamRecordDto extends BaseEntity<ExamRecordDto> {
*/
private
String
examTime
;
/**
* 错误题目数量
*/
private
String
inCorrectNumber
;
/**
* 正确题目数量
*/
private
String
correctNumber
;
/**
* 提交状态 1-已提交 0-未提交
*/
private
String
submitStatus
;
public
String
getExaminationName
()
{
return
examinationName
;
}
...
...
@@ -256,4 +271,28 @@ public class ExamRecordDto extends BaseEntity<ExamRecordDto> {
public
void
setExamTime
(
String
examTime
)
{
this
.
examTime
=
examTime
;
}
public
String
getSubmitStatus
()
{
return
submitStatus
;
}
public
void
setSubmitStatus
(
String
submitStatus
)
{
this
.
submitStatus
=
submitStatus
;
}
public
String
getInCorrectNumber
()
{
return
inCorrectNumber
;
}
public
void
setInCorrectNumber
(
String
inCorrectNumber
)
{
this
.
inCorrectNumber
=
inCorrectNumber
;
}
public
String
getCorrectNumber
()
{
return
correctNumber
;
}
public
void
setCorrectNumber
(
String
correctNumber
)
{
this
.
correctNumber
=
correctNumber
;
}
}
service-api/exam-api/src/main/java/com/github/tangyi/exam/api/dto/StartExamDto.java
0 → 100644
View file @
fb1bdf99
package
com
.
github
.
tangyi
.
exam
.
api
.
dto
;
import
com.github.tangyi.exam.api.module.ExamRecord
;
import
com.github.tangyi.exam.api.module.Examination
;
import
java.io.Serializable
;
/**
* @author tangyi
* @date 2019/4/30 16:54
*/
public
class
StartExamDto
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 考试记录信息
*/
private
ExamRecord
examRecord
;
/**
* 考试信息
*/
private
Examination
examination
;
/**
* 题目信息
*/
private
SubjectDto
subjectDto
;
public
ExamRecord
getExamRecord
()
{
return
examRecord
;
}
public
void
setExamRecord
(
ExamRecord
examRecord
)
{
this
.
examRecord
=
examRecord
;
}
public
Examination
getExamination
()
{
return
examination
;
}
public
void
setExamination
(
Examination
examination
)
{
this
.
examination
=
examination
;
}
public
SubjectDto
getSubjectDto
()
{
return
subjectDto
;
}
public
void
setSubjectDto
(
SubjectDto
subjectDto
)
{
this
.
subjectDto
=
subjectDto
;
}
}
service-api/exam-api/src/main/java/com/github/tangyi/exam/api/module/Answer.java
View file @
fb1bdf99
...
...
@@ -40,6 +40,11 @@ public class Answer extends BaseEntity<Answer> {
*/
private
String
answer
;
/**
* 下一题题目序号
*/
private
String
serialNumber
;
public
String
getUserId
()
{
return
userId
;
}
...
...
@@ -87,4 +92,12 @@ public class Answer extends BaseEntity<Answer> {
public
void
setExamRecordId
(
String
examRecordId
)
{
this
.
examRecordId
=
examRecordId
;
}
public
String
getSerialNumber
()
{
return
serialNumber
;
}
public
void
setSerialNumber
(
String
serialNumber
)
{
this
.
serialNumber
=
serialNumber
;
}
}
service-api/exam-api/src/main/java/com/github/tangyi/exam/api/module/ExamRecord.java
View file @
fb1bdf99
...
...
@@ -55,6 +55,11 @@ public class ExamRecord extends BaseEntity<ExamRecord> {
*/
private
String
correctNumber
;
/**
* 提交状态 1-已提交 0-未提交
*/
private
String
submitStatus
;
public
String
getUserId
()
{
return
userId
;
}
...
...
@@ -126,4 +131,12 @@ public class ExamRecord extends BaseEntity<ExamRecord> {
public
void
setCorrectNumber
(
String
correctNumber
)
{
this
.
correctNumber
=
correctNumber
;
}
public
String
getSubmitStatus
()
{
return
submitStatus
;
}
public
void
setSubmitStatus
(
String
submitStatus
)
{
this
.
submitStatus
=
submitStatus
;
}
}
service-api/exam-api/src/main/java/com/github/tangyi/exam/api/module/Examination.java
View file @
fb1bdf99
...
...
@@ -26,11 +26,6 @@ public class Examination extends BaseEntity<Examination> {
private
String
attention
;
/**
* 当前时间
*/
private
String
currentTime
;
/**
* 考试开始时间
*/
private
String
startTime
;
...
...
@@ -194,14 +189,6 @@ public class Examination extends BaseEntity<Examination> {
this
.
remark
=
remark
;
}
public
String
getCurrentTime
()
{
return
currentTime
;
}
public
void
setCurrentTime
(
String
currentTime
)
{
this
.
currentTime
=
currentTime
;
}
public
String
getTotalSubject
()
{
return
totalSubject
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment