Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@
logs



15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# 更新日志 CHANGELOG

## [V1.3.0-RELEASE]

### ⭐️ New Features

### ⚡️ Optimization

### 📝 Added/Modified


### 📔 Documentation

### 🔨 Dependency Upgrades
- Upgrade to `Fastjson` 1.2.61


## [V1.2.3-RELEASE] 2019.09.09 :computer:
> spring-boot-plusV1.2.3发布,CentOS快速安装环境/构建/部署/启动项目

Expand Down
1 change: 1 addition & 0 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ tail -f -n 1000 /root/spring-boot-plus-server/logs/spring-boot-plus.log
```

## spring-boot-plus 视频 :movie_camera:
- [5分钟完成增删改查](https://www.bilibili.com/video/av67401204)
- [CentOS 快速安装 JDK/Git/Maven/Redis/MySQL](https://www.bilibili.com/video/av67218836/)
- [CentOS 快速部署/构建/打包/运行项目](https://www.bilibili.com/video/av67218970/)

Expand Down
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,11 @@ tail -f -n 1000 /root/spring-boot-plus-server/logs/spring-boot-plus.log
```


## spring-boot-plus Video :movie_camera:
## spring-boot-plus Videos :movie_camera:
- [5-Minutes-Finish-CRUD](https://www.bilibili.com/video/av67401204)
- [CentOS Quick Installation JDK/Git/Maven/Redis/MySQL](https://www.bilibili.com/video/av67218836/)
- [CentOS Quick Build / Deploy / Launch Spring-boot-plus Project](https://www.bilibili.com/video/av67218970/)


## Contact
- Email: [springbootplus@aliyun.com](mailto:springbootplus@aliyun.com)
- QQ Group

![spring-boot-plus QQ Group](https://raw.githubusercontent.com/geekidea/spring-boot-plus/master/docs/img/spring-boot-plus-qq-group.png)


## License
spring-boot-plus is under the Apache 2.0 license. See the [LICENSE](https://github.com/geekidea/spring-boot-plus/blob/master/LICENSE) file for details.
58 changes: 45 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<groupId>io.geekidea</groupId>
<artifactId>spring-boot-plus</artifactId>
<version>1.2.3.RELEASE</version>
<version>1.3.0.RELEASE</version>
<packaging>jar</packaging>

<name>spring-boot-plus</name>
Expand All @@ -47,7 +47,7 @@
<project.reporting.outputEncoding>${utf8}</project.reporting.outputEncoding>
<project-parent.version>${parent.version}</project-parent.version>
<java.version>1.8</java.version>
<spring-boot.version>2.1.8.RELEASE</spring-boot.version>
<spring-boot.version>2.1.0.RELEASE</spring-boot.version>
<mybatis-plus-boot-starter.version>3.2.0</mybatis-plus-boot-starter.version>
<fastjson.version>1.2.60</fastjson.version>
<swagger2.version>2.6.1</swagger2.version>
Expand All @@ -67,6 +67,7 @@
<spring-boot-admin.version>2.1.6</spring-boot-admin.version>
<hutool.version>4.6.4</hutool.version>
<junit.version>4.12</junit.version>
<mapstruct.version>1.3.0.Final</mapstruct.version>

<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
Expand Down Expand Up @@ -239,12 +240,6 @@
<artifactId>snakeyaml</artifactId>
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>${jwt.version}</version>
</dependency>

<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
Expand All @@ -256,6 +251,12 @@
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>${spring-boot-admin.version}</version>
<exclusions>
<exclusion>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-cloud</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
Expand All @@ -265,12 +266,44 @@
<!-- spring boot admin end -->

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
<groupId>org.ini4j</groupId>
<artifactId>ini4j</artifactId>
<version>0.5.4</version>
</dependency>

<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
<scope>provided</scope>
</dependency>

<!-- Shiro JWT start -->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring-boot-web-starter</artifactId>
<version>1.4.0</version>
</dependency>

<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.8.3</version>
</dependency>

<!-- <dependency>-->
<!-- <groupId>io.jsonwebtoken</groupId>-->
<!-- <artifactId>jjwt</artifactId>-->
<!-- <version>${jwt.version}</version>-->
<!-- </dependency>-->

<!-- Spring Security JWT start -->

</dependencies>

<build>
Expand Down Expand Up @@ -387,7 +420,6 @@
</executions>
</plugin>


</plugins>

</build>
Expand Down
2 changes: 1 addition & 1 deletion src/bin/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ STARTUP_LOG="${STARTUP_LOG}application JAVA_OPT : ${JAVA_OPT}\n"


# 打印启动命令
STARTUP_LOG="${STARTUP_LOG}application background startup command: nohup java ${JAVA_OPT} -jar ${BASE_PATH}/lib/${APPLICATION_JAR} --spring.config.location=${CONFIG_DIR} > ${LOG_PATH} 2>&1 &\n"
STARTUP_LOG="${STARTUP_LOG}application background startup command: nohup java ${JAVA_OPT} -jar ${BASE_PATH}/lib/${APPLICATION_JAR} --spring.config.location=${CONFIG_DIR} --logging.config=${CONFIG_DIR}logback.xml > ${LOG_PATH} 2>&1 &\n"


#======================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ public enum ApiCode {

NOT_PERMISSION(403, "没有权限"),

NOT_FOUND(404, "你请求的路径不存在"),
NOT_FOUND(404, "你请求的资源不存在"),

FAIL(500, "操作失败"),


LOGIN_EXCEPTION(4000,"登陆失败"),


SYSTEM_EXCEPTION(5000,"系统异常!"),

PARAMETER_EXCEPTION(5001,"请求参数校验异常"),
Expand All @@ -44,7 +48,6 @@ public enum ApiCode {

HTTP_MEDIA_TYPE_EXCEPTION(5003,"HTTP Media 类型异常"),

SYSTEM_LOGIN_EXCEPTION(5005,"系统登录异常")

;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ public static ApiResult ok(Object data){
return result(ApiCode.SUCCESS,data);
}

public static ApiResult ok(String key,Object value){
public static ApiResult ok(Object data,String msg){
return result(ApiCode.SUCCESS,msg,data);
}

public static ApiResult okMap(String key,Object value){
Map<String,Object> map = new HashMap<>();
map.put(key,value);
return ok(map);
Expand Down Expand Up @@ -122,4 +126,7 @@ public static ApiResult fail(String key,Object value){
return result(ApiCode.FAIL,map);
}

public static ApiResult fail() {
return fail(ApiCode.FAIL);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,25 @@ public interface CommonConstant {
/**
* 登陆token
*/
String TOKEN = "token";
String JWT_TOKEN_NAME = "token";

/**
* JWT用户名
*/
String JWT_USERNAME = "username";


/**
* 刷新token
* JWT刷新新token响应状态码
*/
String REFRESH_TOKEN = "refresh_token";
int JWT_REFRESH_TOKEN_CODE = 460;

/**
* JWT刷新新token响应状态码,
* Redis中不存在,但jwt未过期,不生成新的token,返回361状态码
*/
int JWT_INVALID_TOKEN_CODE = 461;


/**
* 初始密码
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,23 @@
public interface CommonRedisKey {

/**
* 系统登录用户
* 登陆用户token信息key
*/
String LOGIN_SYS_USER = "login:sys:user:%s";
String LOGIN_TOKEN = "login:token:%s";

/**
* 登陆用户信息key
*/
String LOGIN_USER = "login:user:%s";

/**
* 登陆用户盐值信息key
*/
String LOGIN_SALT= "login:salt:%s";

/**
* 系统登录token
* 登陆user hash key
*/
String LOGIN_TOKEN = "login:token";
String LOGIN_USER_HASH = "login:user:hash";

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,18 @@

package io.geekidea.springbootplus.common.exception;

import org.apache.commons.lang3.StringUtils;

/**
* 业务异常
* @author geekidea
* @date 2018-11-08
*/
public class BusinessException extends RuntimeException{
private Integer code;
public BusinessException() {
}
public class BusinessException extends SpringBootPlusException{

public BusinessException(String message) {
super(message);
}

public BusinessException(Integer code ,String message){
this(StringUtils.isBlank(message)?String.valueOf(code):message);
this.code=code;
}

public Integer getCode() {
return code;
public BusinessException(Integer errorCode, String message) {
super(errorCode,message);
}

public void setCode(Integer code) {
this.code = code;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.geekidea.springbootplus.common.exception;

/**
* DAO异常
* @author geekidea
* @date 2018-11-08
*/
public class DaoException extends SpringBootPlusException{

public DaoException(String message) {
super(message);
}
public DaoException(Integer errorCode, String message) {
super(errorCode,message);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
* 全局Error/404处理
Expand All @@ -38,9 +41,24 @@ public class GlobalErrorController implements ErrorController {
private static final String ERROR_PATH = "/error";

@RequestMapping(ERROR_PATH)
public ApiResult handleError(){
log.error("404 NOT FOUND");
return ApiResult.fail(ApiCode.NOT_FOUND);
public ApiResult handleError(HttpServletRequest request,HttpServletResponse response){
int status = response.getStatus();
log.info("response status = " + status);
switch (status){
case HttpServletResponse.SC_UNAUTHORIZED:
log.error("Unauthorized");
return ApiResult.fail(ApiCode.UNAUTHORIZED);
case HttpServletResponse.SC_FORBIDDEN:
log.error("Permission denied");
return ApiResult.fail(ApiCode.NOT_PERMISSION);
case HttpServletResponse.SC_NOT_FOUND:
log.error("404 NOT FOUND");
return ApiResult.fail(ApiCode.NOT_FOUND);
default:
log.error("ERROR...");
break;
}
return ApiResult.fail(ApiCode.FAIL);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public ApiResult handleMethodArgumentNotValidExceptionHandler(MethodArgumentNotV
@ResponseStatus(HttpStatus.OK)
public ApiResult sysLoginExceptionHandler(SysLoginException exception) {
log.warn("系统登录异常:" + exception.getMessage());
return ApiResult.fail(ApiCode.SYSTEM_LOGIN_EXCEPTION);
return ApiResult.fail(ApiCode.LOGIN_EXCEPTION);
}


Expand Down
Loading