Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
architecture
/
glsx-archetype
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 06b438a9
authored
Apr 21, 2023
by
刘宇峰
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
框架完善
1 parent
c975a8b9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
12 deletions
rest-archetype-framework/rest-admin-exception/src/main/java/com/glsx/plat/exception/ServiceException.java
rest-archetype-framework/rest-admin-feign/src/main/java/com/glsx/plat/feign/interceptor/RestTemplateRequestInterceptor.java
rest-archetype-framework/rest-admin-exception/src/main/java/com/glsx/plat/exception/ServiceException.java
View file @
06b438a
package
com
.
glsx
.
plat
.
exception
;
package
com
.
glsx
.
plat
.
exception
;
import
lombok.Getter
;
import
lombok.Data
;
import
lombok.Setter
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
java.io.Serializable
;
import
java.io.Serializable
;
...
@@ -9,9 +8,8 @@ import java.io.Serializable;
...
@@ -9,9 +8,8 @@ import java.io.Serializable;
/**
/**
* @author payu
* @author payu
*/
*/
@Setter
@Getter
@Slf4j
@Slf4j
@Data
public
class
ServiceException
extends
RuntimeException
implements
Serializable
{
public
class
ServiceException
extends
RuntimeException
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
...
@@ -19,12 +17,15 @@ public class ServiceException extends RuntimeException implements Serializable {
...
@@ -19,12 +17,15 @@ public class ServiceException extends RuntimeException implements Serializable {
private
String
msg
;
private
String
msg
;
private
String
code
;
private
String
code
;
public
ServiceException
(
String
code
,
String
msg
)
{
super
(
msg
);
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
static
ServiceException
create
(
String
code
,
String
msg
)
{
public
static
ServiceException
create
(
String
code
,
String
msg
)
{
log
.
error
(
"Service RuntimeException {} {}"
,
code
,
msg
);
log
.
error
(
"Service RuntimeException {} {}"
,
code
,
msg
);
ServiceException
exception
=
new
ServiceException
();
return
new
ServiceException
(
code
,
msg
);
exception
.
setCode
(
code
);
exception
.
setMsg
(
msg
);
return
exception
;
}
}
}
}
rest-archetype-framework/rest-admin-feign/src/main/java/com/glsx/plat/feign/interceptor/RestTemplateRequestInterceptor.java
View file @
06b438a
...
@@ -68,10 +68,10 @@ public class RestTemplateRequestInterceptor implements ClientHttpRequestIntercep
...
@@ -68,10 +68,10 @@ public class RestTemplateRequestInterceptor implements ClientHttpRequestIntercep
.
resStatus
(
responseCopy
.
getRawStatusCode
())
.
resStatus
(
responseCopy
.
getRawStatusCode
())
.
build
()));
.
build
()));
// JSONObject resultJO = JSONUtil.parseObj(req
Body);
JSONObject
resultJO
=
JSONUtil
.
parseObj
(
res
Body
);
//
if (!Objects.equals(SysConstants.ResultStatus.success.getCode(), resultJO.get("code"))) {
if
(!
Objects
.
equals
(
SysConstants
.
ResultStatus
.
success
.
getCode
(),
resultJO
.
get
(
"code"
)))
{
//
throw ServiceException.create(resultJO.getStr("code"), resultJO.getStr("message"));
throw
ServiceException
.
create
(
resultJO
.
getStr
(
"code"
),
resultJO
.
getStr
(
"message"
));
//
}
}
return
responseCopy
;
return
responseCopy
;
}
}
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment