Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
存储配置服务
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 d852e7bf
authored
Feb 17, 2022
by
xmh
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
全局异常处理和同名判断
1 parent
bebbb0fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
src/main/java/com/viontech/storage/config/GlobalExceptionHandler.java
src/main/java/com/viontech/storage/controller/StorageConfigController.java
src/main/java/com/viontech/storage/config/GlobalExceptionHandler.java
0 → 100644
View file @
d852e7b
package
com
.
viontech
.
storage
.
config
;
import
com.viontech.storage.entity.Message
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Optional
;
/**
* .
*
* @author 谢明辉
* @date 2020/6/4
*/
@RestControllerAdvice
public
class
GlobalExceptionHandler
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
GlobalExceptionHandler
.
class
);
@ExceptionHandler
(
Exception
.
class
)
public
Object
exceptionHandler
(
Exception
e
,
HttpServletRequest
request
)
{
log
.
error
(
request
.
getRequestURI
()
+
"?"
+
Optional
.
ofNullable
(
request
.
getQueryString
()).
orElse
(
""
),
e
);
return
Message
.
error
(
e
.
getMessage
());
}
}
src/main/java/com/viontech/storage/controller/StorageConfigController.java
View file @
d852e7b
...
...
@@ -76,6 +76,11 @@ public class StorageConfigController {
@PostMapping
public
Message
<
StorageConfig
>
add
(
@RequestBody
StorageConfigVo
storageConfigVo
)
{
Assert
.
notNull
(
storageConfigVo
.
getName
(),
"name不能为空"
);
Long
count
=
storageConfigService
.
lambdaQuery
().
eq
(
StorageConfig:
:
getName
,
storageConfigVo
.
getName
())
.
count
();
Assert
.
isTrue
(
count
==
0
,
"已存在同名存储配置"
);
List
<
Context
>
contexts
=
storageConfigVo
.
getContexts
();
if
(
CollectionUtil
.
isNotEmpty
(
contexts
))
{
for
(
Context
item
:
contexts
)
{
...
...
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