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
9f6d0ba5
Commit
9f6d0ba5
authored
Apr 23, 2019
by
tangyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复bug、增加演示环境相关内容
parent
4fa72a58
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
166 additions
and
15 deletions
+166
-15
README.md
README.md
+2
-2
auth-service.yml
config-service/src/main/resources/config/auth-service.yml
+1
-0
exam-service.yml
config-service/src/main/resources/config/exam-service.yml
+1
-0
gateway-service.yml
config-service/src/main/resources/config/gateway-service.yml
+13
-0
user-service.yml
config-service/src/main/resources/config/user-service.yml
+1
-0
microservice-auth.sql
doc/deploy/mysql/microservice-auth.sql
+1
-1
microservice-exam.sql
doc/deploy/mysql/microservice-exam.sql
+12
-3
microservice-user.sql
doc/deploy/mysql/microservice-user.sql
+0
-0
docker-compose-base.yml
docker-compose-base.yml
+2
-1
docker-compose.env
docker-compose.env
+5
-2
PreviewConfig.java
.../java/com/github/tangyi/gateway/config/PreviewConfig.java
+31
-0
PreviewFilter.java
...java/com/github/tangyi/gateway/filters/PreviewFilter.java
+74
-0
SubjectBankController.java
.../github/tangyi/exam/controller/SubjectBankController.java
+3
-5
UserController.java
...ava/com/github/tangyi/user/controller/UserController.java
+18
-0
UserService.java
...main/java/com/github/tangyi/user/service/UserService.java
+1
-0
UserMapper.xml
...mpl/user-service/src/main/resources/mapper/UserMapper.xml
+1
-1
No files found.
README.md
View file @
9f6d0ba5
...
...
@@ -12,9 +12,9 @@
-
后端基于
`spring boot`
、
`spring cloud`
、
`MySQL`
等技术实现权限管理、考试管理等功能。
-
[
在线体验-前台
](
http://www.it99.club
)
-
在线体验-前台:
[
http://www.it99.club
](
http://www.it99.club
)
-
[
在线体验-后台
](
http://www.it99.club:81
)
-
在线体验-后台:
[
http://www.it99.club:81
](
http://www.it99.club:81
)
## 技术选型
...
...
config-service/src/main/resources/config/auth-service.yml
View file @
9f6d0ba5
...
...
@@ -83,6 +83,7 @@ ignore:
-
/actuator/**
-
/hystrix.sender
-
/v1/user/findUserByUsername/**
-
/v1/user/checkExist/**
-
/v1/menu/findMenuByRole/**
-
/v1/code/**
-
/v1/attachment/download
...
...
config-service/src/main/resources/config/exam-service.yml
View file @
9f6d0ba5
...
...
@@ -98,6 +98,7 @@ ignore:
-
/hystrix.sender
-
/v1/user/findUserByUsername/**
-
/v1/menu/findMenuByRole/**
-
/v1/user/checkExist/**
-
/v1/code/**
-
/v1/attachment/download
-
/v1/log/**
...
...
config-service/src/main/resources/config/gateway-service.yml
View file @
9f6d0ba5
...
...
@@ -63,6 +63,19 @@ swagger:
-
exam-service
-
auth-service
# 演示环境
preview
:
enabled
:
${PREVIEW_ENABLED:
false
}
ignoreUrls
:
-
token
-
examRecord
-
saveOrUpdate
-
register
-
submit
-
checkExist
-
updateInfo
-
attachment
logging
:
level
:
root
:
info
...
...
config-service/src/main/resources/config/user-service.yml
View file @
9f6d0ba5
...
...
@@ -123,6 +123,7 @@ ignore:
-
/v1/user/findUserByUsername/**
-
/v1/menu/findMenuByRole/**
-
/v1/user/register
-
/v1/user/checkExist/**
-
/v1/code/**
-
/v1/attachment/download
-
/v1/log/**
...
...
doc/deploy/mysql/microservice-auth.sql
View file @
9f6d0ba5
...
...
@@ -11,7 +11,7 @@
Target Server Version : 50710
File Encoding : 65001
Date: 2
1/04/2019 13:46:4
9
Date: 2
3/04/2019 20:03:2
9
*/
SET
NAMES
utf8mb4
;
...
...
doc/deploy/mysql/microservice-exam.sql
View file @
9f6d0ba5
...
...
@@ -11,7 +11,7 @@
Target Server Version : 50710
File Encoding : 65001
Date: 2
1/04/2019 13:47:02
Date: 2
3/04/2019 20:03:38
*/
SET
NAMES
utf8mb4
;
...
...
@@ -63,6 +63,7 @@ CREATE TABLE `course` (
-- Records of course
-- ----------------------------
INSERT
INTO
`course`
VALUES
(
'6dcccd4639bc49b88810be1d30a77f92'
,
'测试课程'
,
'测试学院'
,
'测试专业'
,
'陈老师'
,
'测试课程'
,
'admin'
,
'2018-11-12 22:31:28'
,
'admin'
,
'2019-04-11 16:51:15'
,
'0'
,
'EXAM'
);
INSERT
INTO
`course`
VALUES
(
'b2321aa045d64448a3ad710aae6efbbf'
,
'高等数学'
,
'测试'
,
'测试'
,
'测试'
,
'测试'
,
'admin'
,
'2019-04-23 19:40:05'
,
'admin'
,
'2019-04-23 19:40:05'
,
'0'
,
'EXAM'
);
-- ----------------------------
-- Table structure for exam_record
...
...
@@ -121,10 +122,10 @@ CREATE TABLE `examination` (
-- ----------------------------
-- Records of examination
-- ----------------------------
INSERT
INTO
`examination`
VALUES
(
'4f9ced28ffe64fcea57a7367e9fd4c0c'
,
'离散数学'
,
'2'
,
'离散数学'
,
'2019-01-03 00:00'
,
'2019-01-11 00:00'
,
''
,
'100'
,
'0'
,
'1'
,
'group1/M00/00/00/wKgAX1x3gGqABz6cAAZyO2yzEwA450.jpg'
,
'da4b5623e9754abbb07320d8def18fe7'
,
'信息学院'
,
'软件工程'
,
'
6dcccd4639bc49b88810be1d30a77f92'
,
'离散数学练习'
,
'admin'
,
'2019-01-13 20:16:36'
,
'admin'
,
'2019-04-11 10:56:03
'
,
'0'
,
'EXAM'
);
INSERT
INTO
`examination`
VALUES
(
'4f9ced28ffe64fcea57a7367e9fd4c0c'
,
'离散数学'
,
'2'
,
'离散数学'
,
'2019-01-03 00:00'
,
'2019-01-11 00:00'
,
''
,
'100'
,
'0'
,
'1'
,
'group1/M00/00/00/wKgAX1x3gGqABz6cAAZyO2yzEwA450.jpg'
,
'da4b5623e9754abbb07320d8def18fe7'
,
'信息学院'
,
'软件工程'
,
'
b2321aa045d64448a3ad710aae6efbbf'
,
'离散数学练习'
,
'admin'
,
'2019-01-13 20:16:36'
,
'admin'
,
'2019-04-23 19:40:15
'
,
'0'
,
'EXAM'
);
INSERT
INTO
`examination`
VALUES
(
'b5990bc1c48d49fcb0023de51772c309'
,
'数学期末考试'
,
'0'
,
'期末考试'
,
'2019-01-22 17:00'
,
'2019-01-22 23:00'
,
''
,
'150'
,
'2'
,
'1'
,
'group1/M00/00/00/wKgAX1x3gHWAa82wAAArtzxOXJ4599.jpg'
,
'60df2d550bd9453a943122033a27fe72'
,
'应用数学'
,
'应用数学'
,
'6dcccd4639bc49b88810be1d30a77f92'
,
'期末考试'
,
'admin'
,
'2018-11-20 22:48:40'
,
NULL
,
'2019-03-18 14:09:49'
,
'0'
,
'EXAM'
);
INSERT
INTO
`examination`
VALUES
(
'f051f54621fc4812b929a7777a701712'
,
'语文考试'
,
'0'
,
'语文考试'
,
'2019-01-22 17:00'
,
'2019-01-22 23:00'
,
''
,
'150'
,
'2'
,
'1'
,
'group1/M00/00/00/wKgAX1x3gIOAIVzXAABrb92CxLk678.jpg'
,
'45d2ac58eb21436692e8cdbdd64291dd'
,
'中文'
,
'中文'
,
'6dcccd4639bc49b88810be1d30a77f92'
,
'语文考试'
,
'admin'
,
'2018-11-20 22:50:55'
,
'admin'
,
'2019-02-28 14:33:27'
,
'0'
,
'EXAM'
);
INSERT
INTO
`examination`
VALUES
(
'fad663ea371f4250a81332bd3a346739'
,
'四川省2016年普通高考适应性测试文综历史试题'
,
'0'
,
'文综历史试题'
,
'2019-04-
11 00:00'
,
'2019-04-11
20:30'
,
''
,
'100'
,
'3'
,
'0'
,
'group1/M00/00/00/wKgAX1x3f52AIE4IAADGq28ys0g361.jpg'
,
'a178c7b221524a89b44e884d8e3172cf'
,
'文综历史试题'
,
'文综历史试题'
,
'6dcccd4639bc49b88810be1d30a77f92'
,
'文综历史试题'
,
'admin'
,
'2018-11-12 20:25:38'
,
'admin'
,
'2019-03-06 13:57:13'
,
'0'
,
'EXAM'
);
INSERT
INTO
`examination`
VALUES
(
'fad663ea371f4250a81332bd3a346739'
,
'四川省2016年普通高考适应性测试文综历史试题'
,
'0'
,
'文综历史试题'
,
'2019-04-
23 12:00'
,
'2019-04-23
20:30'
,
''
,
'100'
,
'3'
,
'0'
,
'group1/M00/00/00/wKgAX1x3f52AIE4IAADGq28ys0g361.jpg'
,
'a178c7b221524a89b44e884d8e3172cf'
,
'文综历史试题'
,
'文综历史试题'
,
'6dcccd4639bc49b88810be1d30a77f92'
,
'文综历史试题'
,
'admin'
,
'2018-11-12 20:25:38'
,
'admin'
,
'2019-03-06 13:57:13'
,
'0'
,
'EXAM'
);
-- ----------------------------
-- Table structure for incorrect_answer
...
...
@@ -234,6 +235,14 @@ CREATE TABLE `subject_bank` (
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8
COLLATE
=
utf8_general_ci
COMMENT
=
'题库表'
ROW_FORMAT
=
Dynamic
;
-- ----------------------------
-- Records of subject_bank
-- ----------------------------
INSERT
INTO
`subject_bank`
VALUES
(
'2f4d39409f164955b26941202e8f6d86'
,
'700556b5becd4091821644a5288d489c'
,
'323'
,
'323'
,
'0'
,
''
,
'32'
,
'323'
,
'2323'
,
'2323'
,
''
,
''
,
'B'
,
'323'
,
'32323'
,
'2'
,
'admin'
,
'2019-04-23 19:37:02'
,
'admin'
,
'2019-04-23 19:37:02'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_bank`
VALUES
(
'50f5ca89942e4b468fc9d9fd1323231b'
,
'c664646337c345ac8a91e3b024ded8bb'
,
'1'
,
'1'
,
'0'
,
''
,
'1'
,
'1'
,
'1'
,
'1'
,
''
,
''
,
'B'
,
'1'
,
'1'
,
'2'
,
'admin'
,
'2019-04-23 19:40:34'
,
'admin'
,
'2019-04-23 19:40:34'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_bank`
VALUES
(
'a66c85dc98a243bdbb576ca699ed4a78'
,
'700556b5becd4091821644a5288d489c'
,
'1'
,
'1'
,
'0'
,
''
,
'1'
,
'1'
,
'1'
,
'1'
,
''
,
''
,
'B'
,
'1'
,
'1'
,
'2'
,
'admin'
,
'2019-04-23 19:36:54'
,
'admin'
,
'2019-04-23 19:36:54'
,
'0'
,
'EXAM'
);
INSERT
INTO
`subject_bank`
VALUES
(
'bc030f9138964031bca3de7ef1621ca6'
,
'c664646337c345ac8a91e3b024ded8bb'
,
'32'
,
'32'
,
'0'
,
''
,
'323'
,
'32'
,
'332'
,
'3323'
,
''
,
''
,
'B'
,
'32'
,
'323'
,
'2'
,
'admin'
,
'2019-04-23 19:40:42'
,
'admin'
,
'2019-04-23 19:40:42'
,
'0'
,
'EXAM'
);
-- ----------------------------
-- Table structure for subject_category
-- ----------------------------
DROP
TABLE
IF
EXISTS
`subject_category`
;
...
...
doc/deploy/mysql/microservice-user.sql
View file @
9f6d0ba5
This diff is collapsed.
Click to expand it.
docker-compose-base.yml
View file @
9f6d0ba5
...
...
@@ -59,7 +59,8 @@ services:
# Redis
# ---------------------------
redis
:
image
:
redis:alpine
image
:
redis:latest
container_name
:
redis
ports
:
-
"
6379:6379"
networks
:
...
...
docker-compose.env
View file @
9f6d0ba5
...
...
@@ -45,4 +45,7 @@ ADMIN_PASSWORD=11
// zipkin配置
ZIPKIN_HOST=localhost
ZIPKIN_PORT=9411
\ No newline at end of file
ZIPKIN_PORT=9411
// 演示环境
PREVIEW_ENABLED=false
\ No newline at end of file
gateway-service/src/main/java/com/github/tangyi/gateway/config/PreviewConfig.java
0 → 100644
View file @
9f6d0ba5
package
com
.
github
.
tangyi
.
gateway
.
config
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.cloud.context.config.annotation.RefreshScope
;
import
org.springframework.context.annotation.Configuration
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 演示环境配置
* @author tangyi
* @date 2019/4/23 13:38
*/
@Configuration
@RefreshScope
@ConditionalOnExpression
(
"!'${preview}'.isEmpty()"
)
@ConfigurationProperties
(
prefix
=
"preview"
)
public
class
PreviewConfig
{
private
List
<
String
>
ignoreUrls
=
new
ArrayList
<>();
public
List
<
String
>
getIgnoreUrls
()
{
return
ignoreUrls
;
}
public
void
setIgnoreUrls
(
List
<
String
>
ignoreUrls
)
{
this
.
ignoreUrls
=
ignoreUrls
;
}
}
gateway-service/src/main/java/com/github/tangyi/gateway/filters/PreviewFilter.java
0 → 100644
View file @
9f6d0ba5
package
com
.
github
.
tangyi
.
gateway
.
filters
;
import
cn.hutool.core.util.StrUtil
;
import
com.github.tangyi.gateway.config.PreviewConfig
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.cloud.gateway.filter.GatewayFilterChain
;
import
org.springframework.cloud.gateway.filter.GlobalFilter
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.Ordered
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.server.reactive.ServerHttpRequest
;
import
org.springframework.http.server.reactive.ServerHttpResponse
;
import
org.springframework.web.server.ServerWebExchange
;
import
reactor.core.publisher.Mono
;
import
java.util.List
;
/**
* 演示环境过滤器
* 如果配置了preview.enabled为true则过滤器生效
*
* @author tangyi
* @date 2019/4/23 10:54
*/
@Configuration
@ConditionalOnProperty
(
prefix
=
"preview"
,
name
=
"enabled"
,
havingValue
=
"true"
,
matchIfMissing
=
true
)
public
class
PreviewFilter
implements
GlobalFilter
,
Ordered
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
PreviewFilter
.
class
);
@Autowired
private
PreviewConfig
previewConfig
;
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
,
GatewayFilterChain
chain
)
{
// 当前请求
ServerHttpRequest
request
=
exchange
.
getRequest
();
// GET或者忽略的URL,直接向下执行
if
(
StrUtil
.
equalsIgnoreCase
(
request
.
getMethodValue
(),
HttpMethod
.
GET
.
name
())
||
isIgnore
(
request
.
getURI
().
getPath
()))
return
chain
.
filter
(
exchange
);
logger
.
warn
(
"演示环境不能操作,{},{}"
,
request
.
getMethodValue
(),
request
.
getURI
().
getPath
());
ServerHttpResponse
response
=
exchange
.
getResponse
();
response
.
setStatusCode
(
HttpStatus
.
LOCKED
);
return
response
.
setComplete
();
}
/**
* 是否忽略URI
*
* @param uri uri
* @return boolean
* @author tangyi
* @date 2019/04/23 13:44
*/
private
boolean
isIgnore
(
String
uri
)
{
List
<
String
>
ignoreUrls
=
previewConfig
.
getIgnoreUrls
();
if
(
ignoreUrls
!=
null
&&
!
ignoreUrls
.
isEmpty
())
{
for
(
String
ignoreUrl
:
ignoreUrls
)
{
if
(
StrUtil
.
containsIgnoreCase
(
uri
,
ignoreUrl
))
return
true
;
}
}
return
false
;
}
@Override
public
int
getOrder
()
{
return
-
100
;
}
}
service-api-impl/exam-service/src/main/java/com/github/tangyi/exam/controller/SubjectBankController.java
View file @
9f6d0ba5
...
...
@@ -31,8 +31,6 @@ import java.text.SimpleDateFormat;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Stream
;
/**
* 题库controller
...
...
@@ -105,10 +103,10 @@ public class SubjectBankController extends BaseController {
SubjectCategory
subjectCategory
=
new
SubjectCategory
();
// 流处理获取分类ID,去重,转成字符串数组
subjectCategory
.
setIds
(
page
.
getList
().
stream
().
map
(
SubjectBank:
:
getCategoryId
).
distinct
().
toArray
(
String
[]::
new
));
Stream
<
SubjectCategory
>
subjectCategoryStream
=
subjectCategoryService
.
findListById
(
subjectCategory
).
stream
(
);
if
(
Optional
.
ofNullable
(
subjectCategoryStream
).
isPresent
(
))
{
List
<
SubjectCategory
>
subjectCategoryList
=
subjectCategoryService
.
findListById
(
subjectCategory
);
if
(
CollectionUtils
.
isNotEmpty
(
subjectCategoryList
))
{
page
.
getList
().
forEach
(
tempSubjectBank
->
{
SubjectCategory
category
=
subjectCategory
Stream
SubjectCategory
category
=
subjectCategory
List
.
stream
()
.
filter
(
tempSubjectCategory
->
tempSubjectCategory
.
getId
().
equals
(
tempSubjectBank
.
getCategoryId
()))
.
findFirst
()
.
orElse
(
null
);
...
...
service-api-impl/user-service/src/main/java/com/github/tangyi/user/controller/UserController.java
View file @
9f6d0ba5
...
...
@@ -444,4 +444,22 @@ public class UserController extends BaseController {
}
return
new
ResponseBean
<>(
success
);
}
/**
* 检查用户是否存在
*
* @param username username
* @return ResponseBean
* @author tangyi
* @date 2019/04/23 15:35
*/
@ApiOperation
(
value
=
"检查用户是否存在"
,
notes
=
"检查用户名是否存在"
)
@ApiImplicitParam
(
name
=
"username"
,
value
=
"用户name"
,
required
=
true
,
dataType
=
"String"
,
paramType
=
"path"
)
@GetMapping
(
"/checkExist/{username}"
)
public
ResponseBean
<
Boolean
>
checkUsernameIsExist
(
@PathVariable
(
"username"
)
String
username
)
{
boolean
exist
=
Boolean
.
FALSE
;
if
(
StringUtils
.
isNotEmpty
(
username
))
exist
=
userService
.
selectUserVoByUsername
(
username
)
!=
null
;
return
new
ResponseBean
<>(
exist
);
}
}
service-api-impl/user-service/src/main/java/com/github/tangyi/user/service/UserService.java
View file @
9f6d0ba5
...
...
@@ -59,6 +59,7 @@ public class UserService extends CrudService<UserMapper, User> {
*/
@Override
@Transactional
@CacheEvict
(
value
=
"user"
,
key
=
"#user.username"
)
public
int
insert
(
User
user
)
{
// 保存角色
if
(
CollectionUtils
.
isNotEmpty
(
user
.
getRole
()))
{
...
...
service-api-impl/user-service/src/main/resources/mapper/UserMapper.xml
View file @
9f6d0ba5
...
...
@@ -144,7 +144,7 @@
<select
id=
"selectUserVoByUsername"
resultMap=
"userVoResultMap"
>
<include
refid=
"selectUserVo"
/>
WHERE `user`.username = #{username}
WHERE `user`.username = #{username}
and `user`.del_flag = 0
</select>
<select
id=
"get"
resultMap=
"userResultMap"
>
...
...
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