parent
3de49b1a76
commit
d40eb1a105
@ -0,0 +1,25 @@
|
|||||||
|
<?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">
|
||||||
|
<parent>
|
||||||
|
<artifactId>opsli-boot-parent</artifactId>
|
||||||
|
<groupId>org.opsliframework.boot</groupId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>opsli-core</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- 引入公用模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.opsliframework.boot</groupId>
|
||||||
|
<artifactId>opsli-common</artifactId>
|
||||||
|
<version>${version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,48 @@
|
|||||||
|
package org.opsli.core.handler;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.opsli.common.api.ResultVo;
|
||||||
|
import org.opsli.common.exception.EmptyException;
|
||||||
|
import org.opsli.common.exception.ServiceException;
|
||||||
|
import org.springframework.core.annotation.Order;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author parker
|
||||||
|
* @date 2020-09-13
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@ControllerAdvice
|
||||||
|
@Order(-1)
|
||||||
|
public class GlobalExceptionHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拦截业务异常
|
||||||
|
*/
|
||||||
|
@ExceptionHandler(ServiceException.class)
|
||||||
|
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||||
|
@ResponseBody
|
||||||
|
public ResultVo bussinessException(ServiceException e) {
|
||||||
|
log.warn("业务异常 - 异常编号:{} - 异常信息:{}",e.getCode(),e.getMessage());
|
||||||
|
ResultVo errorR = ResultVo.error(e.getMessage());
|
||||||
|
errorR.setCode(e.getCode());
|
||||||
|
return errorR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拦截空异常
|
||||||
|
*/
|
||||||
|
@ExceptionHandler(EmptyException.class)
|
||||||
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
|
@ResponseBody
|
||||||
|
public ResultVo bussinessException(EmptyException e) {
|
||||||
|
ResultVo errorR = ResultVo.error(e.getMessage());
|
||||||
|
errorR.setCode(e.getCode());
|
||||||
|
return errorR;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package org.opsli.core.msg;
|
||||||
|
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
|
import org.opsli.common.base.msg.BaseMsg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: opsli-boot
|
||||||
|
* @BelongsPackage: org.opsli.core.msg
|
||||||
|
* @Author: Parker
|
||||||
|
* @CreateTime: 2020-09-13 19:36
|
||||||
|
* @Description: 核心类 - 消息
|
||||||
|
*/
|
||||||
|
public enum CoreMsg implements BaseMsg {
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getCode() {
|
||||||
|
return this.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage() {
|
||||||
|
return this.message;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
<?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">
|
||||||
|
<parent>
|
||||||
|
<groupId>org.opsliframework.boot</groupId>
|
||||||
|
<artifactId>opsli-boot-parent</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>opsli-modulars</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<!-- 模块 -->
|
||||||
|
<modules>
|
||||||
|
<module>opsli-modulars-test</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<!-- 规定子类所引用的版本 -->
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<!-- 引入邮件插件 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.opsliframework.boot</groupId>
|
||||||
|
<artifactId>opsli-plugins-mail</artifactId>
|
||||||
|
<version>${plugins.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- 引入公共模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.opsliframework.boot</groupId>
|
||||||
|
<artifactId>opsli-common</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 引入核心模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.opsliframework.boot</groupId>
|
||||||
|
<artifactId>opsli-core</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,2 @@
|
|||||||
|
## 统一异常类
|
||||||
|
02001=请求数据不完整或格式错误!
|
@ -0,0 +1 @@
|
|||||||
|
## 邮件异常 90001 - 90020
|
Loading…
Reference in new issue