Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sv-springboot
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bsoft
sv-springboot
Commits
15158aee
Commit
15158aee
authored
Nov 19, 2019
by
Suvalue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
参数空值判断
parent
cd19c234
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
46 additions
and
1 deletions
+46
-1
bsoft-api/src/main/java/com/bsoft/api/common/Result.java
+4
-0
bsoft-api/src/main/java/com/bsoft/api/common/handlers/GlobalExceptionHandler.java
+27
-0
bsoft-api/src/main/java/com/bsoft/api/model/reqmodel/BlockValues.java
+3
-0
bsoft-api/src/main/java/com/bsoft/api/model/reqmodel/BlockValuesNew.java
+2
-0
bsoft-api/src/main/java/com/bsoft/api/model/reqmodel/CodeAndPwd.java
+4
-0
bsoft-api/src/main/java/com/bsoft/api/model/reqmodel/Disease.java
+2
-0
bsoft-api/src/main/java/com/bsoft/api/model/reqmodel/DiseaseDoc.java
+2
-0
bsoft-api/src/main/java/com/bsoft/api/model/reqmodel/ReqDimValue.java
+2
-1
No files found.
bsoft-api/src/main/java/com/bsoft/api/common/Result.java
View file @
15158aee
...
...
@@ -66,6 +66,10 @@ public class Result<T> {
return
new
Result
(
ErrorCode
.
ERROR
.
getCode
(),
ErrorCode
.
ERROR
.
getEnMessage
(),
null
);
}
public
static
Result
error
(
String
msg
){
return
new
Result
(
ErrorCode
.
ERROR
.
getCode
(),
msg
,
null
);
}
public
static
Result
error
(
ErrorCode
errorCode
){
return
new
Result
(
errorCode
.
getCode
(),
errorCode
.
getEnMessage
(),
null
);
}
...
...
bsoft-api/src/main/java/com/bsoft/api/common/handlers/GlobalExceptionHandler.java
View file @
15158aee
...
...
@@ -5,13 +5,20 @@ import com.bsoft.api.common.exceptions.DBConfigurationError;
import
com.bsoft.api.common.exceptions.ExceptionBase
;
import
com.bsoft.api.common.exceptions.InvalidTokenException
;
import
com.bsoft.common.utils.HttpUtil
;
import
com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.FieldError
;
import
org.springframework.validation.ObjectError
;
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
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 全局异常处理类
...
...
@@ -34,6 +41,26 @@ public class GlobalExceptionHandler {
return
Result
.
error
();
}
@ExceptionHandler
(
MethodArgumentNotValidException
.
class
)
@ResponseBody
public
Object
MethodArgumentNotValidErrorHandler
(
HttpServletRequest
request
,
MethodArgumentNotValidException
e
){
String
url
=
request
.
getRequestURI
();
BindingResult
bindingResult
=
e
.
getBindingResult
();
List
<
ObjectError
>
allErrors
=
bindingResult
.
getAllErrors
();
StringBuilder
errorStrBu
=
new
StringBuilder
();
allErrors
.
forEach
(
objectError
->
{
FieldError
fieldError
=
(
FieldError
)
objectError
;
errorStrBu
.
append
(
fieldError
.
getDefaultMessage
());
errorStrBu
.
append
(
","
);
});
String
errorStr
=
errorStrBu
.
toString
();
log
.
error
(
url
+
"请求未知异常:"
+
e
.
getMessage
(),
e
);
return
Result
.
error
(
errorStr
.
substring
(
0
,
errorStr
.
length
()-
1
));
}
/**
* 其他内部异常
* @param request
...
...
bsoft-api/src/main/java/com/bsoft/api/model/reqmodel/BlockValues.java
View file @
15158aee
...
...
@@ -3,6 +3,8 @@ package com.bsoft.api.model.reqmodel;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
javax.validation.constraints.NotNull
;
@ApiModel
(
description
=
"调用blockValues请求的数据"
)
public
class
BlockValues
{
...
...
@@ -56,5 +58,6 @@ public class BlockValues {
@ApiModelProperty
(
"医生"
)
private
Integer
doctor
;
@ApiModelProperty
(
"时间"
)
@NotNull
(
message
=
"time 参数必传"
)
private
Integer
time
;
}
bsoft-api/src/main/java/com/bsoft/api/model/reqmodel/BlockValuesNew.java
View file @
15158aee
...
...
@@ -2,10 +2,12 @@ package com.bsoft.api.model.reqmodel;
import
io.swagger.annotations.ApiModelProperty
;
import
javax.validation.constraints.NotNull
;
import
java.util.Map
;
public
class
BlockValuesNew
{
@ApiModelProperty
(
value
=
"pageCode"
,
required
=
true
)
@NotNull
(
message
=
"pageCode 参数必传"
)
private
Integer
pageCode
;
@ApiModelProperty
(
"维度查询值"
)
private
Map
<
String
,
String
>
dim
;
...
...
bsoft-api/src/main/java/com/bsoft/api/model/reqmodel/CodeAndPwd.java
View file @
15158aee
...
...
@@ -3,10 +3,14 @@ package com.bsoft.api.model.reqmodel;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
javax.validation.constraints.NotNull
;
@ApiModel
(
"账号密码"
)
public
class
CodeAndPwd
{
@ApiModelProperty
(
value
=
"账号"
,
required
=
true
)
@NotNull
(
message
=
"账号 参数必传"
)
String
loginName
;
@NotNull
(
message
=
"密码 参数必传"
)
@ApiModelProperty
(
value
=
"密码"
,
required
=
true
)
String
password
;
...
...
bsoft-api/src/main/java/com/bsoft/api/model/reqmodel/Disease.java
View file @
15158aee
...
...
@@ -2,6 +2,7 @@ package com.bsoft.api.model.reqmodel;
import
io.swagger.annotations.ApiModelProperty
;
import
javax.validation.constraints.NotNull
;
import
java.math.BigDecimal
;
public
class
Disease
{
...
...
@@ -11,6 +12,7 @@ public class Disease {
public
static
class
DiseaseIDorLevel
{
@ApiModelProperty
(
value
=
"时间"
,
required
=
true
)
@NotNull
(
message
=
"date 参数必传"
)
private
String
date
;
@ApiModelProperty
(
value
=
"疾病编码"
,
required
=
false
)
private
String
disease
;
...
...
bsoft-api/src/main/java/com/bsoft/api/model/reqmodel/DiseaseDoc.java
View file @
15158aee
...
...
@@ -3,6 +3,7 @@ package com.bsoft.api.model.reqmodel;
import
io.swagger.annotations.ApiModelProperty
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
javax.validation.constraints.NotNull
;
import
java.math.BigDecimal
;
/**
...
...
@@ -17,6 +18,7 @@ public class DiseaseDoc {
@ApiModelProperty
(
"科室编码"
)
private
String
deptCode
;
@ApiModelProperty
(
value
=
"时间"
,
required
=
true
)
@NotNull
(
message
=
"date 参数必传"
)
private
String
date
;
public
String
getDate
()
{
...
...
bsoft-api/src/main/java/com/bsoft/api/model/reqmodel/ReqDimValue.java
View file @
15158aee
...
...
@@ -7,11 +7,12 @@ import javax.validation.constraints.NotNull;
public
class
ReqDimValue
{
@ApiModelProperty
(
value
=
"pageCode"
,
required
=
true
)
@NotNull
(
message
=
"pageCode 参数必传"
)
private
String
pageCode
;
@ApiModelProperty
(
"机构id"
)
private
Long
orgId
;
@ApiModelProperty
(
"时间"
)
@NotNull
@NotNull
(
message
=
"date 参数必传"
)
private
String
date
;
public
String
getPageCode
()
{
...
...
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