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
49a2aec5
Commit
49a2aec5
authored
May 04, 2017
by
zhouqian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refact some code.
parent
4ea75dad
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
40 deletions
+50
-40
MotanUserServiceImpl.java
.../xyqb/controller/external/motan/MotanUserServiceImpl.java
+6
-38
InnerController.java
...tgroup/xyqb/controller/external/user/InnerController.java
+6
-2
User.java
src/main/java/cn/quantgroup/xyqb/entity/User.java
+15
-0
UserDetail.java
src/main/java/cn/quantgroup/xyqb/entity/UserDetail.java
+23
-0
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/motan/MotanUserServiceImpl.java
View file @
49a2aec5
...
...
@@ -27,6 +27,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.weibo.api.motan.config.springsupport.annotation.MotanService
;
import
java.util.concurrent.ThreadLocalRandom
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -42,7 +43,7 @@ import java.util.stream.Collectors;
* Created by 11 on 2017/2/27.
*/
@Slf4j
@MotanService
(
export
=
"userMotan:8002"
,
registry
=
"registry
Config"
)
@MotanService
(
basicService
=
"baseService
Config"
)
public
class
MotanUserServiceImpl
implements
UserMotanService
{
private
static
final
ObjectMapper
MAPPER
=
new
ObjectMapper
();
private
final
static
Random
random
=
new
Random
();
...
...
@@ -127,7 +128,7 @@ public class MotanUserServiceImpl implements UserMotanService {
@Override
public
UserSysResult
<
XUserDetail
>
findUserDetailByUserId
(
Long
userId
)
{
if
(
userId
==
null
||
userId
.
longValue
()
<
1
)
{
if
(
userId
==
null
||
userId
<
1
)
{
return
returnErrorValue
(
"参数必须是正整数"
);
}
UserDetail
userDetail
=
userDetailService
.
findByUserId
(
userId
);
...
...
@@ -136,49 +137,16 @@ public class MotanUserServiceImpl implements UserMotanService {
}
private
XUserDetail
fromUserDetail
(
UserDetail
userDetail
)
{
if
(
userDetail
==
null
)
{
return
null
;
}
XUserDetail
xUserDetail
=
new
XUserDetail
();
xUserDetail
.
setId
(
userDetail
.
getId
());
xUserDetail
.
setUserId
(
userDetail
.
getUserId
());
xUserDetail
.
setPhoneNo
(
userDetail
.
getPhoneNo
());
xUserDetail
.
setName
(
userDetail
.
getName
());
xUserDetail
.
setIdNo
(
userDetail
.
getIdNo
());
if
(
userDetail
.
getIdType
()
!=
null
)
{
xUserDetail
.
setIdType
(
cn
.
quantgroup
.
motan
.
enums
.
IdType
.
valueOf
(
userDetail
.
getIdType
().
name
()));
}
if
(
userDetail
.
getGender
()
!=
null
)
{
xUserDetail
.
setGender
(
cn
.
quantgroup
.
motan
.
enums
.
Gender
.
valueOf
(
userDetail
.
getGender
().
name
()));
}
xUserDetail
.
setEmail
(
userDetail
.
getEmail
());
xUserDetail
.
setQq
(
userDetail
.
getQq
());
xUserDetail
.
setId
(
userDetail
.
getId
());
xUserDetail
.
setCreatedAt
(
userDetail
.
getCreatedAt
());
xUserDetail
.
setUpdatedAt
(
userDetail
.
getUpdatedAt
());
xUserDetail
.
setIsAuthenticated
(
userDetail
.
getIsAuthenticated
());
return
xUserDetail
;
return
userDetail
==
null
?
null
:
userDetail
.
toXUserDetail
();
}
private
XUser
fromUser
(
User
user
)
{
if
(
user
==
null
)
{
return
null
;
}
XUser
xUser
=
new
XUser
();
xUser
.
setId
(
user
.
getId
());
xUser
.
setPassword
(
user
.
getPassword
());
xUser
.
setRegisteredFrom
(
user
.
getRegisteredFrom
());
xUser
.
setUuid
(
user
.
getUuid
());
xUser
.
setEnable
(
user
.
getEnable
());
xUser
.
setPhoneNo
(
user
.
getPhoneNo
());
xUser
.
setUpdatedAt
(
user
.
getUpdatedAt
());
xUser
.
setCreatedAt
(
user
.
getCreatedAt
());
return
xUser
;
return
user
==
null
?
null
:
user
.
toXUser
();
}
@Override
public
UserSysResult
<
XUser
>
findUserByUserId
(
Long
id
)
{
if
(
id
==
null
||
id
.
longValue
()
<
1
)
{
if
(
id
==
null
||
id
<
1
)
{
return
returnErrorValue
(
"参数必须是正整数"
);
}
User
user
=
userService
.
findById
(
id
);
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/user/InnerController.java
View file @
49a2aec5
...
...
@@ -236,6 +236,12 @@ public class InnerController {
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
convertContactList
(
userId
,
contacts
,
now
);
List
<
Contact
>
result
=
contactService
.
save
(
contacts
);
return
JsonResult
.
buildSuccessResult
(
null
,
ContactRet
.
contacts2ContactRets
(
result
));
}
private
void
convertContactList
(
Long
userId
,
List
<
Contact
>
contacts
,
Timestamp
now
)
{
for
(
Contact
c
:
contacts
)
{
c
.
setId
(
null
);
c
.
setUserId
(
userId
);
...
...
@@ -243,8 +249,6 @@ public class InnerController {
c
.
setCreatedAt
(
now
);
c
.
setUpdateAt
(
now
);
}
List
<
Contact
>
result
=
contactService
.
save
(
contacts
);
return
JsonResult
.
buildSuccessResult
(
null
,
ContactRet
.
contacts2ContactRets
(
result
));
}
@RequestMapping
(
"/address/search/user_id"
)
...
...
src/main/java/cn/quantgroup/xyqb/entity/User.java
View file @
49a2aec5
package
cn
.
quantgroup
.
xyqb
.
entity
;
import
cn.quantgroup.motan.retbean.XUser
;
import
cn.quantgroup.xyqb.config.http.Timestamp2LongConverter
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
lombok.Getter
;
...
...
@@ -57,4 +58,18 @@ public class User implements Serializable {
private
Timestamp
updatedAt
;
public
XUser
toXUser
()
{
XUser
xUser
=
new
XUser
();
xUser
.
setId
(
this
.
getId
());
xUser
.
setPassword
(
this
.
getPassword
());
xUser
.
setRegisteredFrom
(
this
.
getRegisteredFrom
());
xUser
.
setUuid
(
this
.
getUuid
());
xUser
.
setEnable
(
this
.
getEnable
());
xUser
.
setPhoneNo
(
this
.
getPhoneNo
());
xUser
.
setUpdatedAt
(
this
.
getUpdatedAt
());
xUser
.
setCreatedAt
(
this
.
getCreatedAt
());
return
xUser
;
}
}
src/main/java/cn/quantgroup/xyqb/entity/UserDetail.java
View file @
49a2aec5
package
cn
.
quantgroup
.
xyqb
.
entity
;
import
cn.quantgroup.motan.retbean.XUserDetail
;
import
cn.quantgroup.xyqb.model.Gender
;
import
cn.quantgroup.xyqb.model.IdType
;
import
lombok.Getter
;
...
...
@@ -66,5 +67,27 @@ public class UserDetail implements Serializable {
@Column
(
name
=
"updated_at"
)
private
Timestamp
updatedAt
;
public
XUserDetail
toXUserDetail
()
{
XUserDetail
xUserDetail
=
new
XUserDetail
();
xUserDetail
.
setId
(
this
.
getId
());
xUserDetail
.
setUserId
(
this
.
getUserId
());
xUserDetail
.
setPhoneNo
(
this
.
getPhoneNo
());
xUserDetail
.
setName
(
this
.
getName
());
xUserDetail
.
setIdNo
(
this
.
getIdNo
());
if
(
this
.
getIdType
()
!=
null
)
{
xUserDetail
.
setIdType
(
cn
.
quantgroup
.
motan
.
enums
.
IdType
.
valueOf
(
this
.
getIdType
().
name
()));
}
if
(
this
.
getGender
()
!=
null
)
{
xUserDetail
.
setGender
(
cn
.
quantgroup
.
motan
.
enums
.
Gender
.
valueOf
(
this
.
getGender
().
name
()));
}
xUserDetail
.
setEmail
(
this
.
getEmail
());
xUserDetail
.
setQq
(
this
.
getQq
());
xUserDetail
.
setId
(
this
.
getId
());
xUserDetail
.
setCreatedAt
(
this
.
getCreatedAt
());
xUserDetail
.
setUpdatedAt
(
this
.
getUpdatedAt
());
xUserDetail
.
setIsAuthenticated
(
this
.
getIsAuthenticated
());
return
xUserDetail
;
}
}
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