Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haoban3.0
haoban-manage3.0
Commits
46c2833f
Commit
46c2833f
authored
Dec 15, 2021
by
墨竹
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:拦截器修改
parent
a96f6e31
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
324 additions
and
301 deletions
+324
-301
pom.xml
haoban-manage3-wx/pom.xml
+255
-256
WxEnterpriseInfoController.java
...ban/manage/web/controller/WxEnterpriseInfoController.java
+2
-1
GlobalExceptionHandler.java
...c/haoban/manage/web/exception/GlobalExceptionHandler.java
+67
-44
No files found.
haoban-manage3-wx/pom.xml
View file @
46c2833f
<?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>
com.gic
</groupId>
<artifactId>
gic-pom-base
</artifactId>
<version>
3.0-SNAPSHOT
</version>
<relativePath/>
</parent>
<modelVersion>
4.0.0
</modelVersion>
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<groupId>
com.gic
</groupId>
<artifactId>
gic-pom-base
</artifactId>
<version>
3.0-SNAPSHOT
</version>
<relativePath/>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
haoban-manage3-wx
</artifactId>
<version>
${libraryVersion}
</version>
<packaging>
war
</packaging>
<artifactId>
haoban-manage3-wx
</artifactId>
<version>
${libraryVersion}
</version>
<packaging>
war
</packaging>
<name>
haoban-manage3-wx Maven Webapp
</name>
<!-- FIXME change it to the project's website -->
<url>
http://www.example.com
</url>
<name>
haoban-manage3-wx Maven Webapp
</name>
<!-- FIXME change it to the project's website -->
<url>
http://www.example.com
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<commonVersion>
3.0-SNAPSHOT
</commonVersion>
<libraryVersion>
3.0-SNAPSHOT
</libraryVersion>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-framework-bom
</artifactId>
<version>
4.2.4.RELEASE
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.47
</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.11
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-wechat-api
</artifactId>
<version>
${gic-wechat-api}
</version>
</dependency>
<dependency>
<groupId>
org.springframework.session
</groupId>
<artifactId>
spring-session-data-redis
</artifactId>
<version>
1.2.1.RELEASE
</version>
</dependency>
<dependency>
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
<version>
2.8.1
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-dict-api
</artifactId>
<version>
${gic-dict-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-commons
</artifactId>
<version>
${gic-commons}
</version>
<exclusions>
<exclusion>
<artifactId>
httpclient
</artifactId>
<groupId>
org.apache.httpcomponents
</groupId>
</exclusion>
<exclusion>
<artifactId>
httpcore
</artifactId>
<groupId>
org.apache.httpcomponents
</groupId>
</exclusion>
<exclusion>
<artifactId>
spring-beans
</artifactId>
<groupId>
org.springframework
</groupId>
</exclusion>
<exclusion>
<artifactId>
slf4j-api
</artifactId>
<groupId>
org.slf4j
</groupId>
</exclusion>
</exclusions>
</dependency>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<commonVersion>
3.0-SNAPSHOT
</commonVersion>
<libraryVersion>
3.0-SNAPSHOT
</libraryVersion>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-framework-bom
</artifactId>
<version>
4.2.4.RELEASE
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.47
</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.11
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-wechat-api
</artifactId>
<version>
${gic-wechat-api}
</version>
</dependency>
<dependency>
<groupId>
org.springframework.session
</groupId>
<artifactId>
spring-session-data-redis
</artifactId>
<version>
1.2.1.RELEASE
</version>
</dependency>
<dependency>
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
<version>
2.8.1
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-dict-api
</artifactId>
<version>
${gic-dict-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-commons
</artifactId>
<version>
${gic-commons}
</version>
<exclusions>
<exclusion>
<artifactId>
httpclient
</artifactId>
<groupId>
org.apache.httpcomponents
</groupId>
</exclusion>
<exclusion>
<artifactId>
httpcore
</artifactId>
<groupId>
org.apache.httpcomponents
</groupId>
</exclusion>
<exclusion>
<artifactId>
spring-beans
</artifactId>
<groupId>
org.springframework
</groupId>
</exclusion>
<exclusion>
<artifactId>
slf4j-api
</artifactId>
<groupId>
org.slf4j
</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-platform-config
</artifactId>
<version>
${gic-platform-config}
</version>
</dependency>
<dependency>
<groupId>
net.sourceforge.jexcelapi
</groupId>
<artifactId>
jxl
</artifactId>
<version>
2.6.12
</version>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi
</artifactId>
<version>
3.9
</version>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml
</artifactId>
<version>
3.9
</version>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml-schemas
</artifactId>
<version>
3.9
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-data-api
</artifactId>
<version>
${haoban-data-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-contacts-api
</artifactId>
<version>
${haoban-contacts-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-manage3-api
</artifactId>
<version>
${haoban-manage3-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-contacts-manage-api
</artifactId>
<version>
${haoban-contacts-manage-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-common
</artifactId>
<version>
${haoban-common}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-auth-api
</artifactId>
<version>
${haoban-auth-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-operation-api
</artifactId>
<version>
${haoban-operation-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-config
</artifactId>
<version>
${haoban-config}
</version>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
javax.servlet-api
</artifactId>
<version>
3.1.0
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-thirdparty-api
</artifactId>
<version>
${gic-thirdparty-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-member-api
</artifactId>
<version>
${gic-member-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-message-api
</artifactId>
<version>
${haoban-message-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-app-announcement-api
</artifactId>
<version>
${haoban-app-announcement-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-platform-config
</artifactId>
<version>
${gic-platform-config}
</version>
</dependency>
<dependency>
<groupId>
net.sourceforge.jexcelapi
</groupId>
<artifactId>
jxl
</artifactId>
<version>
2.6.12
</version>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi
</artifactId>
<version>
3.9
</version>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml
</artifactId>
<version>
3.9
</version>
</dependency>
<dependency>
<groupId>
org.apache.poi
</groupId>
<artifactId>
poi-ooxml-schemas
</artifactId>
<version>
3.9
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-data-api
</artifactId>
<version>
${haoban-data-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-contacts-api
</artifactId>
<version>
${haoban-contacts-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-manage3-api
</artifactId>
<version>
${haoban-manage3-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-communicate-api
</artifactId>
<version>
${haoban-communicate-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-contacts-manage-api
</artifactId>
<version>
${haoban-contacts-manage-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-common
</artifactId>
<version>
${haoban-common}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-auth-api
</artifactId>
<version>
${haoban-auth-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-operation-api
</artifactId>
<version>
${haoban-operation-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-config
</artifactId>
<version>
${haoban-config}
</version>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
javax.servlet-api
</artifactId>
<version>
3.1.0
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-thirdparty-api
</artifactId>
<version>
${gic-thirdparty-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-member-api
</artifactId>
<version>
${gic-member-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-message-api
</artifactId>
<version>
${haoban-message-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-app-announcement-api
</artifactId>
<version>
${haoban-app-announcement-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-mobile-app-api
</artifactId>
<version>
${haoban-mobile-app-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-communicate-api
</artifactId>
<version>
${haoban-communicate-api
}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-thirdparty-sdk
</artifactId>
<version>
${gic-thirdparty-sdk
}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-mobile-app-api
</artifactId>
<version>
${haoban-mobile-app-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-thirdparty-sdk
</artifactId>
<version>
${gic-thirdparty-sdk}
</version>
</dependency>
<dependency>
<groupId>
com.gic.operation
</groupId>
<artifactId>
gic-operation-api
</artifactId>
<version>
${gic-operation-api}
</version>
</dependency>
<dependency>
<dependency>
<groupId>
com.gic.operation
</groupId>
<artifactId>
gic-operation-api
</artifactId>
<version>
${gic-operation-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-enterprise-api
</artifactId>
<version>
${gic-enterprise-api}
</version>
...
...
@@ -219,65 +218,65 @@
<artifactId>
gic-clerk-api
</artifactId>
<version>
${gic-clerk-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-quartz-api
</artifactId>
<version>
${gic-quartz-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
gic-quartz-api
</artifactId>
<version>
${gic-quartz-api}
</version>
</dependency>
<dependency>
<groupId>
com.gic
</groupId>
<artifactId>
haoban-app-customer-api
</artifactId>
<version>
${haoban-app-customer-api}
</version>
</dependency>
</dependencies>
</dependencies>
<build>
<finalName>
haoban-manage3-wx
</finalName>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<encoding>
UTF-8
</encoding>
<source>
1.8
</source>
<target>
1.8
</target>
<compilerArgs>
<arg>
-parameters
</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-dependency-plugin
</artifactId>
<executions>
<execution>
<id>
copy-dependencies
</id>
<phase>
package
</phase>
<goals>
<goal>
copy-dependencies
</goal>
</goals>
<configuration>
<type>
jar
</type>
<includeTypes>
jar
</includeTypes>
<outputDirectory>
${project.build.directory}/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>
org.apache.tomcat.maven
</groupId>
<artifactId>
tomcat7-maven-plugin
</artifactId>
<version>
2.2
</version>
<configuration>
<path>
/haoban-manage3-wx
</path>
<port>
9909
</port>
<uriEncoding>
UTF-8
</uriEncoding>
</configuration>
</plugin>
</plugins>
</build>
<build>
<finalName>
haoban-manage3-wx
</finalName>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<encoding>
UTF-8
</encoding>
<source>
1.8
</source>
<target>
1.8
</target>
<compilerArgs>
<arg>
-parameters
</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-dependency-plugin
</artifactId>
<executions>
<execution>
<id>
copy-dependencies
</id>
<phase>
package
</phase>
<goals>
<goal>
copy-dependencies
</goal>
</goals>
<configuration>
<type>
jar
</type>
<includeTypes>
jar
</includeTypes>
<outputDirectory>
${project.build.directory}/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>
org.apache.tomcat.maven
</groupId>
<artifactId>
tomcat7-maven-plugin
</artifactId>
<version>
2.2
</version>
<configuration>
<path>
/haoban-manage3-wx
</path>
<port>
9909
</port>
<uriEncoding>
UTF-8
</uriEncoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/controller/WxEnterpriseInfoController.java
View file @
46c2833f
...
...
@@ -49,6 +49,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.validation.Valid
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -174,7 +175,7 @@ public class WxEnterpriseInfoController extends WebBaseController {
*/
@RequestMapping
(
value
=
"welldone-login"
,
method
=
RequestMethod
.
POST
)
@IgnoreLogin
public
HaobanResponse
welldoneLogin
(
@RequestBody
StaffLoginQO
staffLoginQO
,
HttpServletRequest
request
)
{
public
HaobanResponse
welldoneLogin
(
@RequestBody
@Valid
StaffLoginQO
staffLoginQO
,
HttpServletRequest
request
)
{
StaffDTO
staffDTO
=
staffApiService
.
selectById
(
staffLoginQO
.
getStaffId
());
if
(
staffDTO
==
null
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_6
);
...
...
haoban-manage3-wx/src/main/java/com/gic/haoban/manage/web/exception/GlobalExceptionHandler.java
View file @
46c2833f
package
com
.
gic
.
haoban
.
manage
.
web
.
exception
;
import
com.gic.haoban.base.api.common.ShowFrontMessageException
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.manage.web.controller.WebBaseController
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.validation.BindException
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.FieldError
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.annotation.ControllerAdvice
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ResponseBody
;
...
...
@@ -13,8 +16,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.ByteArrayOutputStream
;
import
java.io.PrintWriter
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
* Created 2018/7/24.
...
...
@@ -23,44 +24,74 @@ import java.util.regex.Pattern;
*/
@ControllerAdvice
public
class
GlobalExceptionHandler
extends
WebBaseController
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
GlobalExceptionHandler
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
GlobalExceptionHandler
.
class
);
private
static
final
Pattern
pattern
=
Pattern
.
compile
(
"(.*: )(.*)(\\n.*)"
);
// @ResponseBody
// @ExceptionHandler(ShowFrontMessageException.class)
// public HaobanResponse ControllerException(HttpServletResponse response, ShowFrontMessageException ex) {
// HaobanResponse res = new HaobanResponse();
// res.setErrorCode(HaoBanErrCode.ERR_0.getCode());
// res.setMessage(ex.getMessage());
// return res;
// }
/**
* RuntimeException 类型异常告警
*
* @param response
* @param ex
* @return
*/
@ResponseBody
@ExceptionHandler
(
RuntimeException
.
class
)
public
HaobanResponse
controllerException
(
HttpServletResponse
response
,
RuntimeException
ex
)
{
logger
.
error
(
"Exception:{}"
,
ex
.
getMessage
(),
ex
);
HaoBanErrCode
errCode
=
HaoBanErrCode
.
ERR_3
;
StringBuilder
sb
=
new
StringBuilder
();
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
try
(
PrintWriter
printWriter
=
new
PrintWriter
(
baos
))
{
ex
.
printStackTrace
(
printWriter
);
}
try
{
sb
.
append
(
baos
.
toString
());
}
catch
(
Exception
ignored
)
{
}
if
(
sb
.
length
()
==
0
)
{
sb
.
append
(
ex
.
getMessage
());
}
// 输出详细错误信息,便于调试
return
resultResponse
(
errCode
,
null
,
sb
.
toString
());
}
/**
* valid 异常告警
*
* @param response
* @param ex
* @return
*/
@ResponseBody
@ExceptionHandler
(
BindException
.
class
)
public
HaobanResponse
bindException
(
HttpServletResponse
response
,
BindException
ex
)
{
logger
.
error
(
"Exception:{}"
,
ex
.
getMessage
(),
ex
);
HaoBanErrCode
errCode
=
HaoBanErrCode
.
ERR_5
;
BindingResult
bindingResult
=
ex
.
getBindingResult
();
FieldError
fieldError
=
bindingResult
.
getFieldError
();
return
resultResponse
(
errCode
,
null
,
fieldError
.
getField
()
+
fieldError
.
getDefaultMessage
());
}
// @ResponseBody
// @ExceptionHandler(RuntimeException.class)
// public HaobanResponse ControllerException(HttpServletResponse response, RuntimeException ex) {
// HaobanResponse res = new HaobanResponse();
// res.setErrorCode(HaoBanErrCode.ERR_3.getCode());
// String message = ex.getMessage();
// if (message != null && message.indexOf(ShowFrontMessageException.class.getName()) > -1) {
// Matcher matcher = pattern.matcher(message);
// while (matcher.find()) {
// message = (matcher.group(2));
// }
// } else {
// message = HaoBanErrCode.ERR_3.getMsg();
// }
// res.setMessage(message);
// return res;
// }
/**
* valid 异常告警 @ReuqestBody
*
* @param response
* @param ex
* @return
*/
@ResponseBody
@ExceptionHandler
(
MethodArgumentNotValidException
.
class
)
public
HaobanResponse
methodArgumentNotValidException
(
HttpServletResponse
response
,
MethodArgumentNotValidException
ex
)
{
logger
.
error
(
"Exception:{}"
,
ex
.
getMessage
(),
ex
);
HaoBanErrCode
errCode
=
HaoBanErrCode
.
ERR_5
;
BindingResult
bindingResult
=
ex
.
getBindingResult
();
FieldError
fieldError
=
bindingResult
.
getFieldError
();
return
resultResponse
(
errCode
,
null
,
fieldError
.
getField
()
+
fieldError
.
getDefaultMessage
());
}
@ResponseBody
@ExceptionHandler
(
Exception
.
class
)
public
HaobanResponse
ControllerException
(
HttpServletResponse
response
,
Exception
ex
)
{
logger
.
error
(
"err:"
,
ex
.
getMessage
());
ex
.
printStackTrace
();
public
HaobanResponse
globalException
(
HttpServletResponse
response
,
Exception
ex
)
{
logger
.
error
(
"Exception:{}"
,
ex
.
getMessage
(),
ex
);
HaoBanErrCode
errCode
=
HaoBanErrCode
.
ERR_3
;
StringBuilder
sb
=
new
StringBuilder
();
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
...
...
@@ -74,17 +105,9 @@ public class GlobalExceptionHandler extends WebBaseController {
if
(
sb
.
length
()
==
0
)
{
sb
.
append
(
ex
.
getMessage
());
}
// 输出详细错误信息,便于调试
// return resultResponse(errCode, null, sb.toString());
return
resultResponse
(
HaoBanErrCode
.
ERR_3
);
return
resultResponse
(
errCode
,
null
,
sb
.
toString
());
}
@ResponseBody
@ExceptionHandler
(
NoLoginException
.
class
)
public
HaobanResponse
ControllerException
(
HttpServletResponse
response
,
NoLoginException
ex
)
{
return
resultResponse
(
HaoBanErrCode
.
ERR_4
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment