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
86bb1bac
Commit
86bb1bac
authored
Apr 20, 2017
by
minminyan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
给用户添加婚姻状态
parent
82bc0332
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
41 deletions
+51
-41
InnerController.java
...tgroup/xyqb/controller/external/user/InnerController.java
+17
-11
UserSpouse.java
src/main/java/cn/quantgroup/xyqb/entity/UserSpouse.java
+10
-4
UserSpouseRet.java
src/main/java/cn/quantgroup/xyqb/model/UserSpouseRet.java
+24
-26
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/user/InnerController.java
View file @
86bb1bac
...
...
@@ -374,25 +374,27 @@ public class InnerController {
}
@RequestMapping
(
"/user/spouse/save"
)
public
JsonResult
saveSpouse
(
Long
userId
,
String
spousePhone
,
String
spouseName
)
{
public
JsonResult
saveSpouse
(
Long
userId
,
MaritalStatus
status
,
String
spousePhone
,
String
spouseName
)
{
if
(
userId
==
null
||
userId
==
0
)
{
return
JsonResult
.
buildErrorStateResult
(
"用户不能为空"
,
null
);
}
if
(!
ValidationUtil
.
validatePhoneNo
(
spousePhone
))
{
return
JsonResult
.
buildErrorStateResult
(
"手机号格式错误"
,
null
);
}
if
(
StringUtils
.
isBlank
(
spouseName
))
{
return
JsonResult
.
buildErrorStateResult
(
"配偶姓名不能为空"
,
null
);
if
(
status
==
MaritalStatus
.
MARRIED
)
{
if
(!
ValidationUtil
.
validatePhoneNo
(
spousePhone
))
{
return
JsonResult
.
buildErrorStateResult
(
"手机号格式错误"
,
null
);
}
if
(
StringUtils
.
isBlank
(
spouseName
))
{
return
JsonResult
.
buildErrorStateResult
(
"配偶姓名不能为空"
,
null
);
}
}
UserSpouse
userSpouse
=
userSpouseService
.
findByUserId
(
userId
);
Timestamp
timestamp
=
new
Timestamp
(
System
.
currentTimeMillis
());
if
(
userSpouse
==
null
)
{
userSpouse
=
new
UserSpouse
();
userSpouse
=
new
UserSpouse
(
userId
);
userSpouse
.
setCreatedAt
(
timestamp
);
}
userSpouse
.
setSpouseName
(
spouseName
);
userSpouse
.
setSpousePhone
(
spousePhone
);
userSpouse
.
setUserId
(
userId
);
userSpouse
.
setCreatedAt
(
timestamp
);
userSpouse
.
setSpouseName
(
status
==
MaritalStatus
.
MARRIED
?
spouseName
:
""
);
userSpouse
.
setSpousePhone
(
status
==
MaritalStatus
.
MARRIED
?
spousePhone
:
""
);
userSpouse
.
setStatus
(
status
);
userSpouse
.
setUpdateAt
(
timestamp
);
userSpouse
=
userSpouseService
.
save
(
userSpouse
);
return
JsonResult
.
buildSuccessResult
(
null
,
UserSpouseRet
.
getUserSpouseRet
(
userSpouse
));
...
...
@@ -404,6 +406,10 @@ public class InnerController {
return
JsonResult
.
buildErrorStateResult
(
"用户不能为空"
,
null
);
}
UserSpouse
userSpouse
=
userSpouseService
.
findByUserId
(
userId
);
if
(
userSpouse
==
null
)
{
userSpouse
=
new
UserSpouse
(
userId
);
userSpouse
.
setStatus
(
MaritalStatus
.
UNKNOWN
);
}
return
JsonResult
.
buildSuccessResult
(
null
,
UserSpouseRet
.
getUserSpouseRet
(
userSpouse
));
}
...
...
src/main/java/cn/quantgroup/xyqb/entity/UserSpouse.java
View file @
86bb1bac
package
cn
.
quantgroup
.
xyqb
.
entity
;
import
lombok.Data
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
cn.quantgroup.xyqb.entity.enumerate.MaritalStatus
;
import
lombok.*
;
import
javax.persistence.*
;
import
java.io.Serializable
;
...
...
@@ -16,6 +14,7 @@ import java.sql.Timestamp;
@Getter
@Setter
@ToString
@NoArgsConstructor
public
class
UserSpouse
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
1L
;
...
...
@@ -38,4 +37,11 @@ public class UserSpouse implements Serializable {
@Column
(
name
=
"updated_at"
)
private
Timestamp
updateAt
;
@Column
(
name
=
"status"
)
private
MaritalStatus
status
;
public
UserSpouse
(
Long
userId
)
{
this
.
userId
=
userId
;
}
}
src/main/java/cn/quantgroup/xyqb/model/UserSpouseRet.java
View file @
86bb1bac
package
cn
.
quantgroup
.
xyqb
.
model
;
import
cn.quantgroup.xyqb.entity.UserExtInfo
;
import
cn.quantgroup.xyqb.entity.UserSpouse
;
import
cn.quantgroup.xyqb.entity.enumerate.MaritalStatus
;
import
lombok.Data
;
import
javax.persistence.Column
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
java.sql.Timestamp
;
/**
* Created by 11 on 2017/4/19.
*/
@Data
public
class
UserSpouseRet
{
private
Long
id
;
private
Long
userId
;
private
Long
userId
;
private
String
spousePhone
;
private
String
spousePhon
e
;
private
String
spouseNam
e
;
private
String
spouseName
;
private
Long
createdAt
;
private
Long
created
At
;
private
Long
update
At
;
private
Long
updateAt
;
private
MaritalStatus
status
;
public
static
UserSpouseRet
getUserSpouseRet
(
UserSpouse
userSpouse
)
{
if
(
userSpouse
==
null
)
{
return
null
;
}
UserSpouseRet
ret
=
new
UserSpouseRet
();
ret
.
setUserId
(
userSpouse
.
getUserId
());
ret
.
setSpouseName
(
userSpouse
.
getSpouseName
());
ret
.
setSpousePhone
(
userSpouse
.
getSpousePhone
());
ret
.
setUpdateAt
(
userSpouse
.
getUpdateAt
().
getTime
());
ret
.
setCreatedAt
(
userSpouse
.
getCreated
At
().
getTime
());
ret
.
setId
(
userSpouse
.
getId
());
ret
.
setId
(
userSpouse
.
getId
());
return
ret
;
public
static
UserSpouseRet
getUserSpouseRet
(
UserSpouse
userSpouse
)
{
if
(
userSpouse
==
null
)
{
return
null
;
}
UserSpouseRet
ret
=
new
UserSpouseRet
();
ret
.
setUserId
(
userSpouse
.
getUserId
());
ret
.
setSpouseName
(
userSpouse
.
getSpouseName
());
ret
.
setSpousePhone
(
userSpouse
.
getSpousePhone
());
if
(
userSpouse
.
getUpdateAt
()
!=
null
)
{
ret
.
setUpdateAt
(
userSpouse
.
getUpdate
At
().
getTime
());
}
if
(
userSpouse
.
getCreatedAt
()
!=
null
)
{
ret
.
setCreatedAt
(
userSpouse
.
getCreatedAt
().
getTime
())
;
}
ret
.
setStatus
(
userSpouse
.
getStatus
());
return
ret
;
}
}
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