Commit bdbf2a13 by tangyi

3.4.0

parent 639cde34
......@@ -22,3 +22,4 @@ build/
atlassian-ide-plugin.xml
!etc/eclipse/.checkstyle
.checkstyle
docs/deploy/dev.env
\ No newline at end of file
Version v3.4.0 (2019-9-14)
--------------------------
改进:
* 主键类型改为bigint
* 去掉题目序号
* 完善多租户
* 前端优化,题目组件化
* 完善多选题
* 调整各服务的端口号
* 升级spring boot 2.1.8、spring cloud Greenwich.SR3
* 优化统一异常处理
* 整合前端工程
Version v3.2.0-SNAPSHOT (2019-8-18)
--------------------------
改进:
......
## 简介
# 1 简介
- 重写[spring-cloud-online-exam](https://gitee.com/wells2333/spring-cloud-online-exam)
......@@ -8,7 +8,7 @@
- 后端基于`spring boot``spring cloud``MySQL`等技术实现权限管理、考试管理等功能。
### 在线体验
# 2 在线体验
- 前台:[http://it99.club](http://it99.club)
......@@ -22,25 +22,7 @@
2. 学生:student/123456
3. 教师:teacher/123456
交流QQ群:<a target="_blank" href="https://jq.qq.com/?_wv=1027&k=5RKZNF2"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="Spring Cloud考试系统学习" title="Spring Cloud考试系统学习"></a>
QQ群号:996208878
如果您觉得有帮助,请点右上角 "Star" 或者项目底部的“捐助”支持一下,谢谢!
### 部署文档
- [在线考试系统部署文档](docs/在线考试系统V3.0_部署文档.md)
- [基于docker-compose部署](docs/在线考试系统V3.0_部署文档(docker版).md)
### 源码地址
- 前台ui:[spring-microservice-exam-web](https://gitee.com/wells2333/spring-microservice-exam-web.git)
- 后台ui:[spring-microservice-exam-ui](https://gitee.com/wells2333/spring-microservice-exam-ui.git)
- 后端:[spring-microservice-exam](https://gitee.com/wells2333/spring-microservice-exam.git)
## 技术选型
# 3 技术选型
- 服务注册与发现:`Consul`
- 熔断器:`Hystrix` + `Turbine`
......@@ -60,18 +42,18 @@ QQ群号:996208878
- 缓存:`Redis`
- 前端:`vue`
## 核心依赖
# 4 核心依赖
| 名称 | 版本 |
| --------- | -------- |
| `Spring Boot` | `2.1.7.RELEASE` |
| `Spring Cloud` | `Greenwich.SR2` |
| `Spring Boot` | `2.1.8.RELEASE` |
| `Spring Cloud` | `Greenwich.SR3` |
## 系统架构
# 5 系统架构
![image](docs/产品设计/系统架构图v3.0.jpg)
![image](docs/images/系统架构图v3.0.jpg)
## 功能概述
# 6 功能概述
项目分前台网站和后台管理两部分,前台主要提供考试功能,后台提供基础管理、考试管理功能。
......@@ -79,33 +61,46 @@ QQ群号:996208878
后台管理分为:系统管理、系统监控、考务管理、附件管理、个人管理
![image](docs/产品设计/系统功能.jpg)
系统管理:提供用户、部门、角色、权限等基础管理
- 用户管理:用户信息增删改查、导入导出
- 部门管理:部门信息增删改查
- 角色管理:角色信息增删改查、分配权限
- 菜单管理:菜单信息增删改查、导入导出
- 终端管理:管理OAuth2.0的客户端,如client_id、client_secret、access_token有效时间等
- 路由管理:网关路由管理,包括路由的增删改查、刷新路由等
- [在线考试系统V3.0功能概述](docs/在线考试系统V3.0_功能概述.md)
系统监控:监控服务、日志等
- 日志监控:查看系统日志
- `consul`监控:`consul`服务监控
- `zipkin`监控:监控服务的调用链路
- 服务监控:`spring boot admin`服务监控
- 接口文档:`swagger api`文档
## 功能演示
考务管理:提供课程、考试、题库、成绩等管理
- 课程管理:课程信息增删改查
- 考试管理:考试信息增删改查、题目管理、发布回收,题目管理支持简单文本、富文本输入、从题库添加等
- 题库管理:题目分类增删改查、题目信息增删改查
- 成绩管理:查看成绩、导出成绩
- 知识库:知识库增删改查、上传附件
### 前台功能
附件管理:项目的所有附件存储在`fastDfs`里,提供统一的管理入口
- 附件列表:管理所有附件,如用户头像、考试附件、知识库附件等。
1. 登录
![image](docs/images/image_web_login.png)
2. 考试
![image](docs/images/image_web_exam.png)
个人管理:管理个人资料和修改密码
- 个人资料:姓名、头像等基本信息的修改
- 修改密码:修改密码
![image](docs/images/image_web_text_subject.png)
# 7 功能演示
3. 答题卡
![image](docs/images/image_web_exam_card.png)
## 7.1 前台功能
4. 查看成绩
![image](docs/images/image_web_exam_score.png)
1. 考试
![image](docs/images/image_web_exam.png)
5. 查看错题
2. 查看错题
![image](docs/images/image_web_incorrect_answer.png)
### 后台功能
## 7.2 后台功能
1. 总体功能
![image](docs/images/image_ui_menu.png)
......@@ -114,42 +109,24 @@ QQ群号:996208878
![image](docs/images/image_ui_exam.png)
3. 题目管理
![image](docs/images/image_ui_exam_subject.png)
![image](docs/images/image_ui_subjects_rich_edit.png)
4. 题库管理
![image](docs/images/image_ui_subject.png)
5. 个人资料
4. 个人资料
![image](docs/images/image_ui_msg.png)
## 后续
- [ ] 作业、考试、知识点管理、考试成绩排名、图表展示
- [ ] 学生签到、请假
- [x] 短信验证码,第三方登录
- [ ] 简答题,题库完善,智能组卷,在线学习,成绩排名
## 问题反馈
# 8 问题反馈
欢迎提交 issue,请写清楚遇到问题的原因、浏览器、操作系统环境、重现的流程和报错日志等。
如果有开发能力,建议在本地调试出出错的代码。
## 参考资料
- [在线考试系统V3.0系统架构图](https://www.processon.com/view/link/5cf88937e4b0a64c88aaa3e4)
- [在线考试系统V3.0使用文档](docs/在线考试系统V3.0_使用文档.md)
# 9 参考资料
- [在线考试系统V3.0设计文档-数据库设计](docs/在线考试系统V3.0_数据库设计.md)
- [在线考试系统-部署文档](https://www.kancloud.cn/tangyi/spring-microservice-exam/1322870)
- [在线考试系统V3.0部署文档](docs/在线考试系统V3.0_部署文档.md)
- [在线考试系统-部署文档(docker版)](https://www.kancloud.cn/tangyi/spring-microservice-exam/1322869)
- [在线考试系统V3.0部署文档(docker版)](docs/在线考试系统V3.0_部署文档(docker版).md)
- [在线考试系统V3.0项目结构说明文档](docs/在线考试系统V3.0_项目结构说明.md)
- [在线考试系统-数据库设计](https://www.kancloud.cn/tangyi/spring-microservice-exam/1322868)
- [微服务架构下的安全设计方案](http://ehedgehog.net/2019/03/23/%E5%BE%AE%E6%9C%8D%E5%8A%A1%E6%9E%B6%E6%9E%84%E4%B8%8B%E7%9A%84%E5%AE%89%E5%85%A8%E8%AE%BE%E8%AE%A1%E6%96%B9%E6%A1%88/)
......@@ -157,6 +134,10 @@ QQ群号:996208878
***
## 关于
# 10 关于
交流QQ群:<a target="_blank" href="https://jq.qq.com/?_wv=1027&k=5RKZNF2"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="Spring Cloud考试系统学习" title="Spring Cloud考试系统学习"></a>
QQ群号:996208878
作者:1633736729@qq.com
\ No newline at end of file
如果您觉得有帮助,请点右上角 "Star" 或者项目底部的“捐助”支持一下,谢谢!
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<parent>
<artifactId>common</artifactId>
<groupId>com.github.tangyi</groupId>
<version>${revision}</version>
</parent>
<artifactId>common-config</artifactId>
<name>${project.artifactId}</name>
<description>公共配置</description>
<dependencies>
<!-- core -->
<dependency>
<groupId>com.github.tangyi</groupId>
<artifactId>common-core</artifactId>
<scope>provided</scope>
</dependency>
<!-- security -->
<dependency>
<groupId>com.github.tangyi</groupId>
<artifactId>common-security</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.github.tangyi.auth.config;
package com.github.tangyi.common.config;
import com.github.tangyi.common.security.constant.SecurityConstant;
import io.swagger.annotations.ApiOperation;
......@@ -84,14 +84,14 @@ public class SwaggerConfig implements WebMvcConfigurer {
.description("https://gitee.com/wells2333/spring-microservice-exam")
.termsOfServiceUrl("https://gitee.com/wells2333/spring-microservice-exam")
.contact(new Contact("tangyi", "https://gitee.com/wells2333/spring-microservice-exam", "1633736729@qq.com"))
.version("2.0")
.version("3.4.0")
.build();
}
/**
* 显示swagger-ui.html文档展示页,还必须注入swagger资源:
*
* @param registry
* @param registry registry
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
......
package com.github.tangyi.exam.error;
package com.github.tangyi.common.config.handler;
import com.github.tangyi.common.core.exceptions.CommonException;
import com.github.tangyi.common.core.model.ResponseBean;
......
......@@ -40,12 +40,10 @@ public class MultitenantCacheManager extends RedisCacheManager {
@Override
protected RedisCache createRedisCache(String name, RedisCacheConfiguration cacheConfig) {
if (StringUtils.isBlank(name) || !name.contains(SPLIT_FLAG)) {
log.debug("create cache name[{}]", name);
return super.createRedisCache(name, cacheConfig);
}
String[] cacheArray = name.split(SPLIT_FLAG);
if (cacheArray.length < CACHE_LENGTH) {
log.debug("create cache name[{}]", name);
return super.createRedisCache(name, cacheConfig);
}
String cacheName = cacheArray[0];
......@@ -54,7 +52,6 @@ public class MultitenantCacheManager extends RedisCacheManager {
long cacheAge = Long.getLong(cacheArray[1], -1);
cacheConfig = cacheConfig.entryTtl(Duration.ofSeconds(cacheAge));
}
log.debug("create cache[{}]", cacheName);
return super.createRedisCache(cacheName, cacheConfig);
}
......@@ -66,8 +63,6 @@ public class MultitenantCacheManager extends RedisCacheManager {
*/
@Override
public Cache getCache(String name) {
name = SysUtil.getTenantCode() + ":" + name;
log.info("get cache[{}]", name);
return super.getCache(name);
return super.getCache(SysUtil.getTenantCode() + ":" + name);
}
}
......@@ -23,11 +23,11 @@ public class AppStartupRunner implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
log.info("start command line...");
log.info("================ start command line ================ ");
log.info("set system properties...");
// 设置系统属性
if (StringUtils.isNotBlank(sysProperties.getCacheExpire()))
System.setProperty(CommonConstant.CACHE_EXPIRE, sysProperties.getCacheExpire());
log.info("end command line...");
log.info("================ end command line ================");
}
}
package com.github.tangyi.common.core.constant;
/**
* 定义api返回编码和提示内容
*
* @author tangyi
* @date 2019-07-24 20:31
*/
public class ApiConstant {
/**
* 服务不可用
*/
public static final int SERVICE_NOT_AVAILABLE = 1;
}
......@@ -163,5 +163,18 @@ public class CommonConstant {
*/
public static final String CACHE_EXPIRE = "CACHE_EXPIRE";
public static final String EMPTY_STRING = "";
/**
* 顶级菜单的parentId
*/
public static final Long ROOT = -1L;
public static final String PARAM_IDS = "ids";
/**
* baskPackage
*/
public static final String BASE_PACKAGE = "com.github.tangyi";
}
package com.github.tangyi.common.core.exceptions;
/**
*
* 服务异常
*
* @author tangyi
* @date 2019-10-08 12:56
*/
public class ServiceException extends CommonException {
private static final long serialVersionUID = -7285211528095468156L;
public ServiceException() {
}
public ServiceException(String msg) {
super(msg);
}
}
package com.github.tangyi.common.core.persistence;
import com.fasterxml.jackson.annotation.JsonFormat;
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 com.github.tangyi.common.core.utils.SysUtil;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang.StringUtils;
import java.io.Serializable;
import java.time.LocalDateTime;
......@@ -24,7 +24,8 @@ public class BaseEntity<T> implements Serializable {
private static final long serialVersionUID = 1L;
protected String id;
@JsonFormat(shape = JsonFormat.Shape.STRING)
protected Long id;
/**
* 创建者
......@@ -66,17 +67,7 @@ public class BaseEntity<T> implements Serializable {
*/
protected boolean isNewRecord;
/**
* ID数组
*/
protected String[] ids;
/**
* ID字符串,多个用逗号隔开
*/
protected String idString;
public BaseEntity(String id) {
public BaseEntity(Long id) {
this();
this.id = id;
}
......@@ -87,7 +78,7 @@ public class BaseEntity<T> implements Serializable {
* @return boolean
*/
public boolean isNewRecord() {
return this.isNewRecord || StringUtils.isBlank(this.getId());
return this.isNewRecord || this.getId() == null;
}
/**
......
package com.github.tangyi.common.core.persistence;
import com.github.tangyi.common.core.constant.CommonConstant;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
......@@ -37,17 +40,10 @@ public interface CrudMapper<T> extends BaseMapper {
/**
* 根据id获取列表数据
*
* @param entity entity
* @return List
*/
List<T> findListById(T entity);
/**
* 获取所有数据
*
* @param ids ids
* @return List
*/
List<T> findAllList();
List<T> findListById(@Param(CommonConstant.PARAM_IDS) Long[] ids);
/**
* 插入单条数据
......@@ -79,6 +75,6 @@ public interface CrudMapper<T> extends BaseMapper {
* @param ids ids
* @return int
*/
int deleteAll(String[] ids);
int deleteAll(@Param(CommonConstant.PARAM_IDS) Long[] ids);
}
......@@ -29,7 +29,7 @@ public abstract class TreeEntity<T> extends BaseEntity<T> {
/**
* 父节点id
*/
protected String parentId;
protected Long parentId;
/**
* 排序号
......
......@@ -4,8 +4,6 @@ import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
/**
* @author tangyi
* @date 2019/4/26 11:54
......
......@@ -28,9 +28,9 @@ public abstract class CrudService<D extends CrudMapper<T>, T extends BaseEntity<
* @throws Exception
*/
@SuppressWarnings("unchecked")
public T get(String id) throws Exception {
public T get(Long id) throws Exception {
Class<T> entityClass = ReflectionUtil.getClassGenricType(getClass(), 1);
T entity = entityClass.getConstructor(String.class).newInstance("0");
T entity = entityClass.getConstructor(Long.class).newInstance("0");
entity.setId(id);
return dao.get(entity);
}
......@@ -68,13 +68,13 @@ public abstract class CrudService<D extends CrudMapper<T>, T extends BaseEntity<
/**
* 查询列表
*
* @param entity entity
* @param ids ids
* @return List
*/
public List<T> findListById(T entity) {
if (entity.getIds() == null || entity.getIds().length == 0)
public List<T> findListById(Long[] ids) {
if (ids == null || ids.length == 0)
return new ArrayList<>();
return dao.findListById(entity);
return dao.findListById(ids);
}
/**
......@@ -86,7 +86,7 @@ public abstract class CrudService<D extends CrudMapper<T>, T extends BaseEntity<
*/
public PageInfo<T> findPage(PageInfo<T> page, T entity) {
PageHelper.startPage(page.getPageNum(), page.getPageSize());
return new PageInfo<T>(dao.findList(entity));
return new PageInfo<>(dao.findList(entity));
}
/**
......@@ -122,7 +122,7 @@ public abstract class CrudService<D extends CrudMapper<T>, T extends BaseEntity<
* @return int
*/
@Transactional
public int deleteAll(String[] ids) {
public int deleteAll(Long[] ids) {
return this.dao.deleteAll(ids);
}
......
......@@ -24,7 +24,7 @@ public class IdGen {
* @author tangyi
* @date 2019/04/26 11:24
*/
public static String snowflakeId() {
return Long.toString(SpringContextHolder.getApplicationContext().getBean(SnowflakeIdWorker.class).nextId());
public static long snowflakeId() {
return SpringContextHolder.getApplicationContext().getBean(SnowflakeIdWorker.class).nextId();
}
}
\ No newline at end of file
package com.github.tangyi.common.core.utils;
import com.github.tangyi.common.core.model.ResponseBean;
/**
*
*
* @author tangyi
* @date 2019-10-08 12:03
*/
public class ResponseUtil {
/**
* 是否成功
* @param responseBean responseBean
* @return boolean
*/
public static boolean isSuccess(ResponseBean<?> responseBean) {
return responseBean != null && responseBean.getStatus() == ResponseBean.SUCCESS;
}
}
......@@ -43,7 +43,7 @@ public class UserVo extends BaseEntity<UserVo> {
/**
* 头像对应的附件id
*/
private String avatarId;
private Long avatarId;
/**
* 邮箱
......@@ -68,7 +68,7 @@ public class UserVo extends BaseEntity<UserVo> {
/**
* 部门ID
*/
private String deptId;
private Long deptId;
/**
* 角色列表
......@@ -88,27 +88,27 @@ public class UserVo extends BaseEntity<UserVo> {
/**
* 引导注册人
*/
private String parentUid;
private Long parentUid;
/**
* 乡/镇
*/
private String streetId;
private Long streetId;
/**
* 县
*/
private String countyId;
private Long countyId;
/**
* 城市
*/
private String cityId;
private Long cityId;
/**
* 省份
*/
private String provinceId;
private Long provinceId;
/**
* 最近登录时间
......
......@@ -17,6 +17,11 @@ public class SecurityConstant {
public static final String ROLE_ADMIN = "role_admin";
/**
* 租户管理员角色
*/
public static final String ROLE_TENANT_ADMIN = "role_tenant_admin";
/**
* 默认生成图形验证码过期时间
*/
public static final int DEFAULT_IMAGE_EXPIRE = 60;
......
package com.github.tangyi.common.security.mobile;
import com.github.tangyi.common.security.tenant.TenantContextHolder;
import com.github.tangyi.common.security.core.CustomUserDetailsService;
import com.github.tangyi.common.security.tenant.TenantContextHolder;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.support.MessageSourceAccessor;
......
......@@ -17,5 +17,6 @@
<module>common-security</module>
<module>common-feign</module>
<module>common-log</module>
<module>common-config</module>
</modules>
</project>
......@@ -3,7 +3,7 @@ MAINTAINER tangyi(1633736729@qq.com)
ARG JAR_FILE
ENV PROFILE native
ADD target/${JAR_FILE} /opt/app.jar
EXPOSE 8769
EXPOSE 9181
ENTRYPOINT java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -Duser.timezone=Asia/Shanghai -Dfile.encoding=UTF-8 -Dspring.profiles.active=${PROFILE} -jar /opt/app.jar
# JAVA_OPS配置,如:JAVA_OPS='-Xmx512m -Xms256m'
\ No newline at end of file
......@@ -5,4 +5,4 @@ Config Service
1. 修改`config-service`服务的`/resources/conf`下对应服务的配置文件
2. 访问对应服务的`/actuator/refresh`,如:`localhost:8000/actuator/refresh`
\ No newline at end of file
2. 访问对应服务的`/actuator/refresh`,如:`localhost:9180/actuator/refresh`
\ No newline at end of file
......@@ -70,6 +70,7 @@
<configuration>
<repository>${docker.registry}/${docker.namespace}/${project.artifactId}</repository>
<tag>${project.version}</tag>
<tag>latest</tag>
<!-- 构建参数,指定jar包名称 -->
<buildArgs>
<JAR_FILE>${project.name}.jar</JAR_FILE>
......
# bootstrap.yml文件中的内容不能放到application.yml中,否则config部分无法被加载
# 因为config部分的配置先于application.yml被加载,而bootstrap.yml中的配置会先于application.yml加载
server:
port: 8769
port: 9181
spring:
application:
name: config-service
......@@ -16,7 +16,7 @@ spring:
boot:
admin:
client:
url: http://${ADMIN_HOST:localhost}:${ADMIN_PORT:8085}/admin
url: http://${ADMIN_HOST:localhost}:${ADMIN_PORT:9186}/admin
username: ${ADMIN_USERNAME:admin}
password: ${ADMIN_PASSWORD:11}
instance:
......
server:
port: 8090
port: 9182
spring:
datasource:
url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/microservice-auth?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=CTT&characterEncoding=UTF-8
url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/${DB_AUTH:microservice-auth}?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=CTT&characterEncoding=UTF-8
username: ${MYSQL_USERNAME:root}
password: ${MYSQL_PASSWORD:11}
type: com.zaxxer.hikari.HikariDataSource
......@@ -18,7 +18,7 @@ spring:
boot:
admin:
client:
url: http://${ADMIN_HOST:localhost}:${ADMIN_PORT:8085}/admin
url: http://${ADMIN_HOST:localhost}:${ADMIN_PORT:9186}/admin
username: ${ADMIN_USERNAME:admin}
password: ${ADMIN_PASSWORD:11}
instance:
......@@ -131,8 +131,3 @@ wx:
appId: test
appSecret: test
grantType: authorization_code
\ No newline at end of file
logging:
level:
root: info
com.github.tangyi: debug
\ No newline at end of file
server:
port: 8098
port: 9184
spring:
datasource:
url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/microservice-exam?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=CTT&characterEncoding=UTF-8
url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/${DB_EXAM:microservice-exam}?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=CTT&characterEncoding=UTF-8
username: ${MYSQL_USERNAME:root}
password: ${MYSQL_PASSWORD:11}
type: com.zaxxer.hikari.HikariDataSource
......@@ -18,7 +18,7 @@ spring:
boot:
admin:
client:
url: http://${ADMIN_HOST:localhost}:${ADMIN_PORT:8085}/admin
url: http://${ADMIN_HOST:localhost}:${ADMIN_PORT:9186}/admin
username: ${ADMIN_USERNAME:admin}
password: ${ADMIN_PASSWORD:11}
instance:
......@@ -41,15 +41,15 @@ security:
client:
client-id: web_app
client-secret: $2a$10$S84wOzmAw4wqYBzAqNtmPOx1ZRWdDl9omm/W8T1hhW8S9EK2u57xG
access-token-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:8000}/api/auth/oauth/token
user-authorization-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:8000}/api/auth/oauth/authorize
access-token-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:9180}/api/auth/oauth/token
user-authorization-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:9180}/api/auth/oauth/authorize
grant-type: password
scope: read
resource:
user-info-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:8000}/api/user/v1/user/info
user-info-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:9180}/api/user/v1/user/info
prefer-token-info: false
jwt:
key-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:8000}/api/auth/oauth/token_key
key-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:9180}/api/auth/oauth/token_key
key-value: |
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjxSawA+NUNmhB2ctiVnt
......@@ -144,8 +144,3 @@ ignore:
cluster:
workId: ${CLUSTER_WORKID:1}
dataCenterId: ${CLUSTER_DATA_CENTER_ID:1}
\ No newline at end of file
logging:
level:
root: info
com.github.tangyi: debug
server:
port: 8000
port: 9180
# HTTPS
# ssl:
# enabled: false
......@@ -11,7 +11,7 @@ server:
# key-store-password: test
spring:
datasource:
url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/microservice-gateway?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=CTT&characterEncoding=UTF-8
url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/${DB_GATEWAY:microservice-gateway}?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=CTT&characterEncoding=UTF-8
username: ${MYSQL_USERNAME:root}
password: ${MYSQL_PASSWORD:11}
type: com.zaxxer.hikari.HikariDataSource
......@@ -27,7 +27,7 @@ spring:
boot:
admin:
client:
url: http://${ADMIN_HOST:localhost}:${ADMIN_PORT:8085}/admin
url: http://${ADMIN_HOST:localhost}:${ADMIN_PORT:9186}/admin
username: ${ADMIN_USERNAME:admin}
password: ${ADMIN_PASSWORD:11}
instance:
......@@ -130,8 +130,3 @@ gateway:
cluster:
workId: ${CLUSTER_WORKID:1}
dataCenterId: ${CLUSTER_DATA_CENTER_ID:1}
\ No newline at end of file
logging:
level:
root: info
com.github.tangyi: debug
\ No newline at end of file
server:
port: 8085
port: 9186
turbine:
appConfig: consul,auth-service,exam-service,user-service,gateway-service,msc-service
......
server:
port: 9000
port: 9185
spring:
redis:
host: ${REDIS_HOST:localhost}
......@@ -12,7 +12,7 @@ spring:
boot:
admin:
client:
url: http://${ADMIN_HOST:localhost}:${ADMIN_PORT:8085}/admin
url: http://${ADMIN_HOST:localhost}:${ADMIN_PORT:9186}/admin
username: ${ADMIN_USERNAME:admin}
password: ${ADMIN_PASSWORD:11}
instance:
......@@ -36,15 +36,15 @@ security:
client:
client-id: web_app
client-secret: $2a$10$S84wOzmAw4wqYBzAqNtmPOx1ZRWdDl9omm/W8T1hhW8S9EK2u57xG
access-token-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:8000}/api/auth/oauth/token
user-authorization-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:8000}/api/auth/oauth/authorize
access-token-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:9180}/api/auth/oauth/token
user-authorization-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:9180}/api/auth/oauth/authorize
grant-type: password
scope: read
resource:
user-info-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:8000}/api/user/v1/user/info
user-info-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:9180}/api/user/v1/user/info
prefer-token-info: false
jwt:
key-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:8000}/api/auth/oauth/token_key
key-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:9180}/api/auth/oauth/token_key
key-value: |
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjxSawA+NUNmhB2ctiVnt
......@@ -117,8 +117,3 @@ ignore:
cluster:
workId: ${CLUSTER_WORKID:1}
dataCenterId: ${CLUSTER_DATA_CENTER_ID:1}
logging:
level:
root: info
com.github.tangyi: debug
\ No newline at end of file
server:
port: 8095
port: 9183
spring:
servlet:
multipart:
......@@ -8,7 +8,7 @@ spring:
# 单次请求的文件的总大小
max-request-size: 100MB
datasource:
url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/microservice-user?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=CTT&characterEncoding=UTF-8
url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/${DB_USER:microservice-user}?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=CTT&characterEncoding=UTF-8
username: ${MYSQL_USERNAME:root}
password: ${MYSQL_PASSWORD:11}
type: com.zaxxer.hikari.HikariDataSource
......@@ -24,7 +24,7 @@ spring:
boot:
admin:
client:
url: http://${ADMIN_HOST:localhost}:${ADMIN_PORT:8085}/admin
url: http://${ADMIN_HOST:localhost}:${ADMIN_PORT:9186}/admin
username: ${ADMIN_USERNAME:admin}
password: ${ADMIN_PASSWORD:11}
instance:
......@@ -47,15 +47,15 @@ security:
client:
client-id: web_app
client-secret: $2a$10$S84wOzmAw4wqYBzAqNtmPOx1ZRWdDl9omm/W8T1hhW8S9EK2u57xG
access-token-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:8000}/api/auth/oauth/token
user-authorization-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:8000}/api/auth/oauth/authorize
access-token-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:9180}/api/auth/oauth/token
user-authorization-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:9180}/api/auth/oauth/authorize
grant-type: password
scope: read
resource:
user-info-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:8000}/api/user/v1/user/info
user-info-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:9180}/api/user/v1/user/info
prefer-token-info: false
jwt:
key-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:8000}/api/auth/oauth/token_key
key-uri: http://${AUTH_SERVICE_HOST:localhost}:${AUTH_SERVICE_PORT:9180}/api/auth/oauth/token_key
key-value: |
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjxSawA+NUNmhB2ctiVnt
......@@ -171,7 +171,3 @@ cluster:
workId: ${CLUSTER_WORKID:1}
dataCenterId: ${CLUSTER_DATA_CENTER_ID:1}
logging:
level:
root: info
com.github.tangyi: debug
......@@ -40,17 +40,17 @@
</appender>
<!-- 输出到logstash的appender -->
<!-- <appender name="logstash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
&lt;!&ndash; logstash的IP和端口,从环境变量注入 &ndash;&gt;
<appender name="logstash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<!-- logstash的IP和端口,从环境变量注入 -->
<destination>${ELK_DESTINATION}</destination>
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>-->
</appender>
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
<root level="info">
<appender-ref ref="console"/>
<appender-ref ref="debug"/>
<appender-ref ref="error"/>
<!--<appender-ref ref="logstash"/>-->
<appender-ref ref="logstash"/>
</root>
</configuration>
# 部署相关的配置文件
## mysql
mysql的初始化脚本
## elk
elk的配置文件
## docker-compose.env
所有服务共享的环境变量
## docker-compose-base.yml
基础服务:consul、Redis、rabbitMq、config-service
## docker-compose-services.yml
核心服务:auth-service、user-service、exam-service、gateway-service、monitor-service、msc-service
## docker-compose-nginx.yml
前端服务:ui-service、web-service
## docker-compose-elk.yml
elk服务
## redis.conf
redis的配置
## nginx.conf
前端服务共享的nginx配置,主要配置将api请求转发到网关gateway-service
## start.sh
启动脚本
......@@ -4,7 +4,7 @@ services:
# consul集群,3个节点
# ---------------------------
consul:
image: consul:1.2.0
image: consul:latest
container_name: consul
command: consul agent -server -client 0.0.0.0 -ui -bootstrap-expect=3 -data-dir=/consul/data -retry-join=consul2 -retry-join=consul3 -datacenter=blr
restart: always
......@@ -16,7 +16,7 @@ services:
networks:
- net
consul2:
image: consul:1.2.0
image: consul:latest
container_name: consul-2
expose:
- "8500"
......@@ -27,7 +27,7 @@ services:
networks:
- net
consul3:
image: consul:1.2.0
image: consul:latest
container_name: consul-3
expose:
- "8500"
......@@ -61,8 +61,13 @@ services:
redis:
image: redis:latest
container_name: redis
restart: always
command: redis-server /usr/local/etc/redis/redis.conf
ports:
- "6379:6379"
volumes:
- ./redis-data:/data
- ./redis.conf:/usr/local/etc/redis/redis.conf
networks:
- net
......@@ -70,7 +75,7 @@ services:
# 配置中心
# ---------------------------
config-service:
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/config-service:3.2.0-SNAPSHOT
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/config-service:latest
container_name: config-service
env_file: docker-compose.env # 从文件中获取配置
restart: always
......@@ -79,7 +84,7 @@ services:
- rabbit
- redis
ports:
- "8769:8769"
- "9181:9181"
networks:
- net
......
version: '3.2'
version: '3.4'
services:
elk:
image: sebp/elk
......
......@@ -4,7 +4,7 @@ services:
# 前台
# ---------------------------
spring-microservice-exam-web:
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/spring-microservice-exam-web:3.2.0-SNAPSHOT
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/spring-microservice-exam-web:latest
volumes:
# 挂载nginx的配置文件
- ./nginx.conf:/etc/nginx/nginx.conf
......@@ -20,7 +20,7 @@ services:
# 后台
# ---------------------------
spring-microservice-exam-ui:
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/spring-microservice-exam-ui:3.2.0-SNAPSHOT
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/spring-microservice-exam-ui:latest
volumes:
# 挂载nginx的配置文件
- ./nginx.conf:/etc/nginx/nginx.conf
......
......@@ -4,12 +4,12 @@ services:
# api网关
# ---------------------------
gateway-service:
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/gateway-service:3.2.0-SNAPSHOT
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/gateway-service:latest
container_name: gateway-service
env_file: docker-compose.env # 从文件中获取配置
restart: always
ports:
- "8000:8000"
- "9180:9180"
networks:
- net
......@@ -17,12 +17,12 @@ services:
# 授权服务
# ---------------------------
auth-service:
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/auth-service:3.2.0-SNAPSHOT
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/auth-service:latest
container_name: auth-service
env_file: docker-compose.env # 从文件中获取配置
restart: always
ports:
- "8090:8090"
- "9182:9182"
networks:
- net
......@@ -30,12 +30,12 @@ services:
# 用户服务
# ---------------------------
user-service:
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/user-service:3.2.0-SNAPSHOT
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/user-service:latest
container_name: user-service
env_file: docker-compose.env # 从文件中获取配置
restart: always
ports:
- "8095:8095"
- "9183:9183"
networks:
- net
......@@ -43,12 +43,12 @@ services:
# 考试服务
# ---------------------------
exam-service:
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/exam-service:3.2.0-SNAPSHOT
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/exam-service:latest
container_name: exam-service
env_file: docker-compose.env # 从文件中获取配置
restart: always
ports:
- "8098:8098"
- "9184:9184"
networks:
- net
......@@ -56,12 +56,12 @@ services:
# 消息服务
# ---------------------------
msc-service:
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/msc-service:3.2.0-SNAPSHOT
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/msc-service:latest
container_name: msc-service
env_file: docker-compose.env # 从文件中获取配置
restart: always
ports:
- "9000:9000"
- "9185:9185"
networks:
- net
......@@ -69,12 +69,12 @@ services:
# 监控服务
# ---------------------------
monitor-service:
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/monitor-service:3.2.0-SNAPSHOT
image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/monitor-service:latest
container_name: monitor-service
env_file: docker-compose.env # 从文件中获取配置
restart: always
ports:
- "8085:8085"
- "9186:9186"
networks:
- net
......
......@@ -53,7 +53,7 @@ USER_SERVICE_HOST=user-service
# 服务监控配置
ADMIN_HOST=monitor-service
ADMIN_PORT=8085
ADMIN_PORT=9186
ADMIN_USERNAME=admin
ADMIN_PASSWORD=11
......@@ -73,3 +73,6 @@ TZ=Asia/Shanghai
# elk配置
ELK_DESTINATION=localhost:5044
# 日志级别
LOGGING_LEVEL=error
\ No newline at end of file
/*
Navicat Premium Data Transfer
Source Server : mysql_localhost
Source Server Type : MySQL
Source Server Version : 50617
Source Host : localhost:3306
Source Schema : microservice-gateway
Target Server Type : MySQL
Target Server Version : 50617
File Encoding : 65001
Date: 18/08/2019 20:10:40
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for sys_route
-- ----------------------------
DROP TABLE IF EXISTS `sys_route`;
CREATE TABLE `sys_route` (
`id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`route_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '路由ID',
`route_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '路由名称',
`predicates` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '断言',
`filters` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '过滤器',
`uri` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'URI',
`sort` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '排序',
`status` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '启用禁用',
`creator` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`create_date` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间',
`modifier` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '修改人',
`modify_date` timestamp(0) NULL DEFAULT NULL COMMENT '修改时间',
`del_flag` int(11) 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 = Compact;
-- ----------------------------
-- Records of sys_route
-- ----------------------------
INSERT INTO `sys_route` VALUES ('0f1aec35a545433c8cc0c8e78995f039', 'auth-service', '认证授权服务', '[\n {\n \"name\": \"Path\",\n \"args\": {\n \"_genkey_0\": \"/api/auth/**\"\n }\n }\n]', '[\n {\n \"name\": \"StripPrefix\",\n \"args\": {\n \"_genkey_0\": \"2\"\n }\n },\n {\n \"name\": \"RemoveRequestHeader\",\n \"args\": {\n \"_genkey_0\": \"Cookie\",\n \"_genkey_1\": \"Set-Cookie\"\n }\n }\n]', 'lb://auth-service', '1', '0', 'admin', '2019-04-07 11:20:55', '', '2019-08-03 09:58:48', 0, 'EXAM');
INSERT INTO `sys_route` VALUES ('5d9dd5f2cb1147aaad6f8b82a58586e8', 'exam-service', '考试服务', '[\n {\n \"name\": \"Path\",\n \"args\": {\n \"_genkey_0\": \"/api/exam/**\"\n }\n }\n]', '[\n {\n \"name\": \"StripPrefix\",\n \"args\": {\n \"_genkey_0\": \"2\"\n }\n },\n {\n \"name\": \"RemoveRequestHeader\",\n \"args\": {\n \"_genkey_0\": \"Cookie\",\n \"_genkey_1\": \"Set-Cookie\"\n }\n }\n]', 'lb://exam-service', '3', '0', 'admin', '2019-04-02 21:39:30', '', '2019-08-03 09:58:54', 0, 'EXAM');
INSERT INTO `sys_route` VALUES ('607150228717572096', 'msc-service', '消息中心', '[\n {\n \"name\": \"Path\",\n \"args\": {\n \"_genkey_0\": \"/api/msc/**\"\n }\n }\n]', '[\n {\n \"name\": \"StripPrefix\",\n \"args\": {\n \"_genkey_0\": \"2\"\n }\n },\n {\n \"name\": \"RemoveRequestHeader\",\n \"args\": {\n \"_genkey_0\": \"Cookie\",\n \"_genkey_1\": \"Set-Cookie\"\n }\n }\n]', 'lb://msc-service', '4', '0', '', '2019-08-03 09:58:15', '', '2019-08-03 09:58:27', 0, 'EXAM');
INSERT INTO `sys_route` VALUES ('e9199257e8dc4f2d8fbb2a113c407eca', 'user-service', '用户服务', '[\n {\n \"name\": \"Path\",\n \"args\": {\n \"_genkey_0\": \"/api/user/**\"\n }\n }\n]', '[\n {\n \"name\": \"StripPrefix\",\n \"args\": {\n \"_genkey_0\": \"2\"\n }\n },\n {\n \"name\": \"RemoveRequestHeader\",\n \"args\": {\n \"_genkey_0\": \"Cookie\",\n \"_genkey_1\": \"Set-Cookie\"\n }\n }\n]', 'lb://user-service', '2', '0', 'admin', '2019-04-07 11:22:05', '', '2019-08-03 09:58:35', 0, 'EXAM');
SET FOREIGN_KEY_CHECKS = 1;
/*
Navicat Premium Data Transfer
Source Server : mysql_localhost
Source Server Type : MySQL
Source Server Version : 50617
Source Host : localhost:3306
Source Schema : microservice-auth
Target Server Type : MySQL
Target Server Version : 50617
File Encoding : 65001
Date: 18/08/2019 20:10:54
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
......@@ -22,12 +7,12 @@ SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
DROP TABLE IF EXISTS `oauth_client_details`;
CREATE TABLE `oauth_client_details` (
`id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '主键',
`client_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'client_id',
`id` bigint(20) NOT NULL COMMENT '主键',
`client_id` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT 'client_id',
`resource_ids` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'resource_ids',
`client_secret_plain_text` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '密钥明文',
`client_secret` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'client_secret',
`scope` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '授权范围',
`client_secret` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT 'client_secret',
`scope` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '授权范围',
`authorized_grant_types` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '授权类型',
`web_server_redirect_uri` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`authorities` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
......@@ -35,19 +20,19 @@ CREATE TABLE `oauth_client_details` (
`refresh_token_validity` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'refresh_token有效时间',
`additional_information` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`autoapprove` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`creator` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人',
`creator` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '创建人',
`create_date` timestamp(0) NULL DEFAULT NULL COMMENT '创建时间',
`modifier` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '修改人',
`modify_date` timestamp(0) NULL DEFAULT NULL COMMENT '修改时间',
`del_flag` int(20) NULL DEFAULT NULL COMMENT '删除标记',
`application_code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '系统编号',
`tenant_code` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '租户编号',
`modifier` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '修改人',
`modify_date` timestamp(0) NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '修改时间',
`del_flag` tinyint(4) NOT NULL COMMENT '删除标记',
`application_code` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '系统编号',
`tenant_code` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of oauth_client_details
-- ----------------------------
INSERT INTO `oauth_client_details` VALUES ('471037a0c1be4df99b40e3f84141cc56', 'web_app', NULL, 'spring-microservice-exam-secret', '$2a$10$IWLD8r7e0rKMW.ZhGsGCUO./MZUNDKudIswSToa9puXJwty.h59.u', 'read,write', 'password,authorization_code,refresh_token,implicit', NULL, NULL, '3600', '21600', NULL, NULL, 'admin', '2019-03-30 23:43:07', 'admin', '2019-07-04 10:52:15', 0, 'EXAM', NULL);
INSERT INTO `oauth_client_details` VALUES (607150228717572096, 'web_app', NULL, 'spring-microservice-exam-secret', '$2a$10$IWLD8r7e0rKMW.ZhGsGCUO./MZUNDKudIswSToa9puXJwty.h59.u', 'read,write', 'password,authorization_code,refresh_token,implicit', NULL, NULL, '3600', '21600', NULL, NULL, 'admin', '2019-03-30 23:43:07', 'admin', '2019-10-07 14:55:28', 0, 'EXAM', 'gitee');
SET FOREIGN_KEY_CHECKS = 1;
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for sys_route
-- ----------------------------
DROP TABLE IF EXISTS `sys_route`;
CREATE TABLE `sys_route` (
`id` bigint(20) NOT NULL COMMENT '主键',
`route_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '路由ID',
`route_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '路由名称',
`predicates` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '断言',
`filters` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '过滤器',
`uri` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT 'URI',
`sort` int(11) NOT NULL COMMENT '排序',
`status` tinyint(4) NOT NULL COMMENT '启用禁用',
`creator` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`create_date` timestamp(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '创建时间',
`modifier` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '修改人',
`modify_date` timestamp(0) NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '修改时间',
`del_flag` tinyint(4) NOT NULL DEFAULT 0 COMMENT '删除标记',
`application_code` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '系统编号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of sys_route
-- ----------------------------
INSERT INTO `sys_route` VALUES (607150228717572096, 'msc-service', '消息中心', '[\n {\n \"name\": \"Path\",\n \"args\": {\n \"_genkey_0\": \"/api/msc/**\"\n }\n }\n]', '[\n {\n \"name\": \"StripPrefix\",\n \"args\": {\n \"_genkey_0\": \"2\"\n }\n },\n {\n \"name\": \"RemoveRequestHeader\",\n \"args\": {\n \"_genkey_0\": \"Cookie\",\n \"_genkey_1\": \"Set-Cookie\"\n }\n }\n]', 'lb://msc-service', 4, 0, '', '2019-10-07 15:04:11', '', '2019-10-07 14:55:44', 0, 'EXAM');
INSERT INTO `sys_route` VALUES (607150228717572097, 'user-service', '用户服务', '[\n {\n \"name\": \"Path\",\n \"args\": {\n \"_genkey_0\": \"/api/user/**\"\n }\n }\n]', '[\n {\n \"name\": \"StripPrefix\",\n \"args\": {\n \"_genkey_0\": \"2\"\n }\n },\n {\n \"name\": \"RemoveRequestHeader\",\n \"args\": {\n \"_genkey_0\": \"Cookie\",\n \"_genkey_1\": \"Set-Cookie\"\n }\n }\n]', 'lb://user-service', 2, 0, 'admin', '2019-04-07 11:22:05', '', '2019-08-03 09:58:35', 0, 'EXAM');
INSERT INTO `sys_route` VALUES (607150228717572098, 'exam-service', '考试服务', '[\n {\n \"name\": \"Path\",\n \"args\": {\n \"_genkey_0\": \"/api/exam/**\"\n }\n }\n]', '[\n {\n \"name\": \"StripPrefix\",\n \"args\": {\n \"_genkey_0\": \"2\"\n }\n },\n {\n \"name\": \"RemoveRequestHeader\",\n \"args\": {\n \"_genkey_0\": \"Cookie\",\n \"_genkey_1\": \"Set-Cookie\"\n }\n }\n]', 'lb://exam-service', 3, 0, 'admin', '2019-04-02 21:39:30', '', '2019-08-03 09:58:54', 0, 'EXAM');
INSERT INTO `sys_route` VALUES (607150228717572099, 'auth-service', '认证授权服务', '[\n {\n \"name\": \"Path\",\n \"args\": {\n \"_genkey_0\": \"/api/auth/**\"\n }\n }\n]', '[\n {\n \"name\": \"StripPrefix\",\n \"args\": {\n \"_genkey_0\": \"2\"\n }\n },\n {\n \"name\": \"RemoveRequestHeader\",\n \"args\": {\n \"_genkey_0\": \"Cookie\",\n \"_genkey_1\": \"Set-Cookie\"\n }\n }\n]', 'lb://auth-service', 1, 0, 'admin', '2019-04-07 11:20:55', '', '2019-08-03 09:58:48', 0, 'EXAM');
SET FOREIGN_KEY_CHECKS = 1;
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -13,7 +13,7 @@ http {
index index.html index.htm;
upstream gateway-service {
server gateway-service:8000 max_fails=3 fail_timeout=30s;
server gateway-service:9180 max_fails=3 fail_timeout=30s;
}
server {
......@@ -22,6 +22,10 @@ http {
location ~* /a(pi|uth) {
proxy_pass http://gateway-service;
}
location ~* /admin {
proxy_pass http://ui-service;
}
location / {
}
}
......
daemonize no
pidfile /var/vcap/sys/run/redis.pid
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 0
loglevel notice
logfile redis.log
syslog-enabled yes
syslog-ident redis-server
syslog-facility local0
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ./
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-ping-slave-period 10
repl-timeout 60
repl-disable-tcp-nodelay no
slave-priority 100
maxmemory-policy noeviction
appendonly yes
appendfilename appendonly.aof
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
rename-command CONFIG "A-B-Ab1AZec_-AaC1A2bAbB22a_a1Baa"
rename-command SAVE "SAVE"
rename-command BGSAVE "BGSAVE"
rename-command DEBUG ""
rename-command SHUTDOWN ""
rename-command SLAVEOF ""
rename-command SYNC ""
maxmemory 1775550873
\ No newline at end of file
......@@ -5,7 +5,7 @@ DOCKERHOME=/spring-microservice-exam
# 镜像名称前缀、标签
BASE_IMAGE_NAME=registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam
BSEE_IMAGE_TAG=3.2.0-SNAPSHOT
BSEE_IMAGE_TAG=latest
# 各服务的镜像名称
CONFIG_SERVICE=$BASE_IMAGE_NAME/config-service:$BSEE_IMAGE_TAG
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
++ /dev/null
### 在线考试系统V3.0使用文档
完整项目地址:
- 前台ui:[spring-microservice-exam-web](https://gitee.com/wells2333/spring-microservice-exam-web.git)
- 后台ui:[spring-microservice-exam-ui](https://gitee.com/wells2333/spring-microservice-exam-ui.git)
- 后端:[spring-microservice-exam](https://gitee.com/wells2333/spring-microservice-exam.git)
### 系列文章
- [登录]()
- [系统管理]()
- [考务管理]()
- [系统监控]()
- [附件管理]()
- [个人资料]()
++ /dev/null
#### 功能概述
项目分前台网站和后台管理两部分,前台主要提供考试功能,后台提供基础管理、考试管理功能。
前台主要提供在线考试、在线学习功能
后台管理分为:系统管理、系统监控、考务管理、附件管理、个人管理
系统管理:提供用户、部门、角色、权限等基础管理
- 用户管理:用户信息增删改查、导入导出
- 部门管理:部门信息增删改查
- 角色管理:角色信息增删改查、分配权限
- 菜单管理:菜单信息增删改查、导入导出
- 终端管理:管理OAuth2.0的客户端,如client_id、client_secret、access_token有效时间等
- 路由管理:网关路由管理,包括路由的增删改查、刷新路由等
系统监控:监控服务、日志等
- 日志监控:查看系统日志
- `consul`监控:`consul`服务监控
- `zipkin`监控:监控服务的调用链路
- 服务监控:`spring boot admin`服务监控
- 接口文档:`swagger api`文档
考务管理:提供课程、考试、题库、成绩等管理
- 课程管理:课程信息增删改查
- 考试管理:考试信息增删改查、题目管理、发布回收,题目管理支持简单文本、富文本输入、从题库添加等
- 题库管理:题目分类增删改查、题目信息增删改查
- 成绩管理:查看成绩、导出成绩
- 知识库:知识库增删改查、上传附件
附件管理:项目的所有附件存储在`fastDfs`里,提供统一的管理入口
- 附件列表:管理所有附件,如用户头像、考试附件、知识库附件等。
个人管理:管理个人资料和修改密码
- 个人资料:姓名、头像等基本信息的修改
- 修改密码:修改密码
++ /dev/null
#### 考试服务数据库ER图
![image](产品设计/数据库ER关系图.jpg)
#### 考试服务数据库PDM
![image](产品设计/数据库PDM-考试服务.png)
#### 用户服务数据库PDM
![image](产品设计/数据库PDM-用户服务.png)
#### 授权服务数据库PDM
![image](产品设计/数据库PDM-授权服务.png)
如有问题欢迎指出!
\ No newline at end of file
主要介绍如何基于docker、docker-compose部署后端项目、前端项目,主要的步骤是本地构建镜像,推送的远程仓库,远程服务器从远程仓库拉去镜像运行
++ /dev/null
主要介绍如何基于docker、docker-compose部署后端项目、前端项目,主要的步骤是本地构建镜像,推送的远程仓库,远程服务器从远程仓库拉去镜像运行
## 前提
- 服务器:2核4G、CentOS 7.2 64位
- 注册阿里云账号
## 安装MySQL
MySQL需要单独安装,创建数据库和执行初始化脚本:
`/docs/deploy/mysql/init/microservice-user.sql`
`/docs/deploy/mysql/init/microservice-exam.sql`
`/docs/deploy/mysql/init/microservice-auth.sql`
`/docs/deploy/mysql/init/microservice-gateway.sql`
## 安装docker、docker-compose
linux系统安装`docker``docker-compose`
windows系统安装`Docker for Windows`
## 安装fastDfs
参考:[fastdfs文件系统单机环境搭建和spring boot整合](https://blog.csdn.net/baidu_36415076/article/details/79505027)
## 修改配置
在服务器的根目录创建文件夹:`spring-microservice-exam`
将源码目录下的`docker-compose.env``docker-compose-base.yml``docker-compose-services.yml``docker-compose-nginx.yml``nginx.conf`上传到服务器的`/spring-microservice-exam/`目录下
将启动脚本`docs/deploy/start.sh`上传到服务器的`/spring-microservice-exam/`目录下
目录结构:
![image](images/deploy/docker_root.png)
修改`docker-compose.env`
包括数据库IP、端口、用户名和密码,fastDfs的IP、端口
![image](images/deploy/config_docker_env.png)
## 运行
1. 登录阿里云Docker Registry
```
$ docker login --username=你的阿里云账号 registry.cn-hangzhou.aliyuncs.com
如:docker login --username=tb70177569 registry.cn-hangzhou.aliyuncs.com
```
2. 拉取镜像并启动:`./start.sh pullrun`
3. 检查是否启动成功:`docker ps`
## 访问
前台地址:ip:80
后台地址:ip:81
## 其它命令
1. 停止容器:`./start.sh stop`
2. 删除所有容器:`./start.sh removeAll`
3. 重启所有容器:`./start.sh restart`
4. 拉取并启动:`./start.sh pullrun`
## 参考资料
- [安装docker](https://www.cnblogs.com/yufeng218/p/8370670.html)
- [安装docker-compose](https://www.jianshu.com/p/94760f35c98c)
- [在线考试系统V3.0镜像构建、推送、部署](http://ehedgehog.net/2019/04/22/%E5%9C%A8%E7%BA%BF%E8%80%83%E8%AF%95%E7%B3%BB%E7%BB%9FV2.0%E9%95%9C%E5%83%8F%E6%9E%84%E5%BB%BA%E3%80%81%E6%8E%A8%E9%80%81%E3%80%81%E9%83%A8%E7%BD%B2/)
\ No newline at end of file
++ /dev/null
主要介绍如何在本地运行项目,包括下载、导入、修改配置、运行项目
#### 环境准备
开发环境:
- jdk:1.8
- MySQL:5.7+
- redis
- rabbitMq
- node.js
- consul
- fastDfs(推荐基于docker安装,安装步骤网上很多)
开发工具:`IntelliJ IDEA``IntelliJ IDEA`需要安装插件:`lombok`
#### 项目下载
1. `git clone`下载[spring-microservice-exam](https://gitee.com/wells2333/spring-microservice-exam.git)[spring-microservice-exam-ui](https://gitee.com/wells2333/spring-microservice-exam-ui.git)[spring-microservice-exam-web](https://gitee.com/wells2333/spring-microservice-exam-web.git)
`git clone https://gitee.com/wells2333/spring-microservice-exam.git`
`git clone https://gitee.com/wells2333/spring-microservice-exam-ui.git`
`git clone https://gitee.com/wells2333/spring-microservice-exam-web.git`
#### 修改配置
1. 修改spring-microservice-exam的config-service的/config文件夹下各服务的配置,主要是数据库、redis和fastDfs,其它配置基本不用动
![image](images/deploy/config.png)
redis的IP和端口号:
![image](images/deploy/config_redis.png)
fastDfs的IP和端口号:
![image](images/deploy/config_fdfs.png)
2. 运行数据库初始化脚本:
`/docs/deploy/mysql/microservice-user.sql`
`/docs/deploy/mysql/microservice-exam.sql`
`/docs/deploy/mysql/microservice-auth.sql`
`/docs/deploy/mysql/microservice-gateway.sql`
#### 启动后端项目
启动项目前要**先确认consul、MySQL、redis、rabbitMq是否已经启动**
按顺序启动:
1. config-service
2. auth-service
3. user-service
4. exam-service
5. gateway-service
需要监控功能再启动:
6. monitor-service
7. msc-service
内存不足的可以限制每个服务的内存:`config-service`可以分配64M(-Xmx64m -Xms64m)、其它服务分配128M(-Xmx128m -Xms128m)
![image](images/deploy/config_xms.png)
#### 启动前端项目
分别在[spring-microservice-exam-ui](https://gitee.com/wells2333/spring-microservice-exam-ui.git)[spring-microservice-exam-web](https://gitee.com/wells2333/spring-microservice-exam-web.git)目录下,命令行运行:
npm install
npm run dev
![image](images/deploy/npm_install.png)
![image](images/deploy/npm_run.png)
`IntelliJ IDEA`导入项目:
![image](images/deploy/import_exam_ui.png)
运行:
![image](images/deploy/import_exam_ui_run.png)
[spring-microservice-exam-web](https://gitee.com/wells2333/spring-microservice-exam-web.git)项目WebStorm导入操作类似
启动成功后访问:
前台:localhost:8080
后台:localhost:9527
默认账号:
1. 管理员:admin/123456
2. 学生:student/123456
3. 教师:teacher/123456
#### 监控
| 名称 | 地址 |
| --------- | -------- |
| rabbitMq监控 | localhost:15672 |
| spring boot admin服务监控 | localhost:8085 |
| zipkin链路跟踪 | localhost:9411 |
| consul | localhost:8500 |
#### 其它
使用keytool生成jwt token密钥库:
```
$ keytool -genkeypair -alias jwt -keyalg RSA -dname "CN=jwt, L=Berlin, S=Berlin, C=DE" -keypass abc123 -keystore jwt.jks -storepass abc123
```
执行下面命令,输入密钥,复制输出的公钥
```
$ keytool -list -rfc --keystore jwt.jks | openssl x509 -inform pem -pubkey
```
++ /dev/null
spring-microservice-exam的模块结构
### 模块说明
```
common -- 系统公共模块
├── common-core -- 系统公共核心模块
├── common-feign -- 系统公共feign模块
├── common-log -- 系统公共日志模块
└── common-security -- 系统公共安全模块,包括资源服务器配置
modules -- 业务模块
|-- auth-service-parent -- 认证授权服务
|-- auth-service-api -- 认证授权服务api
|-- auth-service -- 认证授权服务具体实现
|-- user-service-parent -- 用户服务
|-- user-service-api -- 用户服务api
|-- user-service -- 用户服务具体实现
|── exam-service-parent -- 考试服务
|-- exam-service-api -- 考试服务api
|-- exam-service -- 考试服务具体实现
└── msc-service-parent -- 消息中心
|-- msc-service-api -- 消息中心api
|-- msc-service -- 消息中心具体实现
config-service -- 配置中心(本地仓库)
gateway-service -- 网关(动态路由)
monitor-service -- spring boot amdin 监控服务
```
`common-core`: 封装通用配置、常量、异常、基础实体等
`common-feign`:封装通用feign配置,用于服务调用间携带access_token
`common-log`:封装日志记录逻辑,异步记录日志
`common-security`: 封装OAuth2.0中的资源服务器通用配置
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"],
"env": {
"development":{
"plugins": []
}
}
}
# http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint'
},
env: {
browser: true,
},
extends: [
'plugin:vue/essential',
'standard'
],
plugins: [
'vue'
],
rules: {
'generator-star-spacing': 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment