调整项目结构
This commit is contained in:
@@ -12,11 +12,7 @@ micro-fast
|
||||
| ├── boot-starter-fastdfs-client -- fastdfs客户端
|
||||
| ├── boot-starter-maven-plugin -- maven的一系列插件
|
||||
| | └── mybatis-generator-extend-maven-plugin -- 用于简化mybatis-generator生成代码的流程
|
||||
| ├── boot-starter-security -- 权限认证
|
||||
| | ├── boot-starter-security-core -- 权限认证核心项目
|
||||
| | ├── boot-starter-security-browser -- 浏览器权限认证
|
||||
| | ├── boot-starter-security-app -- app权限认证
|
||||
| | └── boot-starter-security-demo -- 权限认证示例项目
|
||||
| ├── boot-starter-security-oauth -- 权限认证
|
||||
| ├── boot-starter-ssm -- ssm公共配置
|
||||
| └── boot-starter-util -- 常用工具
|
||||
├── ms -- 分布式系统
|
||||
@@ -24,9 +20,9 @@ micro-fast
|
||||
| ├── register-center1 -- 高可用注册中心
|
||||
| ├── register-center2 -- 高可用注册中心
|
||||
| ├── gateway -- 服务网关
|
||||
| ├── oauth -- 认证中心
|
||||
| ├── upms -- 权限管理系统
|
||||
| ├── ucenter -- 用户中心
|
||||
| └── cms -- cms系统
|
||||
| └── ucenter -- 用户中心
|
||||
├── ms-web -- 后台管理系统页面
|
||||
├── all-in-one -- ms系统的集中式实现
|
||||
|
||||
@@ -52,6 +48,7 @@ vuex| 3.0.1 | 单向数据流 | [官网](https://vuex.vuejs.org/zh-cn/)
|
||||
axios| 0.17.1 | ajax请求框架 | [github地址](https://github.com/axios/axios)
|
||||
elemnet-ui | 2.0.8 | 前端视图库 | [官网](http://element-cn.eleme.io/#/zh-CN/component/installation)
|
||||
swagger | 2.6.1 | 文档生成 | [官网](https://swagger.io/)
|
||||
lombok | 1.16.6.1|代码工具|[官网](https://projectlombok.org/features/all)
|
||||
## 整体开发进度
|
||||
|
||||
## 各模块的详细介绍
|
||||
|
||||
@@ -104,7 +104,7 @@ var activeTableTab = "activeTableTab";
|
||||
<li>java.lang.Enum<<a href="../../../../../com/micro/fast/common/response/Const.ServerResponseCode.html" title="com.micro.fast.common.response中的枚举">Const.ServerResponseCode</a>></li>
|
||||
<li>
|
||||
<ul class="inheritance">
|
||||
<li>com.micro.fast.common.response.BaseConst.ServerResponseCode</li>
|
||||
<li>BaseConst.ServerResponseCode</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
<li>java.lang.Object</li>
|
||||
<li>
|
||||
<ul class="inheritance">
|
||||
<li>com.micro.fast.common.response.BaseConst</li>
|
||||
<li>BaseConst</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -101,7 +101,7 @@ var activeTableTab = "activeTableTab";
|
||||
<li>java.lang.Object</li>
|
||||
<li>
|
||||
<ul class="inheritance">
|
||||
<li>com.micro.fast.common.response.ServerResponse<T></li>
|
||||
<li>ServerResponse<T></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<!-- Generated by javadoc (1.8.0_144) on Mon Oct 02 18:41:08 CST 2017 -->
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>类 com.micro.fast.common.response.BaseConst.ServerResponseCode的使用</title>
|
||||
<title>类 BaseConst.ServerResponseCode的使用</title>
|
||||
<meta name="date" content="2017-10-02">
|
||||
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
|
||||
<script type="text/javascript" src="../../../../../../script.js"></script>
|
||||
@@ -13,7 +13,7 @@
|
||||
<script type="text/javascript"><!--
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="\u7C7B com.micro.fast.common.response.BaseConst.ServerResponseCode\u7684\u4F7F\u7528";
|
||||
parent.document.title="\u7C7B BaseConst.ServerResponseCode\u7684\u4F7F\u7528";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
@@ -71,7 +71,7 @@
|
||||
</a></div>
|
||||
<!-- ========= END OF TOP NAVBAR ========= -->
|
||||
<div class="header">
|
||||
<h2 title="类的使用 com.micro.fast.common.response.BaseConst.ServerResponseCode" class="title">类的使用<br>com.micro.fast.common.response.BaseConst.ServerResponseCode</h2>
|
||||
<h2 title="类的使用 BaseConst.ServerResponseCode" class="title">类的使用<br>BaseConst.ServerResponseCode</h2>
|
||||
</div>
|
||||
<div class="classUseContainer">
|
||||
<ul class="blockList">
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<script type="text/javascript"><!--
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="\u7C7B com.micro.fast.common.response.BaseConst\u7684\u4F7F\u7528";
|
||||
parent.document.title="\u7C7B BaseConst\u7684\u4F7F\u7528";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
@@ -71,7 +71,7 @@
|
||||
</a></div>
|
||||
<!-- ========= END OF TOP NAVBAR ========= -->
|
||||
<div class="header">
|
||||
<h2 title="类的使用 com.micro.fast.common.response.BaseConst" class="title">类的使用<br>com.micro.fast.common.response.BaseConst</h2>
|
||||
<h2 title="类的使用 BaseConst" class="title">类的使用<br>BaseConst</h2>
|
||||
</div>
|
||||
<div class="classUseContainer">没有com.micro.fast.common.response.Const的用法</div>
|
||||
<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<script type="text/javascript"><!--
|
||||
try {
|
||||
if (location.href.indexOf('is-external=true') == -1) {
|
||||
parent.document.title="\u7C7B com.micro.fast.common.response.ServerResponse\u7684\u4F7F\u7528";
|
||||
parent.document.title="\u7C7B ServerResponse\u7684\u4F7F\u7528";
|
||||
}
|
||||
}
|
||||
catch(err) {
|
||||
@@ -71,7 +71,7 @@
|
||||
</a></div>
|
||||
<!-- ========= END OF TOP NAVBAR ========= -->
|
||||
<div class="header">
|
||||
<h2 title="类的使用 com.micro.fast.common.response.ServerResponse" class="title">类的使用<br>com.micro.fast.common.response.ServerResponse</h2>
|
||||
<h2 title="类的使用 ServerResponse" class="title">类的使用<br>ServerResponse</h2>
|
||||
</div>
|
||||
<div class="classUseContainer">
|
||||
<ul class="blockList">
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<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>
|
||||
|
||||
<artifactId>boot-starter-common</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>boot-starter-common</name>
|
||||
<description>Spring boot starter</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.micro.fast</groupId>
|
||||
<artifactId>boot-starter</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
<!--<plugin>-->
|
||||
<!--<groupId>org.apache.maven.plugins</groupId>-->
|
||||
<!--<artifactId>maven-javadoc-plugin</artifactId>-->
|
||||
<!--</plugin>-->
|
||||
</plugins>
|
||||
<finalName>boot-starter-common</finalName>
|
||||
</build>
|
||||
</project>
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.micro.fast.common.exception;
|
||||
package com.micro.fast.boot.starter.common.exception;
|
||||
|
||||
|
||||
/**
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.micro.fast.common.exception;
|
||||
package com.micro.fast.boot.starter.common.exception;
|
||||
|
||||
/**
|
||||
* 用户异常类
|
||||
+5
-5
@@ -1,13 +1,12 @@
|
||||
package com.micro.fast.common.exception.handler;
|
||||
package com.micro.fast.boot.starter.common.exception.handler;
|
||||
|
||||
import com.micro.fast.common.exception.SystemException;
|
||||
import com.micro.fast.common.exception.UserException;
|
||||
import com.micro.fast.util.ExceptionUtil;
|
||||
import com.micro.fast.boot.starter.common.exception.SystemException;
|
||||
import com.micro.fast.boot.starter.common.util.ExceptionUtil;
|
||||
import com.micro.fast.boot.starter.common.exception.UserException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -58,4 +57,5 @@ public class BaseExceptionHandlerController {
|
||||
map.put(strings[0],strings[1]);
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -4,4 +4,4 @@
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
package com.micro.fast.common.exception;
|
||||
package com.micro.fast.boot.starter.common.exception;
|
||||
+1
@@ -0,0 +1 @@
|
||||
package com.micro.fast.boot.starter.common;
|
||||
+108
-108
@@ -1,108 +1,108 @@
|
||||
package com.micro.fast.common.response;
|
||||
|
||||
import com.micro.fast.util.ExceptionUtil;
|
||||
|
||||
/**
|
||||
* 数据字典
|
||||
*
|
||||
* @author lishouyu 18332763730@163.com 2017/10/02
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class BaseConst {
|
||||
|
||||
public static final String DEFAULT_VALIDATE_CODE = "888888";
|
||||
|
||||
public static final String BASEMSG_PREFIX = DEFAULT_VALIDATE_CODE+ ExceptionUtil.split;
|
||||
|
||||
/**
|
||||
* 服务器响应数据字典
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统响应码
|
||||
*/
|
||||
public enum SystemResponse {
|
||||
DATABASE_INSERT_FAILURE(00000, "系统错误,请稍后重试");
|
||||
private Integer code;
|
||||
private String msg;
|
||||
|
||||
SystemResponse(Integer code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
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 enum UserResponse {
|
||||
USERNAME_IS_HAVE(10000, "用户名被占用"),
|
||||
EMAIL_IS_HAVE(10001, "邮箱被占用"),
|
||||
TWO_PASSWORD_NOT_SAME(10002,"两次密码不一致");
|
||||
public Integer code;
|
||||
private String msg;
|
||||
|
||||
UserResponse(Integer code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.micro.fast.boot.starter.common.response;
|
||||
|
||||
import com.micro.fast.boot.starter.common.util.ExceptionUtil;
|
||||
|
||||
/**
|
||||
* 数据字典
|
||||
*
|
||||
* @author lishouyu 18332763730@163.com 2017/10/02
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class BaseConst {
|
||||
|
||||
public static final String DEFAULT_VALIDATE_CODE = "888888";
|
||||
|
||||
public static final String BASEMSG_PREFIX = DEFAULT_VALIDATE_CODE+ ExceptionUtil.split;
|
||||
|
||||
/**
|
||||
* 服务器响应数据字典
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统响应码
|
||||
*/
|
||||
public enum SystemResponse {
|
||||
DATABASE_INSERT_FAILURE(00000, "系统错误,请稍后重试");
|
||||
private Integer code;
|
||||
private String msg;
|
||||
|
||||
SystemResponse(Integer code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
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 enum UserResponse {
|
||||
USERNAME_IS_HAVE(10000, "用户名被占用"),
|
||||
EMAIL_IS_HAVE(10001, "邮箱被占用"),
|
||||
TWO_PASSWORD_NOT_SAME(10002,"两次密码不一致");
|
||||
public Integer code;
|
||||
private String msg;
|
||||
|
||||
UserResponse(Integer code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+132
-132
@@ -1,132 +1,132 @@
|
||||
package com.micro.fast.common.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
/**
|
||||
* 统一服务响应类,方法返回值
|
||||
* 序列化中不包含为空值的字段
|
||||
* @author lishouyu 18332763730@163.com 2017/10/02
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class ServerResponse<T> {
|
||||
/**
|
||||
* 获取数据返回的提示数据字典码
|
||||
*/
|
||||
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 BaseConst.ServerResponseCode.SUCCESS.getCode().intValue() == this.code;
|
||||
}
|
||||
|
||||
//请求成功
|
||||
public static <T> ServerResponse<T> success() {
|
||||
|
||||
return new ServerResponse<T>(BaseConst.ServerResponseCode.SUCCESS.getCode());
|
||||
}
|
||||
|
||||
public static <T> ServerResponse<T> successMsg(String msg) {
|
||||
|
||||
return new ServerResponse<T>(
|
||||
BaseConst.ServerResponseCode.SUCCESS.getCode(),
|
||||
msg);
|
||||
}
|
||||
|
||||
public static <T> ServerResponse<T> successData(T data) {
|
||||
|
||||
return new ServerResponse<T>(BaseConst.ServerResponseCode.SUCCESS.getCode(),
|
||||
data);
|
||||
}
|
||||
|
||||
public static <T> ServerResponse<T> successMsgData(String msg, T data) {
|
||||
|
||||
return new ServerResponse<T>(BaseConst.ServerResponseCode.SUCCESS.getCode(),
|
||||
msg, data);
|
||||
}
|
||||
|
||||
//请求失败
|
||||
public static <T> ServerResponse<T> error() {
|
||||
return new ServerResponse<T>(BaseConst.ServerResponseCode.ERROR.getCode());
|
||||
}
|
||||
|
||||
public static <T> ServerResponse<T> errorMsg(String msg) {
|
||||
return new ServerResponse<T>(BaseConst.ServerResponseCode.ERROR.getCode(), msg);
|
||||
}
|
||||
|
||||
public static <T> ServerResponse<T> errorCodeMsg(Integer code, String msg) {
|
||||
return new ServerResponse<T>(code, msg);
|
||||
}
|
||||
}
|
||||
package com.micro.fast.boot.starter.common.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
/**
|
||||
* 统一服务响应类,方法返回值
|
||||
* 序列化中不包含为空值的字段
|
||||
* @author lishouyu 18332763730@163.com 2017/10/02
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class ServerResponse<T> {
|
||||
/**
|
||||
* 获取数据返回的提示数据字典码
|
||||
*/
|
||||
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 BaseConst.ServerResponseCode.SUCCESS.getCode().intValue() == this.code;
|
||||
}
|
||||
|
||||
//请求成功
|
||||
public static <T> ServerResponse<T> success() {
|
||||
|
||||
return new ServerResponse<T>(BaseConst.ServerResponseCode.SUCCESS.getCode());
|
||||
}
|
||||
|
||||
public static <T> ServerResponse<T> successMsg(String msg) {
|
||||
|
||||
return new ServerResponse<T>(
|
||||
BaseConst.ServerResponseCode.SUCCESS.getCode(),
|
||||
msg);
|
||||
}
|
||||
|
||||
public static <T> ServerResponse<T> successData(T data) {
|
||||
|
||||
return new ServerResponse<T>(BaseConst.ServerResponseCode.SUCCESS.getCode(),
|
||||
data);
|
||||
}
|
||||
|
||||
public static <T> ServerResponse<T> successMsgData(String msg, T data) {
|
||||
|
||||
return new ServerResponse<T>(BaseConst.ServerResponseCode.SUCCESS.getCode(),
|
||||
msg, data);
|
||||
}
|
||||
|
||||
//请求失败
|
||||
public static <T> ServerResponse<T> error() {
|
||||
return new ServerResponse<T>(BaseConst.ServerResponseCode.ERROR.getCode());
|
||||
}
|
||||
|
||||
public static <T> ServerResponse<T> errorMsg(String msg) {
|
||||
return new ServerResponse<T>(BaseConst.ServerResponseCode.ERROR.getCode(), msg);
|
||||
}
|
||||
|
||||
public static <T> ServerResponse<T> errorCodeMsg(Integer code, String msg) {
|
||||
return new ServerResponse<T>(code, msg);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -4,4 +4,4 @@
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
package com.micro.fast.common.response;
|
||||
package com.micro.fast.boot.starter.common.response;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.micro.fast.util;
|
||||
package com.micro.fast.boot.starter.common.util;
|
||||
|
||||
/**
|
||||
* 对异常处理的工具类
|
||||
+1
@@ -0,0 +1 @@
|
||||
package com.micro.fast.boot.starter.common.util;
|
||||
@@ -53,6 +53,11 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.micro.fast</groupId>
|
||||
<artifactId>boot-starter-common</artifactId>
|
||||
<version>${micro.fast.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
||||
+1
-7
@@ -1,15 +1,9 @@
|
||||
package com.micro.fast.security.app.controller;
|
||||
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.security.app.master.SecurityConstants;
|
||||
import com.micro.fast.security.app.master.SecurityProperties;
|
||||
import com.micro.fast.security.app.reponse.ServerResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.web.DefaultRedirectStrategy;
|
||||
import org.springframework.security.web.RedirectStrategy;
|
||||
import org.springframework.security.web.savedrequest.HttpSessionRequestCache;
|
||||
import org.springframework.security.web.savedrequest.RequestCache;
|
||||
import org.springframework.security.web.savedrequest.SavedRequest;
|
||||
|
||||
-133
@@ -1,133 +0,0 @@
|
||||
package com.micro.fast.security.app.reponse;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
/**
|
||||
* 统一服务响应类,方法返回值
|
||||
* 序列化中不包含为空值的字段
|
||||
* 0表示成功,1表示失败
|
||||
* @author lishouyu 18332763730@163.com 2017/10/02
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_EMPTY)
|
||||
public class ServerResponse<T> {
|
||||
/**
|
||||
* 获取数据返回的提示数据字典码
|
||||
*/
|
||||
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 0 == this.code;
|
||||
}
|
||||
|
||||
//请求成功
|
||||
public static <T> ServerResponse<T> success() {
|
||||
|
||||
return new ServerResponse<T>(0);
|
||||
}
|
||||
|
||||
public static <T> ServerResponse<T> successMsg(String msg) {
|
||||
|
||||
return new ServerResponse<T>(
|
||||
0,
|
||||
msg);
|
||||
}
|
||||
|
||||
public static <T> ServerResponse<T> successData(T data) {
|
||||
|
||||
return new ServerResponse<T>(0,
|
||||
data);
|
||||
}
|
||||
|
||||
public static <T> ServerResponse<T> successMsgData(String msg, T data) {
|
||||
|
||||
return new ServerResponse<T>(0,
|
||||
msg, data);
|
||||
}
|
||||
|
||||
//请求失败
|
||||
public static <T> ServerResponse<T> error() {
|
||||
return new ServerResponse<T>(1);
|
||||
}
|
||||
|
||||
public static <T> ServerResponse<T> errorMsg(String msg) {
|
||||
return new ServerResponse<T>(1, msg);
|
||||
}
|
||||
|
||||
public static <T> ServerResponse<T> errorCodeMsg(Integer code, String msg) {
|
||||
return new ServerResponse<T>(code, msg);
|
||||
}
|
||||
}
|
||||
@@ -94,6 +94,11 @@
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.micro.fast</groupId>
|
||||
<artifactId>boot-starter-common</artifactId>
|
||||
<version>${micro.fast.version}</version>
|
||||
</dependency>
|
||||
<!--测试-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>boot-starter-common</module>
|
||||
<module>boot-starter-util</module>
|
||||
<module>boot-starter-maven-plugin</module>
|
||||
<module>boot-starter-fastdfs-client</module>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.micro.fast.oauth.feign;
|
||||
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.oauth.dto.UpmsUser;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -18,5 +19,5 @@ public interface UpmsUserService {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/upms/user/{username}")
|
||||
UpmsUser getUserByUserName(@PathVariable(name = "username") String username);
|
||||
ServerResponse<UpmsUser> getUserByUserName(@PathVariable(name = "username") String username);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.micro.fast.oauth.impl;
|
||||
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.oauth.dto.UpmsUser;
|
||||
import com.micro.fast.oauth.feign.UpmsUserService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -23,7 +24,8 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
UpmsUser upmsUser = upmsUserService.getUserByUserName(username);
|
||||
ServerResponse<UpmsUser> userByUserName = upmsUserService.getUserByUserName(username);
|
||||
UpmsUser upmsUser = userByUserName.getData();
|
||||
//判断用户是否存在
|
||||
if (upmsUser!=null){
|
||||
if( StringUtils.equals(username,upmsUser.getUsername())){
|
||||
|
||||
@@ -20,6 +20,11 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.micro.fast</groupId>
|
||||
<artifactId>boot-starter-common</artifactId>
|
||||
<version>${micro.fast.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -6,6 +6,8 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.cloud.client.SpringCloudApplication;
|
||||
import org.springframework.cloud.netflix.feign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
/**
|
||||
* @author lsy
|
||||
@@ -23,5 +25,9 @@ public class UpmsApplication {
|
||||
* 密码加密的bean
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public BCryptPasswordEncoder bCryptPasswordEncoder(){
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.micro.fast.upms.controller;
|
||||
|
||||
import com.micro.fast.common.exception.UserException;
|
||||
import com.micro.fast.common.response.ServerResponse;
|
||||
import com.micro.fast.boot.starter.common.exception.UserException;
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.upms.dao.UpmsUserMapper;
|
||||
import com.micro.fast.upms.pojo.UpmsUser;
|
||||
import com.micro.fast.upms.service.UpmsUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.FieldError;
|
||||
@@ -19,6 +21,7 @@ import javax.validation.Valid;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "/upms/user")
|
||||
@Api(description = "后台用户api")
|
||||
public class UpmsUserController {
|
||||
|
||||
/**
|
||||
@@ -36,7 +39,8 @@ public class UpmsUserController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
public ServerResponse<UpmsUser> register(@Valid UpmsUser upmsUser,BindingResult errors
|
||||
@ApiOperation(value = "后台用户注册")
|
||||
public ServerResponse<UpmsUser> register(@Valid UpmsUser upmsUser,BindingResult errors
|
||||
, @RequestParam(defaultValue = "") String repeatPassword) {
|
||||
//对参数的校验抛出异常
|
||||
if (errors.hasErrors()) {
|
||||
@@ -48,9 +52,18 @@ public class UpmsUserController {
|
||||
ServerResponse<UpmsUser> register = upmsUserService.register(upmsUser, repeatPassword);
|
||||
return register;
|
||||
}
|
||||
|
||||
@GetMapping("/{username}")
|
||||
public UpmsUser getUserName(@PathVariable(name = "username") String username){
|
||||
@ApiOperation(value = "根据用户名称获取用户详细信息")
|
||||
public ServerResponse getUserByName(@PathVariable(name = "username") String username){
|
||||
UpmsUser upmsUser = upmsUserMapper.selectByUsername(username);
|
||||
return upmsUser;
|
||||
if (upmsUser ==null){
|
||||
return ServerResponse.errorMsg("该用户不存在!");
|
||||
}
|
||||
if (upmsUser.getLocked() == 1){
|
||||
return ServerResponse.errorMsg("账户被锁定");
|
||||
}
|
||||
upmsUser.setPassword(null);
|
||||
return ServerResponse.successData(upmsUser);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.micro.fast.upms.controller.handler;
|
||||
|
||||
import com.micro.fast.common.exception.handler.BaseExceptionHandlerController;
|
||||
import com.micro.fast.boot.starter.common.exception.handler.BaseExceptionHandlerController;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.micro.fast.upms.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.micro.fast.common.response.BaseConst;
|
||||
import com.micro.fast.boot.starter.common.response.BaseConst;
|
||||
import org.hibernate.validator.constraints.Email;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.micro.fast.upms.service;
|
||||
|
||||
import com.micro.fast.common.response.ServerResponse;
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.upms.pojo.UpmsUser;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
package com.micro.fast.upms.service.impl;
|
||||
|
||||
import com.micro.fast.common.exception.SystemException;
|
||||
import com.micro.fast.common.exception.UserException;
|
||||
import com.micro.fast.common.response.BaseConst.SystemResponse;
|
||||
import com.micro.fast.common.response.BaseConst.UserResponse;
|
||||
import com.micro.fast.common.response.ServerResponse;
|
||||
import com.micro.fast.boot.starter.common.exception.SystemException;
|
||||
import com.micro.fast.boot.starter.common.exception.UserException;
|
||||
import com.micro.fast.boot.starter.common.response.BaseConst.SystemResponse;
|
||||
import com.micro.fast.boot.starter.common.response.BaseConst.UserResponse;
|
||||
import com.micro.fast.boot.starter.common.response.ServerResponse;
|
||||
import com.micro.fast.upms.dao.UpmsUserMapper;
|
||||
import com.micro.fast.upms.pojo.UpmsUser;
|
||||
import com.micro.fast.upms.service.UpmsUserService;
|
||||
import com.micro.fast.util.ExceptionUtil;
|
||||
import com.micro.fast.boot.starter.common.util.ExceptionUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@@ -22,12 +23,15 @@ public class UpmsUserServiceImpl implements UpmsUserService {
|
||||
@Autowired
|
||||
private UpmsUserMapper upmsUserMapper;
|
||||
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
@Override
|
||||
public ServerResponse<UpmsUser> register(UpmsUser upmsUser, String repeatPassword){
|
||||
ServerResponse checkUsername = checkUsername(upmsUser.getUsername());
|
||||
ServerResponse checkEmail = checkEmail(upmsUser.getEmail());
|
||||
//校验两次输入密码是否一致
|
||||
if (upmsUser.getPassword().equals(repeatPassword)){
|
||||
if (!upmsUser.getPassword().equals(repeatPassword)){
|
||||
throw new UserException(ExceptionUtil.contactCodeMsg(
|
||||
UserResponse.TWO_PASSWORD_NOT_SAME.getCode(),
|
||||
UserResponse.TWO_PASSWORD_NOT_SAME.getMsg()
|
||||
@@ -47,8 +51,10 @@ public class UpmsUserServiceImpl implements UpmsUserService {
|
||||
,UserResponse.EMAIL_IS_HAVE.getMsg()));
|
||||
}
|
||||
upmsUser.setCtime(Long.valueOf(System.currentTimeMillis()));
|
||||
//todo 对密码进行加密处理
|
||||
|
||||
String encode = passwordEncoder.encode(upmsUser.getPassword());
|
||||
upmsUser.setPassword(encode);
|
||||
byte loacked = 0;
|
||||
upmsUser.setLocked(loacked);
|
||||
int i = upmsUserMapper.insertSelective(upmsUser);
|
||||
//是否插入成功
|
||||
if (i<1){
|
||||
@@ -82,5 +88,4 @@ public class UpmsUserServiceImpl implements UpmsUserService {
|
||||
return ServerResponse.success();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user