Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ufo
/
yohoufo-fore
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
mali
5 years ago
Commit
6325ddb89d0ad781fe351c8e65d5f26fc15eb377
2 parents
9eb2bcde
fdde8e30
Merge branch 'test6.9.17' of
http://git.yoho.cn/ufo/yohoufo-fore
into test6.9.17
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
3 deletions
common/src/main/java/com/yohoufo/common/controller/exceptionhandler/GlobalDefaultExceptionHandler.java
product/src/main/java/com/yohoufo/product/controller/HotSearchWordController.java
common/src/main/java/com/yohoufo/common/controller/exceptionhandler/GlobalDefaultExceptionHandler.java
View file @
6325ddb
...
...
@@ -9,6 +9,7 @@ import com.yohoufo.common.exception.SessionExpireException;
import
com.yohoufo.common.exception.UfoServiceException
;
import
com.yohoufo.common.utils.ServletUtils
;
import
org.apache.commons.httpclient.HttpStatus
;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.bind.MissingServletRequestParameterException
;
...
...
@@ -76,9 +77,11 @@ public class GlobalDefaultExceptionHandler {
serviceName
,
code
,
desc
,
request
.
getRequestURI
(),
serviceName
,
params
);
}
else
if
(
e
instanceof
ServiceException
)
{
//服务异常,不能直接返回给客户端,必须映射一下
ServiceException
serviceException
=
(
ServiceException
)
e
;
ServiceError
serviceError
=
serviceException
.
getServiceError
();
code
=
serviceError
.
getMappingGatewayError
().
getLeft
();
desc
=
serviceError
.
getMappingGatewayError
().
getRight
();
Pair
<
Integer
,
String
>
codeMsgPair
=
getMessageCode
((
ServiceException
)
e
);
code
=
codeMsgPair
.
getLeft
();
desc
=
codeMsgPair
.
getRight
();
if
(
serviceException
.
getParams
()
!=
null
)
{
desc
=
MessageFormat
.
format
(
desc
,
serviceException
.
getParams
());
}
...
...
@@ -107,4 +110,21 @@ public class GlobalDefaultExceptionHandler {
}
private
Pair
<
Integer
,
String
>
getMessageCode
(
ServiceException
serviceException
){
ServiceError
serviceError
=
serviceException
.
getServiceError
();
// 该service是OTHER_ERROR 报错[系统异常]
if
(
serviceError
==
ServiceError
.
OTHER_ERROR
){
// ex. servcieException[400, 优惠券领取中] servcie[500,系统异常]
if
(
serviceException
.
getCode
()
!=
serviceError
.
getCode
()){
return
Pair
.
of
(
serviceException
.
getCode
(),
serviceException
.
getMessage
());
}
}
return
Pair
.
of
(
serviceError
.
getMappingGatewayError
().
getLeft
(),
serviceError
.
getMappingGatewayError
().
getRight
());
}
}
\ No newline at end of file
...
...
product/src/main/java/com/yohoufo/product/controller/HotSearchWordController.java
View file @
6325ddb
...
...
@@ -26,6 +26,7 @@ public class HotSearchWordController {
private
final
Integer
CLIENT_TYPE_APP
=
0
;
// APP端
private
final
Integer
CLIENT_TYPE_MINIAPP
=
1
;
// 小程序端
private
final
Integer
CLIENT_TYPE_XIANYU
=
3
;
// 闲鱼
private
final
Integer
WORD_TYPE_HOT
=
0
;
// 热搜词
...
...
@@ -45,6 +46,8 @@ public class HotSearchWordController {
dalClientType
=
CLIENT_TYPE_APP
;
}
else
if
(
"iphone"
.
equals
(
clientType
)
||
"android"
.
equals
(
clientType
))
{
dalClientType
=
CLIENT_TYPE_APP
;
}
else
if
(
"h5"
.
equals
(
clientType
))
{
dalClientType
=
CLIENT_TYPE_XIANYU
;
}
else
{
dalClientType
=
CLIENT_TYPE_MINIAPP
;
}
...
...
Please
register
or
login
to post a comment