Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
64cf2f3f
Commit
64cf2f3f
authored
May 19, 2020
by
xiaoguang.xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
错误数据报错处理
parent
77a9f7dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
12 deletions
+10
-12
ContactController.java
...qb/controller/middleoffice/contact/ContactController.java
+8
-11
ContactSaveDto.java
...b/controller/middleoffice/contact/dto/ContactSaveDto.java
+2
-1
No files found.
src/main/java/cn/quantgroup/xyqb/controller/middleoffice/contact/ContactController.java
View file @
64cf2f3f
...
...
@@ -5,6 +5,7 @@ import cn.quantgroup.xyqb.controller.middleoffice.contact.dto.ContactSaveDto;
import
cn.quantgroup.xyqb.controller.middleoffice.contact.dto.ContactUpdateDto
;
import
cn.quantgroup.xyqb.entity.Contact
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.model.Tuple
;
import
cn.quantgroup.xyqb.service.user.IContactService
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -73,20 +74,16 @@ public class ContactController {
public
JsonResult
save
(
@RequestBody
ContactSaveDto
contactSaveDto
)
{
Long
userId
=
contactSaveDto
.
getUserId
();
List
<
Contact
>
contacts
=
contactSaveDto
.
getContacts
();
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
List
<
Contact
>
collect
=
contacts
.
stream
()
.
filter
(
Contact:
:
valid
)
.
collect
(
Collectors
.
toList
());
collect
.
forEach
(
contact
->
{
for
(
Contact
contact
:
contacts
)
{
Tuple
<
String
,
Boolean
>
result
=
contact
.
validAndResult
();
//数据校验
if
(!
result
.
getValue
())
{
return
JsonResult
.
buildErrorStateResult
(
result
.
getKey
(),
null
);
}
contact
.
setUserId
(
userId
);
contact
.
setBizType
(
contactSaveDto
.
getBizType
());
contact
.
setCreatedAt
(
now
);
contact
.
setUpdatedAt
(
now
);
});
if
(
collect
.
isEmpty
())
{
return
JsonResult
.
buildErrorStateResult
(
"数据格式错误"
,
null
);
}
contactService
.
save
(
co
llect
);
contactService
.
save
(
co
ntacts
);
return
JsonResult
.
buildSuccessResult
();
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/middleoffice/contact/dto/ContactSaveDto.java
View file @
64cf2f3f
...
...
@@ -3,6 +3,7 @@ package cn.quantgroup.xyqb.controller.middleoffice.contact.dto;
import
cn.quantgroup.user.enums.BizType
;
import
cn.quantgroup.xyqb.entity.Contact
;
import
lombok.Data
;
import
org.hibernate.validator.constraints.NotEmpty
;
import
org.springframework.validation.annotation.Validated
;
import
javax.validation.constraints.NotNull
;
...
...
@@ -15,6 +16,6 @@ public class ContactSaveDto {
private
Long
userId
;
@NotNull
(
message
=
"业务类型不能为空"
)
private
BizType
bizType
;
@Not
Null
(
message
=
"联系人信息不能为空"
)
@Not
Empty
(
message
=
"联系人信息不能为空"
)
private
List
<
Contact
>
contacts
;
}
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