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
f299eba2
Commit
f299eba2
authored
Nov 20, 2017
by
Java—KA—李 青
Browse files
Options
Browse Files
Download
Plain Diff
merge conflict
parents
eedf9c38
e295c4ea
Changes
16
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
257 additions
and
175 deletions
+257
-175
Constants.java
src/main/java/cn/quantgroup/xyqb/Constants.java
+0
-1
RedisCaptchaStore.java
.../cn/quantgroup/xyqb/config/captcha/RedisCaptchaStore.java
+3
-2
MotanUserServiceImpl.java
.../xyqb/controller/external/motan/MotanUserServiceImpl.java
+45
-36
AppController.java
...antgroup/xyqb/controller/external/user/AppController.java
+4
-11
InnerController.java
...tgroup/xyqb/controller/external/user/InnerController.java
+43
-72
SyncUserController.java
...oup/xyqb/controller/external/user/SyncUserController.java
+25
-3
UserCenterController.java
...controller/external/user/center/UserCenterController.java
+14
-27
UserController.java
...ntgroup/xyqb/controller/internal/user/UserController.java
+1
-5
Contact.java
src/main/java/cn/quantgroup/xyqb/entity/Contact.java
+10
-0
UserSpouse.java
src/main/java/cn/quantgroup/xyqb/entity/UserSpouse.java
+9
-0
UserRet.java
src/main/java/cn/quantgroup/xyqb/model/UserRet.java
+1
-1
PageServiceImpl.java
...cn/quantgroup/xyqb/service/page/impl/PageServiceImpl.java
+1
-1
IContactService.java
...java/cn/quantgroup/xyqb/service/user/IContactService.java
+15
-2
ContactServiceImpl.java
...quantgroup/xyqb/service/user/impl/ContactServiceImpl.java
+72
-8
UserServiceImpl.java
...cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
+1
-6
MqUtils.java
src/main/java/cn/quantgroup/xyqb/util/MqUtils.java
+13
-0
No files found.
src/main/java/cn/quantgroup/xyqb/Constants.java
View file @
f299eba2
...
@@ -13,7 +13,6 @@ public interface Constants {
...
@@ -13,7 +13,6 @@ public interface Constants {
String
IMAGE_CAPTCHA_KEY
=
"img_captcha:"
;
String
IMAGE_CAPTCHA_KEY
=
"img_captcha:"
;
String
REDIS_CAPTCHA_KEY
=
"auth:"
;
String
REDIS_CAPTCHA_KEY
=
"auth:"
;
String
REDIS_CAPTCHA_KEY_PATTERN
=
REDIS_CAPTCHA_KEY
+
IMAGE_CAPTCHA_KEY
+
"*"
;
String
CONFIG_CAPTCHA
=
"cfg_captcha_%"
;
String
CONFIG_CAPTCHA
=
"cfg_captcha_%"
;
// app 后端白名单
// app 后端白名单
...
...
src/main/java/cn/quantgroup/xyqb/config/captcha/RedisCaptchaStore.java
View file @
f299eba2
...
@@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
...
@@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -70,12 +71,12 @@ public class RedisCaptchaStore implements CaptchaStore {
...
@@ -70,12 +71,12 @@ public class RedisCaptchaStore implements CaptchaStore {
@Override
@Override
public
int
getSize
()
{
public
int
getSize
()
{
return
getKeys
().
size
()
;
return
0
;
}
}
@Override
@Override
public
Collection
getKeys
()
{
public
Collection
getKeys
()
{
return
stringRedisTemplate
.
keys
(
Constants
.
REDIS_CAPTCHA_KEY_PATTERN
);
return
Collections
.
emptyList
(
);
}
}
@Override
@Override
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/motan/MotanUserServiceImpl.java
View file @
f299eba2
...
@@ -41,6 +41,7 @@ import java.sql.Timestamp;
...
@@ -41,6 +41,7 @@ import java.sql.Timestamp;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Random
;
import
java.util.Random
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -196,6 +197,18 @@ public class MotanUserServiceImpl implements UserMotanService {
...
@@ -196,6 +197,18 @@ public class MotanUserServiceImpl implements UserMotanService {
return
returnErrorValue
(
"要保存的用户详情对象不能为null"
);
return
returnErrorValue
(
"要保存的用户详情对象不能为null"
);
}
}
UserDetail
userDetail
=
new
UserDetail
();
UserDetail
userDetail
=
new
UserDetail
();
if
(!
ValidationUtil
.
validateChinese
(
userDetailUpdateBean
.
getName
()))
{
return
returnErrorValue
(
"用户姓名错误"
);
}
IdCardInfo
info
=
null
;
try
{
info
=
idCardService
.
getIdCardInfo
(
userDetailUpdateBean
.
getIdNo
());
}
catch
(
ParseException
ex
)
{
log
.
error
(
"用户身份证号错误, idNo: {}"
,
userDetailUpdateBean
.
getIdNo
(),
ex
);
}
if
(
Objects
.
isNull
(
info
)
||
!
info
.
isValid
())
{
return
returnErrorValue
(
"身份证号码错误"
);
}
if
(
null
!=
userDetailUpdateBean
.
getId
()
&&
userDetailUpdateBean
.
getId
()
>
0L
)
{
if
(
null
!=
userDetailUpdateBean
.
getId
()
&&
userDetailUpdateBean
.
getId
()
>
0L
)
{
userDetail
.
setId
(
userDetailUpdateBean
.
getId
());
userDetail
.
setId
(
userDetailUpdateBean
.
getId
());
}
}
...
@@ -207,12 +220,7 @@ public class MotanUserServiceImpl implements UserMotanService {
...
@@ -207,12 +220,7 @@ public class MotanUserServiceImpl implements UserMotanService {
userDetail
.
setCreatedAt
(
time
);
userDetail
.
setCreatedAt
(
time
);
userDetail
.
setUpdatedAt
(
time
);
userDetail
.
setUpdatedAt
(
time
);
userDetail
.
setIdType
(
IdType
.
ID_CARD
);
userDetail
.
setIdType
(
IdType
.
ID_CARD
);
try
{
userDetail
.
setGender
(
info
.
getGender
());
userDetail
.
setGender
(
idCardService
.
getIdCardInfo
(
userDetailUpdateBean
.
getIdNo
()).
getGender
());
}
catch
(
ParseException
e
)
{
log
.
error
(
"根据身份证获取性别出错,userDetailUpdateBean:{}"
,
JSON
.
toJSONString
(
userDetailUpdateBean
),
e
);
return
returnErrorValue
(
"根据身份证获取性别出错."
);
}
userDetail
.
setEmail
(
userDetailUpdateBean
.
getEmail
());
userDetail
.
setEmail
(
userDetailUpdateBean
.
getEmail
());
userDetail
=
userDetailService
.
saveUserDetail
(
userDetail
);
userDetail
=
userDetailService
.
saveUserDetail
(
userDetail
);
if
(
userDetail
!=
null
)
{
if
(
userDetail
!=
null
)
{
...
@@ -241,6 +249,18 @@ public class MotanUserServiceImpl implements UserMotanService {
...
@@ -241,6 +249,18 @@ public class MotanUserServiceImpl implements UserMotanService {
if
(
StringUtils
.
isBlank
(
userDetailSaveBean
.
getIdNo
()))
{
if
(
StringUtils
.
isBlank
(
userDetailSaveBean
.
getIdNo
()))
{
return
returnErrorValue
(
"用户身份证为空"
);
return
returnErrorValue
(
"用户身份证为空"
);
}
}
if
(!
ValidationUtil
.
validateChinese
(
userDetailSaveBean
.
getName
()))
{
return
returnErrorValue
(
"用户姓名错误"
);
}
IdCardInfo
info
=
null
;
try
{
info
=
idCardService
.
getIdCardInfo
(
userDetailSaveBean
.
getIdNo
());
}
catch
(
ParseException
ex
)
{
log
.
error
(
"用户身份证号错误, idNo: {}"
,
userDetailSaveBean
.
getIdNo
(),
ex
);
}
if
(
Objects
.
isNull
(
info
)
||
!
info
.
isValid
())
{
return
returnErrorValue
(
"身份证号码错误"
);
}
Timestamp
time
=
new
Timestamp
(
System
.
currentTimeMillis
());
Timestamp
time
=
new
Timestamp
(
System
.
currentTimeMillis
());
UserDetail
userDetail
=
userDetailService
.
findByUserId
(
userId
);
UserDetail
userDetail
=
userDetailService
.
findByUserId
(
userId
);
if
(
userDetail
==
null
)
{
if
(
userDetail
==
null
)
{
...
@@ -251,19 +271,12 @@ public class MotanUserServiceImpl implements UserMotanService {
...
@@ -251,19 +271,12 @@ public class MotanUserServiceImpl implements UserMotanService {
}
else
{
}
else
{
userDetail
.
setUpdatedAt
(
time
);
userDetail
.
setUpdatedAt
(
time
);
}
}
userDetail
.
setName
(
userDetail
.
getName
());
userDetail
.
setName
(
userDetail
SaveBean
.
getName
());
userDetail
.
setPhoneNo
(
userDetail
.
getPhoneNo
());
userDetail
.
setPhoneNo
(
userDetail
SaveBean
.
getPhoneNo
());
userDetail
.
setIdType
(
IdType
.
ID_CARD
);
userDetail
.
setIdType
(
IdType
.
ID_CARD
);
if
(
StringUtils
.
isNotBlank
(
userDetail
.
getIdNo
()))
{
userDetail
.
setGender
(
info
.
getGender
());
try
{
userDetail
.
setIdNo
(
userDetailSaveBean
.
getIdNo
());
userDetail
.
setGender
(
idCardService
.
getIdCardInfo
(
userDetail
.
getIdNo
()).
getGender
());
userDetail
.
setEmail
(
userDetailSaveBean
.
getEmail
());
}
catch
(
ParseException
e
)
{
log
.
error
(
"根据身份证获取性别出错,身份证号码:{}"
,
userDetail
.
getIdNo
(),
e
);
return
returnErrorValue
(
"身份证信息出错"
);
}
userDetail
.
setIdNo
(
userDetail
.
getIdNo
());
}
userDetail
.
setEmail
(
userDetail
.
getEmail
());
userDetail
=
userDetailService
.
saveUserDetail
(
userDetail
);
userDetail
=
userDetailService
.
saveUserDetail
(
userDetail
);
if
(
userDetail
!=
null
)
{
if
(
userDetail
!=
null
)
{
return
returnSuccessValue
(
fromUserDetail
(
userDetail
));
return
returnSuccessValue
(
fromUserDetail
(
userDetail
));
...
@@ -335,7 +348,7 @@ public class MotanUserServiceImpl implements UserMotanService {
...
@@ -335,7 +348,7 @@ public class MotanUserServiceImpl implements UserMotanService {
@Override
@Override
public
UserSysResult
<
List
<
XContact
>>
findContactsByUserId
(
Long
userId
)
{
public
UserSysResult
<
List
<
XContact
>>
findContactsByUserId
(
Long
userId
)
{
List
<
Contact
>
contacts
=
contactService
.
findByUserId
(
userId
);
List
<
Contact
>
contacts
=
contactService
.
findByUserId
(
userId
,
true
);
List
<
XContact
>
xContacts
=
convertObject
(
JSON
.
toJSONString
(
contacts
),
new
TypeReference
<
List
<
XContact
>>()
{
List
<
XContact
>
xContacts
=
convertObject
(
JSON
.
toJSONString
(
contacts
),
new
TypeReference
<
List
<
XContact
>>()
{
});
});
return
returnSuccessValue
(
xContacts
);
return
returnSuccessValue
(
xContacts
);
...
@@ -353,23 +366,19 @@ public class MotanUserServiceImpl implements UserMotanService {
...
@@ -353,23 +366,19 @@ public class MotanUserServiceImpl implements UserMotanService {
String
jsonContacts
=
JSON
.
toJSONString
(
contacts
);
String
jsonContacts
=
JSON
.
toJSONString
(
contacts
);
List
<
Contact
>
contactList
=
null
;
List
<
Contact
>
contactList
=
null
;
try
{
try
{
contactList
=
MAPPER
.
readValue
(
jsonContacts
,
new
TypeReference
<
List
<
Contact
>>()
{
contactList
=
MAPPER
.
readValue
(
jsonContacts
,
new
TypeReference
<
List
<
Contact
>>(){});
});
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"联系人列表转换错误"
,
e
);
log
.
error
(
"联系人列表转换错误"
,
e
);
return
returnErrorValue
(
"联系人转换错误"
);
return
returnErrorValue
(
"联系人转换错误"
);
}
}
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
for
(
Contact
c
:
contactList
)
{
for
(
Contact
c
:
contactList
)
{
c
.
setId
(
null
);
if
(!
c
.
valid
())
{
c
.
setUserId
(
userId
);
log
.
info
(
"用户手机号或姓名错误, phoneNo:{},name:{}"
,
c
.
getPhoneNo
(),
c
.
getName
());
c
.
setRelation
(
c
.
getRelation
()
==
null
?
Relation
.
OTHER
:
c
.
getRelation
());
return
returnErrorValue
(
"用户手机号或姓名错误"
);
c
.
setCreatedAt
(
now
);
}
c
.
setUpdateAt
(
now
);
}
}
List
<
Contact
>
result
=
contactService
.
save
(
userId
,
contactList
);
List
<
Contact
>
result
=
contactService
.
save
(
contactList
);
List
<
XContact
>
xResult
=
convertObject
(
JSON
.
toJSONString
(
result
),
new
TypeReference
<
List
<
XContact
>>(){});
List
<
XContact
>
xResult
=
convertObject
(
JSON
.
toJSONString
(
result
),
new
TypeReference
<
List
<
XContact
>>()
{
});
return
returnSuccessValue
(
xResult
);
return
returnSuccessValue
(
xResult
);
}
}
...
@@ -388,7 +397,7 @@ public class MotanUserServiceImpl implements UserMotanService {
...
@@ -388,7 +397,7 @@ public class MotanUserServiceImpl implements UserMotanService {
@Override
@Override
public
UserSysResult
<
XAddress
>
saveAddress
(
Long
userId
,
Long
provinceCode
,
String
province
,
Long
cityCode
,
String
city
,
public
UserSysResult
<
XAddress
>
saveAddress
(
Long
userId
,
Long
provinceCode
,
String
province
,
Long
cityCode
,
String
city
,
Long
districtCode
,
String
district
,
String
address
)
{
Long
districtCode
,
String
district
,
String
address
)
{
if
(
null
==
userId
||
null
==
provinceCode
||
null
==
cityCode
)
{
if
(
null
==
userId
||
null
==
provinceCode
||
null
==
cityCode
||
StringUtils
.
isBlank
(
address
)
)
{
return
returnErrorValue
(
"参数不能为空"
);
return
returnErrorValue
(
"参数不能为空"
);
}
}
Address
addressObj
=
addressService
.
findByUserId
(
userId
);
Address
addressObj
=
addressService
.
findByUserId
(
userId
);
...
@@ -515,7 +524,7 @@ public class MotanUserServiceImpl implements UserMotanService {
...
@@ -515,7 +524,7 @@ public class MotanUserServiceImpl implements UserMotanService {
return
returnErrorValue
(
"用户不能为空"
);
return
returnErrorValue
(
"用户不能为空"
);
}
}
UserSpouse
userSpouse
=
userSpouseService
.
findByUserId
(
userId
);
UserSpouse
userSpouse
=
userSpouseService
.
findByUserId
(
userId
);
if
(
userSpouse
==
null
)
{
if
(
userSpouse
==
null
||
!
userSpouse
.
valid
()
)
{
userSpouse
=
new
UserSpouse
(
userId
);
userSpouse
=
new
UserSpouse
(
userId
);
userSpouse
.
setStatus
(
MaritalStatus
.
UNKNOWN
);
userSpouse
.
setStatus
(
MaritalStatus
.
UNKNOWN
);
}
}
...
@@ -594,8 +603,8 @@ public class MotanUserServiceImpl implements UserMotanService {
...
@@ -594,8 +603,8 @@ public class MotanUserServiceImpl implements UserMotanService {
if
(!
ValidationUtil
.
validatePhoneNo
(
spousePhone
))
{
if
(!
ValidationUtil
.
validatePhoneNo
(
spousePhone
))
{
return
returnErrorValue
(
"手机号格式错误"
);
return
returnErrorValue
(
"手机号格式错误"
);
}
}
if
(
StringUtils
.
isBlank
(
spouseName
))
{
if
(
!
ValidationUtil
.
validateChinese
(
spouseName
))
{
return
returnErrorValue
(
"配偶姓名
不能为空
"
);
return
returnErrorValue
(
"配偶姓名
错误
"
);
}
}
}
}
UserSpouse
userSpouse
=
userSpouseService
.
findByUserId
(
xUserSpouse
.
getUserId
());
UserSpouse
userSpouse
=
userSpouseService
.
findByUserId
(
xUserSpouse
.
getUserId
());
...
@@ -805,7 +814,7 @@ public class MotanUserServiceImpl implements UserMotanService {
...
@@ -805,7 +814,7 @@ public class MotanUserServiceImpl implements UserMotanService {
log
.
info
(
"第三方(聚美)登录用户注册成功, registerFrom:{}, phoneNo:{},idNo:{},name:{} 并且已发送短信通知"
,
registerFrom
,
phoneNo
,
idNo
,
name
);
log
.
info
(
"第三方(聚美)登录用户注册成功, registerFrom:{}, phoneNo:{},idNo:{},name:{} 并且已发送短信通知"
,
registerFrom
,
phoneNo
,
idNo
,
name
);
}
}
if
(
StringUtils
.
isNot
Empty
(
idNo
)
&&
StringUtils
.
isNotEmpty
(
name
))
{
if
(
StringUtils
.
isNot
Blank
(
idNo
)
&&
StringUtils
.
isNotBlank
(
name
)
&&
ValidationUtil
.
validateChinese
(
name
))
{
IdCardInfo
cardInfo
;
IdCardInfo
cardInfo
;
try
{
try
{
cardInfo
=
idCardService
.
getIdCardInfoWithExceptions
(
idNo
);
cardInfo
=
idCardService
.
getIdCardInfoWithExceptions
(
idNo
);
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/user/AppController.java
View file @
f299eba2
...
@@ -35,6 +35,8 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -35,6 +35,8 @@ import org.springframework.web.bind.annotation.RestController;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.text.ParseException
;
import
java.util.Objects
;
import
java.util.Random
;
import
java.util.Random
;
import
static
cn
.
quantgroup
.
xyqb
.
constant
.
UserConstant
.
USER_ERROR_OR_PASSWORD_ERROR
;
import
static
cn
.
quantgroup
.
xyqb
.
constant
.
UserConstant
.
USER_ERROR_OR_PASSWORD_ERROR
;
...
@@ -231,14 +233,10 @@ public class AppController implements IBaseController {
...
@@ -231,14 +233,10 @@ public class AppController implements IBaseController {
* @return
* @return
*/
*/
private
User
register
(
Long
registerFrom
,
String
phoneNo
,
String
idNo
,
String
name
,
Long
channelId
)
{
private
User
register
(
Long
registerFrom
,
String
phoneNo
,
String
idNo
,
String
name
,
Long
channelId
)
{
String
randomCode
=
String
.
valueOf
(
random
.
nextInt
(
899999
)
+
100000
);
String
randomCode
=
String
.
valueOf
(
random
.
nextInt
(
899999
)
+
100000
);
String
uuid
=
lkbUserService
.
registerApp
(
phoneNo
,
randomCode
);
String
uuid
=
lkbUserService
.
registerApp
(
phoneNo
,
randomCode
);
Timestamp
currentTime
=
new
Timestamp
(
System
.
currentTimeMillis
());
Timestamp
currentTime
=
new
Timestamp
(
System
.
currentTimeMillis
());
LOGGER
.
info
(
"第三方登录用户,保存 User"
);
LOGGER
.
info
(
"第三方登录用户,保存 User"
);
User
user
=
new
User
();
User
user
=
new
User
();
if
(
channelId
==
222L
)
{
if
(
channelId
==
222L
)
{
user
.
setRegisteredFrom
(
channelId
);
user
.
setRegisteredFrom
(
channelId
);
...
@@ -262,7 +260,7 @@ public class AppController implements IBaseController {
...
@@ -262,7 +260,7 @@ public class AppController implements IBaseController {
LOGGER
.
info
(
"第三方(聚美)登录用户注册成功, registerFrom:{}, phoneNo:{},idNo:{},name:{} 并且已发送短信通知"
,
registerFrom
,
phoneNo
,
idNo
,
name
);
LOGGER
.
info
(
"第三方(聚美)登录用户注册成功, registerFrom:{}, phoneNo:{},idNo:{},name:{} 并且已发送短信通知"
,
registerFrom
,
phoneNo
,
idNo
,
name
);
}
}
if
(
StringUtils
.
isNot
Empty
(
idNo
)
&&
StringUtils
.
isNotEmpty
(
name
))
{
if
(
StringUtils
.
isNot
Blank
(
idNo
)
&&
StringUtils
.
isNotBlank
(
name
)
&&
ValidationUtil
.
validateChinese
(
name
))
{
LOGGER
.
info
(
"第三方登录用户,保存 UserDetail"
);
LOGGER
.
info
(
"第三方登录用户,保存 UserDetail"
);
IdCardInfo
cardInfo
;
IdCardInfo
cardInfo
;
try
{
try
{
...
@@ -284,12 +282,7 @@ public class AppController implements IBaseController {
...
@@ -284,12 +282,7 @@ public class AppController implements IBaseController {
LOGGER
.
error
(
"保存 UserDetail 出现异常"
,
e
);
LOGGER
.
error
(
"保存 UserDetail 出现异常"
,
e
);
}
}
}
}
//增加登陆统计发送
MqUtils
.
sendRegisterMessage
(
channelId
,
user
);
UserStatistics
statistics
=
new
UserStatistics
(
user
,
null
,
2
,
channelId
);
MqUtils
.
sendLoanVest
(
statistics
);
//增加用户注册广播
UserRegisterMqMessage
registerMqMessage
=
new
UserRegisterMqMessage
(
user
);
MqUtils
.
sendRegisterMessage
(
registerMqMessage
);
return
user
;
return
user
;
}
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/user/InnerController.java
View file @
f299eba2
This diff is collapsed.
Click to expand it.
src/main/java/cn/quantgroup/xyqb/controller/external/user/SyncUserController.java
View file @
f299eba2
...
@@ -2,17 +2,25 @@ package cn.quantgroup.xyqb.controller.external.user;
...
@@ -2,17 +2,25 @@ package cn.quantgroup.xyqb.controller.external.user;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.model.IdCardInfo
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.model.UserModel
;
import
cn.quantgroup.xyqb.model.UserModel
;
import
cn.quantgroup.xyqb.service.auth.IIdCardService
;
import
cn.quantgroup.xyqb.service.user.IUserDetailService
;
import
cn.quantgroup.xyqb.service.user.IUserDetailService
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.text.ParseException
;
import
java.util.Objects
;
/**
/**
* 同步用户数据,第三方模块访问时
* 同步用户数据,第三方模块访问时
* Created by Miraculous on 15/12/29.
* Created by Miraculous on 15/12/29.
...
@@ -20,13 +28,14 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -20,13 +28,14 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RestController
@RequestMapping
(
"/api/sync"
)
@RequestMapping
(
"/api/sync"
)
public
class
SyncUserController
{
public
class
SyncUserController
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
SyncUserController
.
class
);
@Autowired
@Autowired
private
IUserService
userService
;
private
IUserService
userService
;
@Autowired
@Autowired
private
IUserDetailService
userDetailService
;
private
IUserDetailService
userDetailService
;
/*
@Autowired
@Autowired
private IUserDetailRepository userDetailRepository;*/
private
IIdCardService
idCardService
;
@Autowired
@Autowired
...
@@ -56,9 +65,22 @@ public class SyncUserController {
...
@@ -56,9 +65,22 @@ public class SyncUserController {
@RequestMapping
(
"/save_detail"
)
@RequestMapping
(
"/save_detail"
)
public
JsonResult
saveUserDetail
(
String
key
,
UserDetail
userDetail
)
{
public
JsonResult
saveUserDetail
(
String
key
,
UserDetail
userDetail
)
{
if
(
StringUtils
.
isEmpty
(
key
)
||
!
"abc1234"
.
equals
(
key
))
{
if
(
StringUtils
.
isEmpty
(
key
)
||
!
"abc1234"
.
equals
(
key
)
||
Objects
.
isNull
(
userDetail
)
||
StringUtils
.
isBlank
(
userDetail
.
getPhoneNo
())
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
}
if
(!
ValidationUtil
.
validateChinese
(
userDetail
.
getName
()))
{
return
JsonResult
.
buildErrorStateResult
(
"姓名错误"
,
null
);
}
IdCardInfo
info
=
null
;
try
{
info
=
idCardService
.
getIdCardInfo
(
userDetail
.
getIdNo
());
}
catch
(
ParseException
ex
)
{
LOGGER
.
error
(
"身份证号错误, idNo: {}"
,
userDetail
.
getIdNo
());
return
JsonResult
.
buildErrorStateResult
(
"身份证号码错误"
,
null
);
}
if
(
Objects
.
isNull
(
info
)
||
!
info
.
isValid
())
{
return
JsonResult
.
buildErrorStateResult
(
"身份证号码错误"
,
null
);
}
String
phoneNo
=
userDetail
.
getPhoneNo
();
String
phoneNo
=
userDetail
.
getPhoneNo
();
User
user
=
userService
.
findByPhoneWithCache
(
phoneNo
);
User
user
=
userService
.
findByPhoneWithCache
(
phoneNo
);
if
(
null
==
user
)
{
if
(
null
==
user
)
{
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/user/center/UserCenterController.java
View file @
f299eba2
...
@@ -11,6 +11,7 @@ import cn.quantgroup.xyqb.model.ContactRet;
...
@@ -11,6 +11,7 @@ import cn.quantgroup.xyqb.model.ContactRet;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.service.user.*
;
import
cn.quantgroup.xyqb.service.user.*
;
import
cn.quantgroup.user.enums.*
;
import
cn.quantgroup.user.enums.*
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.alibaba.fastjson.TypeReference
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
...
@@ -200,7 +201,7 @@ public class UserCenterController {
...
@@ -200,7 +201,7 @@ public class UserCenterController {
return
JsonResult
.
buildErrorStateResult
(
"该用户不存在"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"该用户不存在"
,
null
);
}
}
UserExtInfo
userExtInfo
=
userExtInfoService
.
findByUserId
(
userId
);
UserExtInfo
userExtInfo
=
userExtInfoService
.
findByUserId
(
userId
);
List
<
Contact
>
contacts
=
contactService
.
findByUserId
(
userId
);
List
<
Contact
>
contacts
=
contactService
.
findByUserId
(
userId
,
true
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
if
(
null
!=
userExtInfo
)
{
if
(
null
!=
userExtInfo
)
{
result
.
put
(
"contacts"
,
null
!=
contacts
&&
contacts
.
size
()
>
0
?
true
:
false
);
result
.
put
(
"contacts"
,
null
!=
contacts
&&
contacts
.
size
()
>
0
?
true
:
false
);
...
@@ -244,32 +245,18 @@ public class UserCenterController {
...
@@ -244,32 +245,18 @@ public class UserCenterController {
LOGGER
.
error
(
"保存联系人,联系人参数为空.contactJson:{}"
,
contactJson
);
LOGGER
.
error
(
"保存联系人,联系人参数为空.contactJson:{}"
,
contactJson
);
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
}
List
<
Contact
>
userContact
=
contactService
.
findByUserId
(
userId
);
List
<
Contact
>
contacts
=
JSONObject
.
parseObject
(
contactJson
,
new
TypeReference
<
List
<
Contact
>>(){});
/*if(userContact != null && userContact.size() >= 2) {
return JsonResult.buildSuccessResult(null, ContactRet.contacts2ContactRets(userContact));
}*/
//推翻之前逻辑,联系人可以更改.如果数据库已有记录.则更改
List
<
Contact
>
contacts
=
JSONObject
.
parseObject
(
contactJson
,
new
TypeReference
<
List
<
Contact
>>()
{});
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
if
(
CollectionUtils
.
isEmpty
(
contacts
))
{
if
(
CollectionUtils
.
isEmpty
(
contacts
))
{
return
JsonResult
.
buildErrorStateResult
(
"参数转换错误"
,
null
);
LOGGER
.
info
(
"联系人不能空"
);
}
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
if
(
null
!=
userContact
&&
userContact
.
size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
contacts
.
size
();
i
++)
{
contacts
.
get
(
i
).
setId
(
userContact
.
get
(
i
).
getId
());
contacts
.
get
(
i
).
setUserId
(
userContact
.
get
(
i
).
getUserId
());
contacts
.
get
(
i
).
setCreatedAt
(
now
);
contacts
.
get
(
i
).
setUpdateAt
(
now
);
}
}
}
else
{
for
(
Contact
contact
:
contacts
){
for
(
Contact
c
:
contacts
)
{
if
(!
contact
.
valid
())
{
c
.
setId
(
null
);
LOGGER
.
info
(
"用户手机号或姓名错误, phoneNo:{},name:{}"
,
contact
.
getPhoneNo
(),
contact
.
getName
());
c
.
setUserId
(
userId
);
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
c
.
setCreatedAt
(
now
);
c
.
setUpdateAt
(
now
);
}
}
}
}
List
<
Contact
>
result
=
contactService
.
save
(
contacts
);
List
<
Contact
>
result
=
contactService
.
save
(
userId
,
contacts
);
return
JsonResult
.
buildSuccessResult
(
null
,
result
);
return
JsonResult
.
buildSuccessResult
(
null
,
result
);
}
}
...
@@ -285,8 +272,8 @@ public class UserCenterController {
...
@@ -285,8 +272,8 @@ public class UserCenterController {
@RequestMapping
(
"/address/save"
)
@RequestMapping
(
"/address/save"
)
public
JsonResult
saveUserAddress
(
String
phoneNo
,
String
province
,
Long
provinceCode
,
String
city
,
Long
cityCode
,
String
address
,
public
JsonResult
saveUserAddress
(
String
phoneNo
,
String
province
,
Long
provinceCode
,
String
city
,
Long
cityCode
,
String
address
,
Long
districtCode
,
String
district
)
{
Long
districtCode
,
String
district
)
{
LOGGER
.
info
(
"保存用户地址信息, phoneNo:{}, province:{}, provinceCode:{}, city:{}, cityCode:{}
"
,
phoneNo
,
province
,
provinceCode
,
city
,
cityCode
);
LOGGER
.
info
(
"保存用户地址信息, phoneNo:{}, province:{}, provinceCode:{}, city:{}, cityCode:{}
,district:{}, address:{}"
,
phoneNo
,
province
,
provinceCode
,
city
,
cityCode
,
district
,
address
);
if
(
StringUtils
.
isEmpty
(
phoneNo
)
||
provinceCode
==
null
||
cityCode
==
null
)
{
if
(
StringUtils
.
isEmpty
(
phoneNo
)
||
provinceCode
==
null
||
cityCode
==
null
||
StringUtils
.
isBlank
(
address
)
)
{
return
JsonResult
.
buildErrorStateResult
(
"参数错误"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"参数错误"
,
null
);
}
}
Long
userId
=
queryUserId
(
phoneNo
);
Long
userId
=
queryUserId
(
phoneNo
);
...
@@ -350,7 +337,7 @@ public class UserCenterController {
...
@@ -350,7 +337,7 @@ public class UserCenterController {
LOGGER
.
error
(
"保存联系人,未获取到用户id. userId:{}"
,
userId
);
LOGGER
.
error
(
"保存联系人,未获取到用户id. userId:{}"
,
userId
);
return
JsonResult
.
buildErrorStateResult
(
"该用户不存在"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"该用户不存在"
,
null
);
}
}
List
<
Contact
>
contacts
=
contactService
.
findByUserId
(
userId
);
List
<
Contact
>
contacts
=
contactService
.
findByUserId
(
userId
,
true
);
return
JsonResult
.
buildSuccessResult
(
null
,
contacts
);
return
JsonResult
.
buildSuccessResult
(
null
,
contacts
);
}
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/user/UserController.java
View file @
f299eba2
...
@@ -162,11 +162,7 @@ public class UserController implements IBaseController {
...
@@ -162,11 +162,7 @@ public class UserController implements IBaseController {
}
}
User
user
=
userService
.
registerAndReturn
(
phoneNo
,
password
,
registerFrom
,
btRegisterChannelId
);
User
user
=
userService
.
registerAndReturn
(
phoneNo
,
password
,
registerFrom
,
btRegisterChannelId
);
LOGGER
.
info
(
"用户快速注册成功, registerFrom:{}, phoneNo:{}"
,
registerFrom
,
phoneNo
);
LOGGER
.
info
(
"用户快速注册成功, registerFrom:{}, phoneNo:{}"
,
registerFrom
,
phoneNo
);
UserStatistics
statistics
=
new
UserStatistics
(
user
,
dimension
,
2
,
channelId
);
MqUtils
.
sendRegisterMessage
(
channelId
,
user
);
MqUtils
.
sendLoanVest
(
statistics
);
//增加用户注册广播
UserRegisterMqMessage
registerMqMessage
=
new
UserRegisterMqMessage
(
user
);
MqUtils
.
sendRegisterMessage
(
registerMqMessage
);
return
user
;
return
user
;
}
}
...
...
src/main/java/cn/quantgroup/xyqb/entity/Contact.java
View file @
f299eba2
package
cn
.
quantgroup
.
xyqb
.
entity
;
package
cn
.
quantgroup
.
xyqb
.
entity
;
import
cn.quantgroup.user.enums.Relation
;
import
cn.quantgroup.user.enums.Relation
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
lombok.Data
;
import
lombok.Data
;
import
javax.persistence.*
;
import
javax.persistence.*
;
...
@@ -32,4 +33,13 @@ public class Contact implements Serializable {
...
@@ -32,4 +33,13 @@ public class Contact implements Serializable {
private
Timestamp
createdAt
;
private
Timestamp
createdAt
;
@Column
(
name
=
"updated_at"
)
@Column
(
name
=
"updated_at"
)
private
Timestamp
updateAt
;
private
Timestamp
updateAt
;
/**
* 数据合法性校验
* @return
*/
public
boolean
valid
(){
return
(
ValidationUtil
.
validatePhoneNo
(
this
.
phoneNo
)
&&
ValidationUtil
.
validateChinese
(
this
.
name
));
}
}
}
src/main/java/cn/quantgroup/xyqb/entity/UserSpouse.java
View file @
f299eba2
...
@@ -2,6 +2,7 @@ package cn.quantgroup.xyqb.entity;
...
@@ -2,6 +2,7 @@ package cn.quantgroup.xyqb.entity;
import
cn.quantgroup.user.enums.MaritalStatus
;
import
cn.quantgroup.user.enums.MaritalStatus
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
lombok.*
;
import
lombok.*
;
import
javax.persistence.*
;
import
javax.persistence.*
;
...
@@ -44,4 +45,12 @@ public class UserSpouse implements Serializable {
...
@@ -44,4 +45,12 @@ public class UserSpouse implements Serializable {
public
UserSpouse
(
Long
userId
)
{
public
UserSpouse
(
Long
userId
)
{
this
.
userId
=
userId
;
this
.
userId
=
userId
;
}
}
/**
* 数据合法性校验
* @return
*/
public
boolean
valid
(){
return
(
ValidationUtil
.
validatePhoneNo
(
this
.
spousePhone
)
&&
ValidationUtil
.
validateChinese
(
this
.
spouseName
));
}
}
}
src/main/java/cn/quantgroup/xyqb/model/UserRet.java
View file @
f299eba2
...
@@ -41,7 +41,7 @@ public class UserRet implements Serializable {
...
@@ -41,7 +41,7 @@ public class UserRet implements Serializable {
this
.
setId
(
user
.
getId
());
this
.
setId
(
user
.
getId
());
this
.
setPhoneNo
(
user
.
getPhoneNo
());
this
.
setPhoneNo
(
user
.
getPhoneNo
());
this
.
setEnable
(
user
.
getEnable
());
this
.
setEnable
(
user
.
getEnable
());
this
.
setPassword
(
StringUtils
.
defaultIfEmpty
(
user
.
getPassword
(),
""
)
);
this
.
setPassword
(
""
);
this
.
setRegisteredFrom
(
user
.
getRegisteredFrom
());
this
.
setRegisteredFrom
(
user
.
getRegisteredFrom
());
this
.
setUuid
(
user
.
getUuid
());
this
.
setUuid
(
user
.
getUuid
());
this
.
setCreatedAt
(
createTimeStamp
);
this
.
setCreatedAt
(
createTimeStamp
);
...
...
src/main/java/cn/quantgroup/xyqb/service/page/impl/PageServiceImpl.java
View file @
f299eba2
...
@@ -55,7 +55,7 @@ public class PageServiceImpl implements IPageService {
...
@@ -55,7 +55,7 @@ public class PageServiceImpl implements IPageService {
private
PageType
pageContacts
=
new
PageType
(
"contacts"
,
false
)
{
private
PageType
pageContacts
=
new
PageType
(
"contacts"
,
false
)
{
@Override
@Override
public
boolean
canPass
(
User
user
)
{
public
boolean
canPass
(
User
user
)
{
List
<
Contact
>
contacts
=
contactService
.
findByUserId
(
user
.
getId
());
List
<
Contact
>
contacts
=
contactService
.
findByUserId
(
user
.
getId
()
,
true
);
return
contacts
!=
null
&&
contacts
.
size
()
!=
0
;
return
contacts
!=
null
&&
contacts
.
size
()
!=
0
;
}
}
};
};
...
...
src/main/java/cn/quantgroup/xyqb/service/user/IContactService.java
View file @
f299eba2
...
@@ -9,11 +9,24 @@ import java.util.List;
...
@@ -9,11 +9,24 @@ import java.util.List;
* Created by Miraculous on 2017/1/3.
* Created by Miraculous on 2017/1/3.
*/
*/
public
interface
IContactService
{
public
interface
IContactService
{
List
<
Contact
>
findByUserId
(
Long
userId
);
/**
*
* @param userId - 用户主键
* @param trim - 是否清除非法错误记录,true-清除,false-不清除
* @return
*/
List
<
Contact
>
findByUserId
(
Long
userId
,
boolean
trim
);
Contact
findById
(
Long
id
);
Contact
findById
(
Long
id
);
List
<
Contact
>
save
(
List
<
Contact
>
contacts
);
/**
* 批量保存用户联系人
* 如果已存在联系人,则覆盖更新
* @param userId - 用户主键
* @param contacts - 联系人列表
* @return
*/
List
<
Contact
>
save
(
Long
userId
,
List
<
Contact
>
contacts
);
Contact
save
(
Contact
contact
);
Contact
save
(
Contact
contact
);
Contact
saveContact
(
String
name
,
String
phoneNo
,
Relation
relation
,
Contact
contact
);
Contact
saveContact
(
String
name
,
String
phoneNo
,
Relation
relation
,
Contact
contact
);
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/ContactServiceImpl.java
View file @
f299eba2
...
@@ -5,13 +5,21 @@ import cn.quantgroup.xyqb.controller.external.user.InnerController;
...
@@ -5,13 +5,21 @@ import cn.quantgroup.xyqb.controller.external.user.InnerController;
import
cn.quantgroup.xyqb.entity.Contact
;
import
cn.quantgroup.xyqb.entity.Contact
;
import
cn.quantgroup.xyqb.repository.IContactRepository
;
import
cn.quantgroup.xyqb.repository.IContactRepository
;
import
cn.quantgroup.xyqb.service.user.IContactService
;
import
cn.quantgroup.xyqb.service.user.IContactService
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.tomcat.util.bcel.classfile.Constant
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.cache.annotation.Caching
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -24,9 +32,30 @@ public class ContactServiceImpl implements IContactService {
...
@@ -24,9 +32,30 @@ public class ContactServiceImpl implements IContactService {
private
IContactRepository
contactRepository
;
private
IContactRepository
contactRepository
;
@Override
@Override
@Cacheable
(
value
=
"contact"
,
key
=
"'contact' + #userId"
,
unless
=
"#result == null or #result.size() == 0"
,
cacheManager
=
"cacheManager"
)
@Cacheable
(
value
=
"contact"
,
key
=
"'contact:' + #trim + #userId"
,
unless
=
"#result == null or #result.size() == 0"
,
cacheManager
=
"cacheManager"
)
public
List
<
Contact
>
findByUserId
(
Long
userId
)
{
public
List
<
Contact
>
findByUserId
(
Long
userId
,
boolean
trim
)
{
return
contactRepository
.
findByUserId
(
userId
);
List
<
Contact
>
contacts
=
contactRepository
.
findByUserId
(
userId
);
if
(
trim
){
trim
(
contacts
);
}
return
contacts
;
}
/**
* 过滤掉非法联系人记录
* @param contacts - 包含待清除记录的联系人列表
*/
private
void
trim
(
List
<
Contact
>
contacts
){
if
(
CollectionUtils
.
isEmpty
(
contacts
)){
return
;
}
Iterator
<
Contact
>
iterator
=
contacts
.
iterator
();
while
(
iterator
.
hasNext
()){
Contact
contact
=
iterator
.
next
();
if
(!
contact
.
valid
())
{
iterator
.
remove
();
}
}
}
}
@Override
@Override
...
@@ -35,22 +64,32 @@ public class ContactServiceImpl implements IContactService {
...
@@ -35,22 +64,32 @@ public class ContactServiceImpl implements IContactService {
}
}
@Override
@Override
@CacheEvict
(
value
=
"contact"
,
key
=
"'contact' + #contacts.get(0).userId"
,
cacheManager
=
"cacheManager"
)
@Caching
(
evict
=
{
public
List
<
Contact
>
save
(
List
<
Contact
>
contacts
)
{
@CacheEvict
(
value
=
"contact"
,
key
=
"'contact:true' + #userId"
,
cacheManager
=
"cacheManager"
),
@CacheEvict
(
value
=
"contact"
,
key
=
"'contact:false' + #userId"
,
cacheManager
=
"cacheManager"
)})
public
List
<
Contact
>
save
(
Long
userId
,
List
<
Contact
>
contacts
)
{
if
(
userId
==
null
){
return
null
;
}
// 合并当前用户列表到更新列表
mergeContacts
(
userId
,
contacts
);
return
contactRepository
.
save
(
contacts
);
return
contactRepository
.
save
(
contacts
);
}
}
@Override
@Override
@CacheEvict
(
value
=
"contact"
,
key
=
"'contact' + #contact.userId"
,
cacheManager
=
"cacheManager"
)
@Caching
(
evict
=
{
@CacheEvict
(
value
=
"contact"
,
key
=
"'contact:true' + #contact.userId"
,
cacheManager
=
"cacheManager"
),
@CacheEvict
(
value
=
"contact"
,
key
=
"'contact:false' + #contact.userId"
,
cacheManager
=
"cacheManager"
)})
public
Contact
save
(
Contact
contact
)
{
public
Contact
save
(
Contact
contact
)
{
return
contactRepository
.
save
(
contact
);
return
contactRepository
.
save
(
contact
);
}
}
@Override
public
Contact
saveContact
(
String
name
,
String
phoneNo
,
Relation
relation
,
Contact
contact
)
{
public
Contact
saveContact
(
String
name
,
String
phoneNo
,
Relation
relation
,
Contact
contact
)
{
if
(
null
!=
name
)
{
if
(
StringUtils
.
isNotBlank
(
name
)
)
{
contact
.
setName
(
name
);
contact
.
setName
(
name
);
}
}
if
(
null
!=
phoneNo
)
{
if
(
StringUtils
.
isNotBlank
(
phoneNo
)
)
{
contact
.
setPhoneNo
(
phoneNo
);
contact
.
setPhoneNo
(
phoneNo
);
}
}
if
(
null
!=
relation
)
{
if
(
null
!=
relation
)
{
...
@@ -62,4 +101,29 @@ public class ContactServiceImpl implements IContactService {
...
@@ -62,4 +101,29 @@ public class ContactServiceImpl implements IContactService {
contact
=
save
(
contact
);
contact
=
save
(
contact
);
return
contact
;
return
contact
;
}
}
/**
* 合并当前用户列表到更新列表
* @param userId - 用户主键
* @param contacts - 新联系人列表
*/
private
void
mergeContacts
(
Long
userId
,
List
<
Contact
>
contacts
)
{
// 当前联系人列表
List
<
Contact
>
userContact
=
contactRepository
.
findByUserId
(
userId
);
int
userContactCount
=
(
userContact
==
null
)
?
0
:
userContact
.
size
();
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
for
(
int
i
=
0
;
i
<
contacts
.
size
();
i
++)
{
Contact
c
=
contacts
.
get
(
i
);
c
.
setId
(
null
);
c
.
setUserId
(
userId
);
c
.
setRelation
(
c
.
getRelation
()
==
null
?
Relation
.
OTHER
:
c
.
getRelation
());
c
.
setCreatedAt
(
now
);
c
.
setUpdateAt
(
now
);
if
(
userContactCount
>
i
){
c
.
setId
(
userContact
.
get
(
i
).
getId
());
c
.
setCreatedAt
(
contacts
.
get
(
i
).
getCreatedAt
()
==
null
?
now
:
contacts
.
get
(
i
).
getCreatedAt
());
c
.
setRelation
(
contacts
.
get
(
i
).
getRelation
()
==
null
?
Relation
.
OTHER
:
contacts
.
get
(
i
).
getRelation
());
}
}
}
}
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
View file @
f299eba2
...
@@ -192,12 +192,7 @@ public class UserServiceImpl implements IUserService {
...
@@ -192,12 +192,7 @@ public class UserServiceImpl implements IUserService {
smsService
.
sendAfterRegister
(
phoneNo
);
smsService
.
sendAfterRegister
(
phoneNo
);
}
}
if
(
registerSuccess
){
if
(
registerSuccess
){
//增加登陆统计发送
MqUtils
.
sendRegisterMessage
(
channelId
,
user
);
UserStatistics
statistics
=
new
UserStatistics
(
user
,
dimension
,
2
,
channelId
);
MqUtils
.
sendLoanVest
(
statistics
);
//增加用户注册广播
UserRegisterMqMessage
registerMqMessage
=
new
UserRegisterMqMessage
(
user
);
MqUtils
.
sendRegisterMessage
(
registerMqMessage
);
}
}
return
user
!=
null
;
return
user
!=
null
;
}
}
...
...
src/main/java/cn/quantgroup/xyqb/util/MqUtils.java
View file @
f299eba2
package
cn
.
quantgroup
.
xyqb
.
util
;
package
cn
.
quantgroup
.
xyqb
.
util
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.model.UserRegisterMqMessage
;
import
cn.quantgroup.xyqb.model.UserRegisterMqMessage
;
import
cn.quantgroup.xyqb.model.UserRet
;
import
cn.quantgroup.xyqb.model.UserStatistics
;
import
cn.quantgroup.xyqb.model.UserStatistics
;
import
cn.quantgroup.xyqb.service.mq.IRegisterMqService
;
import
cn.quantgroup.xyqb.service.mq.IRegisterMqService
;
import
cn.quantgroup.xyqb.service.mq.IVestService
;
import
cn.quantgroup.xyqb.service.mq.IVestService
;
...
@@ -37,4 +39,15 @@ public class MqUtils {
...
@@ -37,4 +39,15 @@ public class MqUtils {
message
,
e
);
message
,
e
);
}
}
}
}
public
static
UserRet
sendRegisterMessage
(
Long
registeredFrom
,
User
user
)
{
UserRet
userRet
;
UserStatistics
statistics
=
new
UserStatistics
(
user
,
null
,
2
,
registeredFrom
);
MqUtils
.
sendLoanVest
(
statistics
);
userRet
=
new
UserRet
(
user
);
//增加用户注册广播
UserRegisterMqMessage
registerMqMessage
=
new
UserRegisterMqMessage
(
user
);
MqUtils
.
sendRegisterMessage
(
registerMqMessage
);
return
userRet
;
}
}
}
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