From 10197f72667ff1331f38e38cdf58c4c408c3390e Mon Sep 17 00:00:00 2001
From: lsy <18332763730@163.com>
Date: Sat, 9 Sep 2017 22:28:03 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 74 ++++++++---
common/pom.xml | 9 +-
.../fast/common/config/DataSourceConfig.java | 3 +-
.../config/param/MybatisParamConfig.java | 9 ++
.../com/micro/fast/common/response/Const.java | 30 +++++
.../fast/common/response/ServerResponse.java | 125 ++++++++++++++++++
.../micro/fast/common/util/AESUtilTest.java | 2 +-
7 files changed, 221 insertions(+), 31 deletions(-)
create mode 100644 common/src/main/java/com/micro/fast/common/response/Const.java
create mode 100644 common/src/main/java/com/micro/fast/common/response/ServerResponse.java
diff --git a/README.md b/README.md
index af6e1a1..017c73c 100644
--- a/README.md
+++ b/README.md
@@ -1,21 +1,53 @@
-**可以使用传统方式运行,可以使用docker
-容器的方式运行。程序的启动顺序是配置中心,
-注册中心,其他服务。无论是使何种方式运行,
-保证除配置中心外,其他所有服务都能从配置中
-加载到对应的配置文件,其他所有的服务都能注
-册到注册中心。所以运行的时候一定要将除配置
-中心外所有服务的注册空间的配置空间都指定正
-确,本项目中本地运行时则是都指定到本机的
-ip地址**
-###本项目开发的相关约定
-
-###配置中心 端口号 9999 监控 19999
-www.config.server.com
-###注册中心 端口号 10002 监控 20002
-www.eureka.server.com
-###注册中心2 端口号 10003 监控 20003
-www.eureka.server2.com
-###用户权限管理中心 端口号 10004 监控 20004
-www.upms.com
-###后台管理界面
-manage-system
+
欢迎查看micro-fast项目说明
+
+
+ 项目简介
+ 本项目使用mybatis,spring系列框架作为基础,致力于打造一套中小企业分布式系统解决方案.借助于springCould微服务
+ 框架,对原框架进行整合扩展使用云架构进行开发.
+
+ 模块介绍
+
+ SSM公共模块 common
+ common模块对SSM框架进行了整合,借助springboot实现了模块的热插拔,具有可复用性和可扩展性
+
+
+ 配置中心 config-server
+ 配置中心默认启动端口号9999,健康检查端口号19999.访问地址www.config.server.com
+
+
+ 注册中心 eureka-sever
+ 注册中心默认启动端口号10002,健康检查端口号20002.访问地址www.eureka.server.com.为保证服务的稳定可靠,
+ 可以创建多个注册中心,实现服务注册的备份冗余,实现高可用性
+
+
+ 注册中心2 eureka-sever2
+ 注册中心2默认启动端口号10003,健康检查端口号20003.访问地址www.eureka.server2.com.
+
+
+ 用户权限管理中心 upms
+ 用户权限管理中心默认启动端口号10004,健康检查端口号20004.访问地址www.upms.com
+
+
+ 后台管理界面 manage-system
+ 使用react.js搭建后台管理界面
+
+
+
+
+ 项目相关约束
+ 遵循类似于springboot约定大与配置的原则.本项目开发约束如下:
+
关于使用docker方式运行项目
+ 可以使用传统方式运行,可以使用docker
+ 容器的方式运行。程序的启动顺序是配置中心,
+ 注册中心,其他服务。无论是使何种方式运行,
+ 保证除配置中心外,其他所有服务都能从配置中
+ 加载到对应的配置文件,其他所有的服务都能注
+ 册到注册中心。所以运行的时候一定要将除配置
+ 中心外所有服务的注册空间的配置空间都指定正
+ 确,本项目中本地运行时则是都指定到本机的
+ ip地址
+
+
+
+
+
diff --git a/common/pom.xml b/common/pom.xml
index de93459..1ce3ed8 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -87,21 +87,18 @@
org.apache.tomcat.embed
tomcat-embed-el
-
com.google.guava
guava
20.0
-
org.apache.commons
commons-lang3
3.5
-
commons-collections
@@ -114,22 +111,19 @@
joda-time
2.3
-
org.hashids
hashids
1.0.1
-
commons-net
commons-net
3.1
-
-
+
commons-fileupload
commons-fileupload
@@ -163,7 +157,6 @@
spring-boot-starter-test
test
-
diff --git a/common/src/main/java/com/micro/fast/common/config/DataSourceConfig.java b/common/src/main/java/com/micro/fast/common/config/DataSourceConfig.java
index 56b6f68..2ec182f 100644
--- a/common/src/main/java/com/micro/fast/common/config/DataSourceConfig.java
+++ b/common/src/main/java/com/micro/fast/common/config/DataSourceConfig.java
@@ -6,6 +6,7 @@ import com.alibaba.druid.support.http.WebStatFilter;
import com.alibaba.druid.support.spring.stat.DruidStatInterceptor;
import com.micro.fast.common.config.param.DruidParamConfig;
import com.micro.fast.common.config.param.JdbcConnectionParamConfig;
+import com.micro.fast.common.util.AESUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -133,7 +134,7 @@ public class DataSourceConfig {
DruidDataSource druidDataSource = new DruidDataSource();
//数据库连接的相关配置
druidDataSource.setUsername(jdbcConnectionParamConfig.getUsername());
- druidDataSource.setPassword(jdbcConnectionParamConfig.getPassword());
+ druidDataSource.setPassword(AESUtil.AESDecode(jdbcConnectionParamConfig.getPassword()));
druidDataSource.setUrl(jdbcConnectionParamConfig.getUrl());
druidDataSource.setDriverClassName(jdbcConnectionParamConfig.getDriverClass());
//连接池的具体配置
diff --git a/common/src/main/java/com/micro/fast/common/config/param/MybatisParamConfig.java b/common/src/main/java/com/micro/fast/common/config/param/MybatisParamConfig.java
index 0954cb0..3be8b91 100644
--- a/common/src/main/java/com/micro/fast/common/config/param/MybatisParamConfig.java
+++ b/common/src/main/java/com/micro/fast/common/config/param/MybatisParamConfig.java
@@ -8,6 +8,15 @@ import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
+/**
+ * mybatis配置参数
+ * create by lishouyu 2017/09/09
+ * email 18332763730@163.com
+ *
+ * last edit lishouyu 2017/09/09
+ * email 18332763730@163.com
+ *
+ */
@Configuration
@AutoConfigureBefore(com.micro.fast.common.config.SqlSessionFactoryConfig.class)
@ConfigurationProperties(prefix = "mybatis")
diff --git a/common/src/main/java/com/micro/fast/common/response/Const.java b/common/src/main/java/com/micro/fast/common/response/Const.java
new file mode 100644
index 0000000..7ffc259
--- /dev/null
+++ b/common/src/main/java/com/micro/fast/common/response/Const.java
@@ -0,0 +1,30 @@
+package com.micro.fast.common.response;
+
+/**
+ * 数据字典
+ * create by lishouyu 2017/09/09
+ * email 18332763730@163.com
+ *
+ * last edit lishouyu 2017/09/09
+ * email 18332763730@163.com
+ *
+ */
+public class Const {
+ //服务器响应数据字典
+ public enum ServerResponseCode{
+ SUCCESS(0,"SUCCESS"),//获取数据成功
+ ERROR(1,"ERROR");//获取数据失败
+ private Integer code;
+ private String msg;
+ ServerResponseCode(Integer code, String msg) {
+ this.code = code;
+ this.msg = msg;
+ }
+ public Integer getCode() {
+ return code;
+ }
+ public String getMsg() {
+ return msg;
+ }
+ }
+}
diff --git a/common/src/main/java/com/micro/fast/common/response/ServerResponse.java b/common/src/main/java/com/micro/fast/common/response/ServerResponse.java
new file mode 100644
index 0000000..931ba53
--- /dev/null
+++ b/common/src/main/java/com/micro/fast/common/response/ServerResponse.java
@@ -0,0 +1,125 @@
+package com.micro.fast.common.response;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+/**
+ * mybatis参数配置
+ * create by lishouyu 2017/09/09
+ * email 18332763730@163.com
+ *
+ * last edit lishouyu 2017/09/09
+ * email 18332763730@163.com
+ *
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)//序列化中不包含为空的字段
+public class ServerResponse {
+ private Integer code;//获取数据返回的提示数据字典码
+ private String msg; //获取数据成功或者失败的时候提示的消息
+ T data;
+
+ /**
+ * 所有的构造方法均为私有,不允许外部直接调用构造方法
+ */
+ public ServerResponse() {
+
+ }
+
+ private ServerResponse(Integer code) {
+ this(code, null, null);
+ }
+
+ private ServerResponse(Integer code, String msg) {
+ this(code, msg, null);
+ }
+
+ /**
+ * 为了避免T 为string的时候调用的是 上面的构造方法,需要对构造方法进行包装。构造方法设置为私有,不允许外部调用
+ *
+ * @param code
+ * @param data
+ */
+ private ServerResponse(Integer code, T data) {
+ this(code, null, data);
+ }
+
+ private ServerResponse(Integer code, String msg, T data) {
+ this.code = code;
+ this.msg = msg;
+ this.data = data;
+ }
+
+ public Integer getCode() {
+ return code;
+ }
+
+ public void setCode(Integer code) {
+ this.code = code;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+
+ public void setMsg(String msg) {
+ this.msg = msg;
+ }
+
+ public T getData() {
+ return data;
+ }
+
+ public void setData(T data) {
+ this.data = data;
+ }
+
+ /**
+ * 返回代码是小于等于0的时候表示请求数据失败,或者进行验证时失败
+ *
+ * @return
+ */
+ @JsonIgnore //使其不再json序列化结果之中
+ public boolean isSuccess() {
+ return Const.ServerResponseCode.SUCCESS.getCode() == this.code;
+ }
+
+ //请求成功
+ public static ServerResponse success() {
+
+ return new ServerResponse(Const.ServerResponseCode.SUCCESS.getCode());
+ }
+
+ public static ServerResponse successMsg(String msg) {
+
+ return new ServerResponse(
+ Const.ServerResponseCode.SUCCESS.getCode(),
+ msg);
+ }
+
+ public static ServerResponse successData(T data) {
+
+ return new ServerResponse(Const.ServerResponseCode.SUCCESS.getCode(),
+ data);
+ }
+
+ public static ServerResponse successMsgData(String msg, T data) {
+
+ return new ServerResponse(Const.ServerResponseCode.SUCCESS.getCode(),
+ msg, data);
+ }
+
+ //请求失败
+ public static ServerResponse error() {
+ return new ServerResponse(Const.ServerResponseCode.ERROR.getCode());
+ }
+
+ public static ServerResponse errorMsg(String msg) {
+ return new ServerResponse(Const.ServerResponseCode.ERROR.getCode(), msg);
+ }
+
+ public static ServerResponse errorCodeMsg(Integer code, String msg) {
+ return new ServerResponse(code, msg);
+ }
+}
diff --git a/common/src/test/java/com/micro/fast/common/util/AESUtilTest.java b/common/src/test/java/com/micro/fast/common/util/AESUtilTest.java
index 39e28db..fbfbc58 100644
--- a/common/src/test/java/com/micro/fast/common/util/AESUtilTest.java
+++ b/common/src/test/java/com/micro/fast/common/util/AESUtilTest.java
@@ -11,7 +11,7 @@ public class AESUtilTest {
System.out.println("key | AESEncode | AESDecode");
for (String key : keys) {
System.out.print(key+" | ");
- String aesEncode = AESUtil.AESEncode("li");
+ String aesEncode = AESUtil.AESEncode("studyj2e");
System.out.print(aesEncode+" | ");
String aesDecode = AESUtil.AESDecode(aesEncode);
System.out.println(aesDecode);