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
423b1579
Commit
423b1579
authored
Jun 28, 2023
by
王亮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify user detail.
parent
3fca5558
Changes
39
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
473 additions
and
958 deletions
+473
-958
update-20230621.sql
doc/sql/update-20230621.sql
+26
-0
UserConstant.java
src/main/java/cn/quantgroup/xyqb/constant/UserConstant.java
+3
-0
UserController.java
...n/quantgroup/xyqb/controller/external/UserController.java
+21
-15
PlatformApiController.java
...b/controller/external/platform/PlatformApiController.java
+2
-2
UserQueryLogController.java
.../controller/internal/querylog/UserQueryLogController.java
+5
-201
InnerController.java
...tgroup/xyqb/controller/internal/user/InnerController.java
+50
-181
SyncUserController.java
...oup/xyqb/controller/internal/user/SyncUserController.java
+21
-17
UserCenterController.java
...controller/internal/user/center/UserCenterController.java
+6
-10
UserDetailController.java
...troller/middleoffice/userdetail/UserDetailController.java
+16
-15
UserExtController.java
...qb/controller/middleoffice/userext/UserExtController.java
+6
-9
ModifyPhoneNoResp.java
...xyqb/controller/modifyphoneno/resp/ModifyPhoneNoResp.java
+3
-2
UserModifyPhoneRecordResp.java
...troller/modifyphoneno/resp/UserModifyPhoneRecordResp.java
+4
-3
BaseEntity.java
src/main/java/cn/quantgroup/xyqb/entity/BaseEntity.java
+9
-8
User.java
src/main/java/cn/quantgroup/xyqb/entity/User.java
+3
-0
UserInfoEntity.java
src/main/java/cn/quantgroup/xyqb/entity/UserInfoEntity.java
+50
-0
LocalDateAttributeConverter.java
...up/xyqb/entity/converter/LocalDateAttributeConverter.java
+19
-0
LocalDateTimeAttributeConverter.java
...yqb/entity/converter/LocalDateTimeAttributeConverter.java
+19
-0
DetailRegisteredEventListener.java
.../quantgroup/xyqb/event/DetailRegisteredEventListener.java
+5
-7
UserDetailUpdateEvent.java
.../java/cn/quantgroup/xyqb/event/UserDetailUpdateEvent.java
+0
-24
UserDisableRecordModel.java
...java/cn/quantgroup/xyqb/model/UserDisableRecordModel.java
+32
-30
UserFullInfo.java
src/main/java/cn/quantgroup/xyqb/model/UserFullInfo.java
+5
-5
UserInfo.java
src/main/java/cn/quantgroup/xyqb/model/UserInfo.java
+4
-4
UserInfoRet.java
src/main/java/cn/quantgroup/xyqb/model/UserInfoRet.java
+74
-0
UserModel.java
src/main/java/cn/quantgroup/xyqb/model/UserModel.java
+2
-2
UserRegisterMqMessage.java
.../java/cn/quantgroup/xyqb/model/UserRegisterMqMessage.java
+4
-3
UserRet.java
src/main/java/cn/quantgroup/xyqb/model/UserRet.java
+3
-2
IUserDetailRepository.java
.../cn/quantgroup/xyqb/repository/IUserDetailRepository.java
+0
-59
IUserInfoRepository.java
...va/cn/quantgroup/xyqb/repository/IUserInfoRepository.java
+38
-0
UserApiServiceImpl.java
.../quantgroup/xyqb/service/api/impl/UserApiServiceImpl.java
+6
-5
PageServiceImpl.java
...cn/quantgroup/xyqb/service/page/impl/PageServiceImpl.java
+5
-4
IUserDetailService.java
...a/cn/quantgroup/xyqb/service/user/IUserDetailService.java
+0
-54
IUserService.java
...in/java/cn/quantgroup/xyqb/service/user/IUserService.java
+3
-3
ModifyPhoneNoServiceImpl.java
...roup/xyqb/service/user/impl/ModifyPhoneNoServiceImpl.java
+4
-9
UserDetailServiceImpl.java
...ntgroup/xyqb/service/user/impl/UserDetailServiceImpl.java
+0
-253
UserServiceImpl.java
...cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
+10
-12
JsonTest.java
src/test/java/common/JsonTest.java
+8
-9
RepsitoryJpaTest.java
src/test/java/demo/RepsitoryJpaTest.java
+2
-3
RepsitoryTest.java
src/test/java/demo/RepsitoryTest.java
+3
-4
ServiceTest.java
src/test/java/demo/ServiceTest.java
+2
-3
No files found.
doc/sql/update-20230621.sql
View file @
423b1579
----新增用户资料表
CREATE
TABLE
`xyqb_user`
.
`user_info`
(
`id`
BIGINT
(
20
)
NOT
NULL
AUTO_INCREMENT
,
`user_id`
BIGINT
(
20
)
NOT
NULL
COMMENT
'用户表id'
,
`phone_no`
VARCHAR
(
20
)
NULL
COMMENT
'手机号码'
,
`gender`
TINYINT
(
3
)
NULL
COMMENT
'性别'
,
`email`
VARCHAR
(
45
)
NULL
COMMENT
'邮箱'
,
`qq`
VARCHAR
(
20
)
NULL
COMMENT
'腾讯qq'
,
`nick_name`
VARCHAR
(
45
)
NULL
COMMENT
'昵称'
,
`photo`
VARCHAR
(
255
)
NULL
COMMENT
'头像地址'
,
`birthday`
DATE
NULL
COMMENT
'生日'
,
`province_id`
INT
NULL
COMMENT
'地址省份id'
,
`city_id`
INT
NULL
COMMENT
'地址市id'
,
`address`
VARCHAR
(
255
)
NULL
COMMENT
'详细地址'
,
`tenant_id`
INT
NOT
NULL
COMMENT
'租户id'
,
`created_at`
TIMESTAMP
NULL
DEFAULT
CURRENT_TIMESTAMP
,
`updated_at`
TIMESTAMP
NULL
DEFAULT
CURRENT_TIMESTAMP
,
PRIMARY
KEY
(
`id`
),
INDEX
`idx_user_id`
(
`user_id`
ASC
),
INDEX
`idx_user_phone`
(
`phone_no`
ASC
)
);
ALTER
TABLE
`xyqb_user`
.
`user`
ADD
COLUMN
`tenant_id`
INT
NULL
COMMENT
'租户id'
AFTER
`cipher_password`
;
src/main/java/cn/quantgroup/xyqb/constant/UserConstant.java
View file @
423b1579
...
...
@@ -6,4 +6,7 @@ public class UserConstant {
public
static
final
String
USER_ERROR_OR_ENABLE_ERROR
=
"账号异常,请联系平台客服。"
;
public
static
final
String
USER_FREEZE_ERROR
=
"账号异常,已冻结。"
;
public
static
final
Integer
defaultTenantId
=
1028
;
public
static
final
String
defaultTenantIdString
=
"1028"
;
}
src/main/java/cn/quantgroup/xyqb/controller/external/UserController.java
View file @
423b1579
package
cn
.
quantgroup
.
xyqb
.
controller
.
external
;
import
cn.quantgroup.xyqb.constant.enums.LoginType
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.aspect.accessable.IpValidator
;
import
cn.quantgroup.xyqb.aspect.captcha.CaptchaFiniteValidator
;
...
...
@@ -8,6 +7,8 @@ import cn.quantgroup.xyqb.aspect.captcha.CaptchaNewValidator;
import
cn.quantgroup.xyqb.aspect.forbidden.AccessForbiddenValidator
;
import
cn.quantgroup.xyqb.aspect.limit.PasswordFreeAccessValidator
;
import
cn.quantgroup.xyqb.aspect.lock.PasswordErrorFiniteValidator
;
import
cn.quantgroup.xyqb.constant.UserConstant
;
import
cn.quantgroup.xyqb.constant.enums.LoginType
;
import
cn.quantgroup.xyqb.controller.IBaseController
;
import
cn.quantgroup.xyqb.entity.*
;
import
cn.quantgroup.xyqb.exception.UserNotExistException
;
...
...
@@ -15,13 +16,17 @@ import cn.quantgroup.xyqb.exception.VerificationCodeErrorException;
import
cn.quantgroup.xyqb.model.*
;
import
cn.quantgroup.xyqb.model.session.SessionStruct
;
import
cn.quantgroup.xyqb.model.session.SessionValue
;
import
cn.quantgroup.xyqb.repository.IUserInfoRepository
;
import
cn.quantgroup.xyqb.service.captcha.IGeetestLogService
;
import
cn.quantgroup.xyqb.service.http.IHttpService
;
import
cn.quantgroup.xyqb.service.merchant.IMerchantService
;
import
cn.quantgroup.xyqb.service.register.IUserRegisterService
;
import
cn.quantgroup.xyqb.service.session.ISessionService
;
import
cn.quantgroup.xyqb.service.sms.ISmsService
;
import
cn.quantgroup.xyqb.service.user.*
;
import
cn.quantgroup.xyqb.service.user.ILockIpv4Service
;
import
cn.quantgroup.xyqb.service.user.ILoginRecordService
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.service.user.UserCenterService
;
import
cn.quantgroup.xyqb.service.wechat.IWechatService
;
import
cn.quantgroup.xyqb.session.XyqbSessionContextHolder
;
import
cn.quantgroup.xyqb.util.*
;
...
...
@@ -73,7 +78,7 @@ public class UserController implements IBaseController {
private
ISessionService
sessionService
;
@Autowired
private
IUser
DetailService
userDetailService
;
private
IUser
InfoRepository
userInfoRepository
;
@Autowired
private
IMerchantService
merchantService
;
@Autowired
...
...
@@ -450,7 +455,7 @@ public class UserController implements IBaseController {
return
JsonResult
.
buildErrorStateResult
(
"修改密码失败"
,
null
);
}
// 优先校验新的密码
if
(
StringUtils
.
isNotBlank
(
user
.
getCipherPassword
())
)
{
if
(
StringUtils
.
isNotBlank
(
user
.
getCipherPassword
()))
{
if
(!
BctyptPasswordUtil
.
BCryptCheckPw
(
password
,
user
.
getCipherPassword
()))
{
return
JsonResult
.
buildErrorStateResult
(
"修改密码失败"
,
null
);
}
...
...
@@ -537,7 +542,6 @@ public class UserController implements IBaseController {
/**
* token 交换
*
*/
@RequestMapping
(
"/tokenExchange"
)
public
JsonResult
tokenExchange
(
@RequestParam
String
token
,
@RequestParam
(
required
=
false
)
Integer
tenantId
)
{
...
...
@@ -564,7 +568,8 @@ public class UserController implements IBaseController {
}
/**
* 交换token
* 交换token
*
* @param token
* @return
*/
...
...
@@ -580,7 +585,8 @@ public class UserController implements IBaseController {
try
{
String
resultStr
=
httpService
.
post
(
userHost
+
"/api/finance-gateway/finance-user/finance/tokenExchange"
,
headers
,
parameters
);
JsonResult
<
TokenExchange
>
tokenExchangeResult
=
JSONObject
.
parseObject
(
resultStr
,
new
TypeReference
<
JsonResult
<
TokenExchange
>>(){});
JsonResult
<
TokenExchange
>
tokenExchangeResult
=
JSONObject
.
parseObject
(
resultStr
,
new
TypeReference
<
JsonResult
<
TokenExchange
>>()
{
});
// 如果有返回值
TokenExchange
tokenExchange
=
tokenExchangeResult
.
getData
();
if
(
tokenExchange
!=
null
)
{
...
...
@@ -610,7 +616,8 @@ public class UserController implements IBaseController {
@AccessForbiddenValidator
@PasswordFreeAccessValidator
@RequestMapping
(
"/center/index"
)
public
JsonResult
userCenterIndex
()
{
public
JsonResult
userCenterIndex
(
@RequestParam
(
value
=
"tenantId"
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
)
{
UserBrief
brief
=
new
UserBrief
();
//TODO:he 返回"",待解决
...
...
@@ -620,7 +627,7 @@ public class UserController implements IBaseController {
brief
.
setAvatar
(
userAttached
.
getAvatar
());
brief
.
setNick
(
userAttached
.
getNick
());
}
User
Detail
userDetail
=
userDetailService
.
findSlaveByUserId
(
user
Id
);
User
InfoEntity
userDetail
=
userInfoRepository
.
findByUserIdAndTenantId
(
userId
,
tenant
Id
);
if
(
userDetail
!=
null
)
{
brief
.
setName
(
userDetail
.
getName
());
brief
.
setSex
(
Optional
.
ofNullable
(
userDetail
.
getGender
()).
orElse
(
cn
.
quantgroup
.
xyqb
.
model
.
Gender
.
UNKNOWN
).
ordinal
()
+
""
);
...
...
@@ -638,13 +645,12 @@ public class UserController implements IBaseController {
*/
@Deprecated
@RequestMapping
(
"/syncUserInfo"
)
public
JsonResult
syncUserInfo
(
HttpServletRequest
request
)
{
log
.
error
(
"[监控][UserController][syncUserInfo] request-Header:{}"
,
JSON
.
toJSONString
(
getRequestHeaderMap
(
request
)));
public
JsonResult
syncUserInfo
()
{
User
user
=
getCurrentUserFromRedis
();
if
(
null
==
user
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
User
Detail
detail
=
userDetailService
.
findByUserId
(
user
.
ge
tId
());
User
InfoEntity
detail
=
userInfoRepository
.
findByUserIdAndTenantId
(
user
.
getId
(),
user
.
getTenan
tId
());
UserModel
userModel
=
new
UserModel
(
user
,
detail
);
return
JsonResult
.
buildSuccessResult
(
"token校验成功"
,
userModel
);
}
...
...
@@ -677,14 +683,14 @@ public class UserController implements IBaseController {
User
user
=
verificateUserNameAndPassword
(
request
);
if
(
user
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
"用户名或密码不正确"
,
null
);
}
else
if
(!
user
.
getEnable
())
{
}
else
if
(!
user
.
getEnable
())
{
return
JsonResult
.
buildErrorStateResult
(
USER_ERROR_OR_ENABLE_ERROR
,
null
);
}
else
if
(!
wechatRelateUserIfNecessary
(
user
,
request
))
{
return
JsonResult
.
buildErrorStateResult
(
"登录时微信关联失败"
,
null
);
}
LoginProperties
loginProperties
=
new
LoginProperties
(
""
,
1
,
channelId
,
createdFrom
,
appChannel
,
merchant
.
getId
(),
merchant
.
getName
(),
null
);
AuthBean
authBean
=
sessionService
.
createSession
(
user
,
loginProperties
,
LoginType
.
ACCOUNTPASSWORD
.
ordinal
());
if
(
authBean
!=
null
)
{
AuthBean
authBean
=
sessionService
.
createSession
(
user
,
loginProperties
,
LoginType
.
ACCOUNTPASSWORD
.
ordinal
());
if
(
authBean
!=
null
)
{
authBean
.
setRegister
(
false
);
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/platform/PlatformApiController.java
View file @
423b1579
...
...
@@ -7,9 +7,9 @@ import cn.quantgroup.xyqb.entity.MerchantConfig;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.model.Tuple
;
import
cn.quantgroup.xyqb.repository.IUserInfoRepository
;
import
cn.quantgroup.xyqb.service.merchant.IMerchantService
;
import
cn.quantgroup.xyqb.service.page.IPageService
;
import
cn.quantgroup.xyqb.service.user.IUserDetailService
;
import
com.google.common.collect.ImmutableMap
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -29,7 +29,7 @@ public class PlatformApiController implements IBaseController {
@Autowired
private
IMerchantService
merchantService
;
@Autowired
private
IUser
DetailService
userDetailService
;
private
IUser
InfoRepository
userInfoRepository
;
@RequestMapping
(
"/page/return_url"
)
public
JsonResult
returnUrl
(
String
key
)
{
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/querylog/UserQueryLogController.java
View file @
423b1579
This diff is collapsed.
Click to expand it.
src/main/java/cn/quantgroup/xyqb/controller/internal/user/InnerController.java
View file @
423b1579
This diff is collapsed.
Click to expand it.
src/main/java/cn/quantgroup/xyqb/controller/internal/user/SyncUserController.java
View file @
423b1579
package
cn
.
quantgroup
.
xyqb
.
controller
.
internal
.
user
;
import
cn.quantgroup.xyqb.aspect.accessable.IpValidator
;
import
cn.quantgroup.xyqb.constant.UserConstant
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
Detail
;
import
cn.quantgroup.xyqb.entity.User
InfoEntity
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.model.UserModel
;
import
cn.quantgroup.xyqb.
service.user.IUserDetailService
;
import
cn.quantgroup.xyqb.
repository.IUserInfoRepository
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
cn.quantgroup.xyqb.validator.ChineseName
;
...
...
@@ -33,13 +34,15 @@ public class SyncUserController {
private
static
final
String
KEY
=
"abc1234"
;
@Autowired
private
IUserService
userService
;
@Autowired
private
IUser
DetailService
userDetailService
;
private
IUser
InfoRepository
userInfoRepository
;
@RequestMapping
(
"/save_detail"
)
public
JsonResult
saveUserDetail
(
String
key
,
String
phoneNo
,
String
idNo
,
@ChineseName
@RequestParam
String
name
)
{
public
JsonResult
saveUserDetail
(
String
key
,
String
phoneNo
,
@ChineseName
@RequestParam
String
name
,
@RequestParam
(
value
=
"tenantId"
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
)
{
if
(!
Objects
.
equals
(
KEY
,
key
))
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
...
...
@@ -58,17 +61,17 @@ public class SyncUserController {
return
JsonResult
.
buildErrorStateResult
(
"用户不存在"
,
phoneNo
);
}
/* 保存或更新 */
User
Detail
userDetail
=
userDetailService
.
findByUserId
(
user
.
getId
()
);
User
InfoEntity
userDetail
=
userInfoRepository
.
findByUserIdAndTenantId
(
user
.
getId
(),
tenantId
);
if
(
Objects
.
isNull
(
userDetail
))
{
userDetail
=
new
User
Detail
();
userDetail
=
new
User
InfoEntity
();
}
userDetail
.
setUserId
(
user
.
getId
());
userDetail
.
setPhoneNo
(
phoneNo
);
userDetail
.
setName
(
name
);
userDetail
.
set
IsAuthenticated
(
false
);
userDetail
.
set
TenantId
(
tenantId
);
log
.
info
(
"SyncUserController saveUserDetail, userId:{}, phoneNo:{}, name:{}"
,
user
.
getId
(),
phoneNo
,
name
);
try
{
user
DetailService
.
saveUserDetail
(
userDetail
);
user
InfoRepository
.
save
(
userDetail
);
}
catch
(
DataIntegrityViolationException
ex
)
{
return
JsonResult
.
buildSuccessResult
(
""
,
null
);
}
...
...
@@ -76,18 +79,19 @@ public class SyncUserController {
/*
* 如果已存在记录,则更新
*/
User
Detail
theUserDetail
=
userDetailService
.
findByUserId
(
user
.
getId
()
);
User
InfoEntity
theUserDetail
=
userInfoRepository
.
findByUserIdAndTenantId
(
user
.
getId
(),
tenantId
);
if
(
Objects
.
isNull
(
theUserDetail
))
{
userDetail
.
setId
(
null
);
}
else
{
userDetail
.
setId
(
theUserDetail
.
getId
());
}
user
DetailService
.
saveUserDetail
(
userDetail
);
user
InfoRepository
.
save
(
userDetail
);
return
JsonResult
.
buildSuccessResult
(
null
,
null
);
}
@RequestMapping
(
"/user"
)
public
JsonResult
fetchUser
(
String
key
,
String
phoneNo
)
{
public
JsonResult
fetchUser
(
String
key
,
String
phoneNo
,
@RequestParam
(
value
=
"tenantId"
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
)
{
if
(!
Objects
.
equals
(
KEY
,
key
)
||
!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
...
...
@@ -95,13 +99,13 @@ public class SyncUserController {
if
(
Objects
.
isNull
(
user
))
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
User
Detail
detail
=
userDetailService
.
findByUserId
(
user
.
getId
()
);
User
InfoEntity
detail
=
userInfoRepository
.
findByUserIdAndTenantId
(
user
.
getId
(),
tenantId
);
UserModel
userModel
=
new
UserModel
(
user
,
detail
);
return
JsonResult
.
buildSuccessResult
(
null
,
userModel
);
}
@RequestMapping
(
"/user_uuid"
)
public
JsonResult
fetchUserByUuid
(
String
key
,
String
uuid
)
{
public
JsonResult
fetchUserByUuid
(
String
key
,
String
uuid
,
@RequestParam
(
value
=
"tenantId"
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
)
{
if
(
StringUtils
.
isEmpty
(
key
)
||
!
KEY
.
equals
(
key
))
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
...
...
@@ -112,7 +116,7 @@ public class SyncUserController {
if
(
null
==
user
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
User
Detail
detail
=
userDetailService
.
findByUserId
(
user
.
getId
()
);
User
InfoEntity
detail
=
userInfoRepository
.
findByUserIdAndTenantId
(
user
.
getId
(),
tenantId
);
UserModel
userModel
=
new
UserModel
(
user
,
detail
);
return
JsonResult
.
buildSuccessResult
(
null
,
userModel
);
}
...
...
@@ -124,14 +128,14 @@ public class SyncUserController {
*/
@IpValidator
@RequestMapping
(
"/listByUserIds"
)
public
JsonResult
listByUserIds
(
String
userIds
)
{
public
JsonResult
listByUserIds
(
String
userIds
,
@RequestParam
(
value
=
"tenantId"
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
)
{
// 过滤掉合法的多个数值串间的空白值
userIds
=
ValidationUtil
.
filterNumbers
(
userIds
);
if
(!
ValidationUtil
.
validateNumbers
(
userIds
))
{
return
JsonResult
.
buildErrorStateResult
(
"参数不正确"
,
null
);
}
List
<
Long
>
userIdList
=
Arrays
.
asList
(
userIds
.
split
(
",|;"
)).
stream
().
map
(
userId
->
Long
.
valueOf
(
userId
)).
collect
(
Collectors
.
toList
());
List
<
User
Detail
>
userDetailList
=
userDetailService
.
findByUserIdIn
(
userIdList
);
List
<
User
InfoEntity
>
userDetailList
=
userInfoRepository
.
findByTenantIdAndUserIdIn
(
tenantId
,
userIdList
);
return
JsonResult
.
buildSuccessResult
(
null
,
userDetailList
);
}
}
src/main/java/cn/quantgroup/xyqb/controller/internal/user/center/UserCenterController.java
View file @
423b1579
package
cn
.
quantgroup
.
xyqb
.
controller
.
internal
.
user
.
center
;
import
cn.quantgroup.xyqb.constant.enums.EducationEnum
;
import
cn.quantgroup.xyqb.constant.enums.IncomeRangeEnum
;
import
cn.quantgroup.xyqb.constant.enums.MaritalStatus
;
import
cn.quantgroup.xyqb.constant.enums.OccupationEnum
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.aspect.forbidden.AccessForbiddenValidator
;
import
cn.quantgroup.xyqb.aspect.limit.PasswordFreeAccessValidator
;
import
cn.quantgroup.xyqb.
aspect.lock.RedisLock
;
import
cn.quantgroup.xyqb.
constant.UserConstant
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.UserAttached
;
import
cn.quantgroup.xyqb.entity.User
Detail
;
import
cn.quantgroup.xyqb.entity.User
InfoEntity
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.
service.user.IUserDetailService
;
import
cn.quantgroup.xyqb.
repository.IUserInfoRepository
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.service.user.UserCenterService
;
import
cn.quantgroup.xyqb.util.TenantUtil
;
...
...
@@ -38,7 +34,7 @@ public class UserCenterController {
@Autowired
private
UserCenterService
userCenterService
;
@Autowired
private
IUser
DetailService
userDetailService
;
private
IUser
InfoRepository
userInfoRepository
;
@Autowired
private
IUserService
userService
;
...
...
@@ -185,7 +181,7 @@ public class UserCenterController {
* @return
*/
@RequestMapping
(
"/query/verified"
)
public
JsonResult
queryVerified
(
String
phoneNo
)
{
public
JsonResult
queryVerified
(
String
phoneNo
,
@RequestParam
(
value
=
"tenantId"
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
)
{
if
(
StringUtils
.
isEmpty
(
phoneNo
))
{
log
.
error
(
"手机号为空,phoneNo:{}"
,
phoneNo
);
return
JsonResult
.
buildErrorStateResult
(
"参数不合法"
,
null
);
...
...
@@ -194,7 +190,7 @@ public class UserCenterController {
if
(
null
==
userId
||
userId
==
0L
)
{
return
JsonResult
.
buildErrorStateResult
(
"该用户不存在"
,
null
);
}
User
Detail
userDetail
=
userDetailService
.
findByUserId
(
user
Id
);
User
InfoEntity
userDetail
=
userInfoRepository
.
findByUserIdAndTenantId
(
userId
,
tenant
Id
);
if
(
null
!=
userDetail
)
{
return
JsonResult
.
buildSuccessResult
(
null
,
userDetail
);
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/middleoffice/userdetail/UserDetailController.java
View file @
423b1579
package
cn
.
quantgroup
.
xyqb
.
controller
.
middleoffice
.
userdetail
;
import
cn.quantgroup.xyqb.constant.UserConstant
;
import
cn.quantgroup.xyqb.controller.middleoffice.userdetail.req.UserDetailReq
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
Detail
;
import
cn.quantgroup.xyqb.entity.User
InfoEntity
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.
service.user.IUserDetailService
;
import
cn.quantgroup.xyqb.
repository.IUserInfoRepository
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -21,7 +22,7 @@ import javax.validation.Valid;
public
class
UserDetailController
{
@Resource
private
IUser
DetailService
userDetailService
;
private
IUser
InfoRepository
userInfoRepository
;
@Resource
private
IUserService
userService
;
...
...
@@ -36,14 +37,14 @@ public class UserDetailController {
*/
@PutMapping
(
"/{userId}"
)
public
JsonResult
update
(
@PathVariable
Long
userId
,
@Valid
@RequestBody
UserDetailReq
userDetailReq
)
{
User
Detail
userDetail
=
userDetailService
.
findByUserId
(
user
Id
);
@Valid
@RequestBody
UserDetailReq
userDetailReq
,
@RequestParam
(
value
=
"tenantId"
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
)
{
User
InfoEntity
userDetail
=
userInfoRepository
.
findByUserIdAndTenantId
(
userId
,
tenant
Id
);
if
(
userDetail
==
null
)
{
return
save
(
userId
,
userDetailReq
);
return
save
(
userId
,
userDetailReq
,
tenantId
);
}
//更新
userDetail
.
setName
(
userDetailReq
.
getName
());
userDetail
=
user
DetailService
.
saveUserDetail
(
userDetail
);
userDetail
=
user
InfoRepository
.
save
(
userDetail
);
log
.
info
(
"UserDetailController update, userId:{}, name:{}"
,
userId
,
userDetailReq
.
getName
());
return
JsonResult
.
buildSuccessResultGeneric
(
userDetail
);
}
...
...
@@ -57,19 +58,19 @@ public class UserDetailController {
*/
@PostMapping
(
"/{userId}"
)
public
JsonResult
save
(
@PathVariable
Long
userId
,
@Valid
@RequestBody
UserDetailReq
userDetailReq
)
{
User
Detail
userDetail
=
userDetailService
.
findByUserId
(
user
Id
);
@Valid
@RequestBody
UserDetailReq
userDetailReq
,
@RequestParam
(
value
=
"tenantId"
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
)
{
User
InfoEntity
userDetail
=
userInfoRepository
.
findByUserIdAndTenantId
(
userId
,
tenant
Id
);
if
(
userDetail
!=
null
)
{
return
JsonResult
.
buildSuccessResultGeneric
(
userDetail
);
}
User
user
=
userService
.
findById
(
userId
);
userDetail
=
new
User
Detail
();
userDetail
=
new
User
InfoEntity
();
userDetail
.
setUserId
(
userId
);
userDetail
.
setName
(
userDetailReq
.
getName
());
userDetail
.
setPhoneNo
(
user
.
getPhoneNo
());
userDetail
.
setGender
(
userDetail
.
getGender
());
userDetail
=
user
DetailService
.
saveUserDetail
(
userDetail
);
userDetail
=
user
InfoRepository
.
save
(
userDetail
);
log
.
info
(
"UserDetailController save, userId:{}, phoneNo:{}, name:{}"
,
user
.
getId
(),
user
.
getPhoneNo
(),
userDetailReq
.
getName
());
return
JsonResult
.
buildSuccessResultGeneric
(
userDetail
);
}
...
...
@@ -81,8 +82,8 @@ public class UserDetailController {
* @return
*/
@GetMapping
(
"/userId/{userId}"
)
public
JsonResult
query
(
@PathVariable
Long
userId
)
{
User
Detail
userDetail
=
userDetailService
.
findByUserId
(
user
Id
);
public
JsonResult
query
(
@PathVariable
Long
userId
,
@RequestParam
(
value
=
"tenantId"
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
)
{
User
InfoEntity
userDetail
=
userInfoRepository
.
findByUserIdAndTenantId
(
userId
,
tenant
Id
);
return
JsonResult
.
buildSuccessResultGeneric
(
userDetail
);
}
...
...
@@ -93,8 +94,8 @@ public class UserDetailController {
* @return
*/
@GetMapping
(
"/phoneNo/{phoneNo}"
)
public
JsonResult
query
(
@PathVariable
String
phoneNo
)
{
User
Detail
userDetail
=
userDetailService
.
findByPhoneNo
(
phoneNo
);
public
JsonResult
query
(
@PathVariable
String
phoneNo
,
@RequestParam
(
value
=
"tenantId"
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
)
{
User
InfoEntity
userDetail
=
userInfoRepository
.
findByPhoneNoAndTenantId
(
phoneNo
,
tenantId
);
return
JsonResult
.
buildSuccessResultGeneric
(
userDetail
);
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/middleoffice/userext/UserExtController.java
View file @
423b1579
package
cn
.
quantgroup
.
xyqb
.
controller
.
middleoffice
.
userext
;
import
cn.quantgroup.xyqb.constant.
enums.OccupationEnum
;
import
cn.quantgroup.xyqb.constant.
UserConstant
;
import
cn.quantgroup.xyqb.controller.middleoffice.userext.req.UserExtReq
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.
service.user.IUserDetailService
;
import
cn.quantgroup.xyqb.
repository.IUserInfoRepository
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 用户扩展信息
...
...
@@ -21,7 +18,7 @@ import java.util.Map;
public
class
UserExtController
{
@Resource
private
IUser
DetailService
userDetailService
;
private
IUser
InfoRepository
userInfoRepository
;
@Resource
...
...
@@ -32,12 +29,12 @@ public class UserExtController {
//todo 保存失败的各种场景。
@PutMapping
(
"/{userId}"
)
public
JsonResult
ext
(
@PathVariable
Long
userId
,
@RequestBody
UserExtReq
userExtReq
)
{
public
JsonResult
ext
(
@PathVariable
Long
userId
,
@RequestBody
UserExtReq
userExtReq
,
@RequestParam
(
value
=
"tenantId"
,
defaultValue
=
UserConstant
.
defaultTenantIdString
)
Integer
tenantId
)
{
if
(
userExtReq
.
getEmail
()
!=
null
)
{
user
DetailService
.
updateUserEmail
(
userId
,
userExtReq
.
getEmail
()
);
user
InfoRepository
.
updateUserEmail
(
userExtReq
.
getEmail
(),
userId
,
tenantId
);
}
if
(
userExtReq
.
getQq
()
!=
null
)
{
user
DetailService
.
updateUserQq
(
userId
,
userExtReq
.
getQq
()
);
user
InfoRepository
.
updateUserQq
(
userExtReq
.
getQq
(),
userId
,
tenantId
);
}
return
JsonResult
.
buildSuccessResult
();
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/modifyphoneno/resp/ModifyPhoneNoResp.java
View file @
423b1579
...
...
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import
lombok.Data
;
import
java.sql.Timestamp
;
import
java.time.LocalDateTime
;
import
java.util.Optional
;
/**
...
...
@@ -22,10 +23,10 @@ public class ModifyPhoneNoResp {
private
Long
id
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Timestamp
createdAt
;
private
LocalDateTime
createdAt
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Timestamp
updatedAt
;
private
LocalDateTime
updatedAt
;
/**
* user.id
...
...
src/main/java/cn/quantgroup/xyqb/controller/modifyphoneno/resp/UserModifyPhoneRecordResp.java
View file @
423b1579
...
...
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import
lombok.Data
;
import
java.sql.Timestamp
;
import
java.time.LocalDateTime
;
@Data
public
class
UserModifyPhoneRecordResp
{
...
...
@@ -25,13 +26,13 @@ public class UserModifyPhoneRecordResp {
private
String
financialResponse
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Timestamp
createdAt
;
private
LocalDateTime
createdAt
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Timestamp
updatedAt
;
private
LocalDateTime
updatedAt
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
Timestamp
operationAt
;
private
LocalDateTime
operationAt
;
private
ApplySource
applySource
;
...
...
src/main/java/cn/quantgroup/xyqb/entity/BaseEntity.java
View file @
423b1579
...
...
@@ -5,6 +5,8 @@ import lombok.Data;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
/**
* 所有数据库实体,都要继承 BaseEntity
...
...
@@ -21,22 +23,21 @@ public abstract class BaseEntity implements Serializable {
@Basic
(
optional
=
false
)
private
Long
id
;
@Column
(
name
=
"created_at"
)
private
Timestamp
createdAt
;
@Column
(
name
=
"created_at"
,
columnDefinition
=
"TIMESTAMP"
)
private
LocalDateTime
createdAt
;
@Column
(
name
=
"updated_at"
)
private
Timestamp
updatedAt
;
@Column
(
name
=
"updated_at"
,
columnDefinition
=
"TIMESTAMP"
)
private
LocalDateTime
updatedAt
;
@PrePersist
public
void
prePersist
()
{
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
this
.
createdAt
=
now
;
this
.
updatedAt
=
now
;
this
.
createdAt
=
LocalDateTime
.
now
();
this
.
updatedAt
=
LocalDateTime
.
now
();
}
@PreUpdate
public
void
preUpdate
()
{
this
.
updatedAt
=
new
Timestamp
(
System
.
currentTimeMillis
()
);
this
.
updatedAt
=
LocalDateTime
.
now
(
);
}
}
src/main/java/cn/quantgroup/xyqb/entity/User.java
View file @
423b1579
...
...
@@ -48,6 +48,9 @@ public class User extends BaseEntity implements Serializable {
@Column
(
name
=
"cipher_password"
)
private
String
cipherPassword
;
@Column
(
name
=
"tenant_id"
)
private
Integer
tenantId
;
public
String
getEncryptedPhoneNo
()
{
return
StringUtils
.
isBlank
(
encryptedPhoneNo
)
?
phoneNo
:
encryptedPhoneNo
;
}
...
...
src/main/java/cn/quantgroup/xyqb/entity/User
Detail
.java
→
src/main/java/cn/quantgroup/xyqb/entity/User
InfoEntity
.java
View file @
423b1579
package
cn
.
quantgroup
.
xyqb
.
entity
;
import
cn.quantgroup.xyqb.model.Gender
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
javax.persistence.UniqueConstraint
;
import
java.io.Serializable
;
import
java.time.LocalDate
;
/**
* Created by FrankChow on 15/7/8.
*/
@Getter
@Setter
@ToString
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
@Entity
@Table
(
name
=
"user_detail"
,
uniqueConstraints
=
@UniqueConstraint
(
columnNames
=
"user_id"
))
public
class
UserDetail
extends
BaseEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
1L
;
@Table
(
name
=
"user_detail"
)
public
class
UserInfoEntity
extends
BaseEntity
implements
Serializable
{
@Column
(
name
=
"user_id"
)
private
Long
userId
;
@Column
(
name
=
"phone_no"
)
private
String
phoneNo
;
@Column
(
name
=
"name"
)
private
String
name
;
//身份证验真 0 未认证 1认证
@Column
(
name
=
"is_authenticated"
)
private
Boolean
isAuthenticated
=
false
;
//0 未知 1 女 2 男
@Column
(
name
=
"gender"
)
private
Gender
gender
;
...
...
@@ -46,4 +30,21 @@ public class UserDetail extends BaseEntity implements Serializable {
@Column
(
name
=
"qq"
)
private
String
qq
;
@Column
(
name
=
"name"
)
private
String
name
;
@Column
(
name
=
"photo"
)
private
String
photo
;
@Column
(
name
=
"birthday"
)
private
LocalDate
birthday
;
@Column
(
name
=
"province_id"
)
private
Integer
provinceId
;
@Column
(
name
=
"city_id"
)
private
Integer
cityId
;
@Column
(
name
=
"address"
)
private
String
address
;
@Column
(
name
=
"tenant_id"
)
private
Integer
tenantId
;
}
src/main/java/cn/quantgroup/xyqb/entity/converter/LocalDateAttributeConverter.java
0 → 100644
View file @
423b1579
package
cn
.
quantgroup
.
xyqb
.
entity
.
converter
;
import
javax.persistence.AttributeConverter
;
import
javax.persistence.Converter
;
import
java.sql.Date
;
import
java.time.LocalDate
;
@Converter
(
autoApply
=
true
)
public
class
LocalDateAttributeConverter
implements
AttributeConverter
<
LocalDate
,
Date
>
{
@Override
public
Date
convertToDatabaseColumn
(
LocalDate
attribute
)
{
return
attribute
==
null
?
null
:
Date
.
valueOf
(
attribute
);
}
@Override
public
LocalDate
convertToEntityAttribute
(
Date
dbData
)
{
return
dbData
==
null
?
null
:
dbData
.
toLocalDate
();
}
}
src/main/java/cn/quantgroup/xyqb/entity/converter/LocalDateTimeAttributeConverter.java
0 → 100644
View file @
423b1579
package
cn
.
quantgroup
.
xyqb
.
entity
.
converter
;
import
javax.persistence.AttributeConverter
;
import
javax.persistence.Converter
;
import
java.sql.Timestamp
;
import
java.time.LocalDateTime
;
@Converter
(
autoApply
=
true
)
public
class
LocalDateTimeAttributeConverter
implements
AttributeConverter
<
LocalDateTime
,
Timestamp
>
{
@Override
public
Timestamp
convertToDatabaseColumn
(
LocalDateTime
attribute
)
{
return
attribute
==
null
?
null
:
Timestamp
.
valueOf
(
attribute
);
}
@Override
public
LocalDateTime
convertToEntityAttribute
(
Timestamp
dbData
)
{
return
dbData
==
null
?
null
:
dbData
.
toLocalDateTime
();
}
}
src/main/java/cn/quantgroup/xyqb/event/DetailRegisteredEventListener.java
View file @
423b1579
package
cn
.
quantgroup
.
xyqb
.
event
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
Detail
;
import
cn.quantgroup.xyqb.entity.User
InfoEntity
;
import
cn.quantgroup.xyqb.model.UserRegisterParam
;
import
cn.quantgroup.xyqb.
service.user.IUserDetailService
;
import
cn.quantgroup.xyqb.
repository.IUserInfoRepository
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -15,10 +15,8 @@ import javax.annotation.Resource;
@Slf4j
@Component
public
class
DetailRegisteredEventListener
implements
ApplicationListener
<
RegisterEvent
>
{
@Resource
private
IUser
DetailService
userDetailService
;
private
IUser
InfoRepository
userInfoRepository
;
@Override
public
void
onApplicationEvent
(
RegisterEvent
event
)
{
...
...
@@ -31,11 +29,11 @@ public class DetailRegisteredEventListener implements ApplicationListener<Regist
}
String
phoneNo
=
userRegisterParam
.
getPhoneNo
();
String
name
=
userRegisterParam
.
getName
();
User
Detail
userDetail
=
new
UserDetail
();
User
InfoEntity
userDetail
=
new
UserInfoEntity
();
userDetail
.
setPhoneNo
(
phoneNo
);
userDetail
.
setName
(
name
);
userDetail
.
setUserId
(
user
.
getId
());
log
.
info
(
"DetailRegisteredEventListener saveUserDetail, userId:{}, phoneNo:{}, name:{}"
,
user
.
getId
(),
phoneNo
,
name
);
user
DetailService
.
saveUserDetail
(
userDetail
);
user
InfoRepository
.
save
(
userDetail
);
}
}
src/main/java/cn/quantgroup/xyqb/event/UserDetailUpdateEvent.java
deleted
100644 → 0
View file @
3fca5558
package
cn
.
quantgroup
.
xyqb
.
event
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
lombok.Getter
;
import
org.springframework.context.ApplicationEvent
;
@Getter
public
class
UserDetailUpdateEvent
extends
ApplicationEvent
{
/**
* Create a new ApplicationEvent.
*
* @param source the object on which the event initially occurred (never {@code null})
*/
public
UserDetailUpdateEvent
(
Object
source
)
{
super
(
source
);
}
private
UserDetail
userDetail
;
public
UserDetailUpdateEvent
(
Object
source
,
UserDetail
userDetail
)
{
super
(
source
);
this
.
userDetail
=
userDetail
;
}
}
src/main/java/cn/quantgroup/xyqb/model/UserDisableRecordModel.java
View file @
423b1579
package
cn
.
quantgroup
.
xyqb
.
model
;
import
cn.quantgroup.xyqb.entity.UserDisableRecord
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
import
java.time.
format.DateTimeFormatter
;
import
java.time.
LocalDateTime
;
/**
* 只是为了兼容时间格式化问题,后续用户中心升级后,该model不需要
*/
@Data
public
class
UserDisableRecordModel
{
private
Long
id
;
private
Long
userId
;
private
short
operation_type
;
private
String
reason
;
private
String
createdBy
;
private
String
updatedBy
;
private
String
createdAt
;
private
String
updatedAt
;
public
static
UserDisableRecordModel
from
(
UserDisableRecord
userDisableRecord
){
UserDisableRecordModel
userDisableRecordModel
=
new
UserDisableRecordModel
();
userDisableRecordModel
.
setUserId
(
userDisableRecord
.
getUserId
());
userDisableRecordModel
.
setId
(
userDisableRecord
.
getId
());
userDisableRecordModel
.
setReason
(
userDisableRecord
.
getReason
());
userDisableRecordModel
.
setOperation_type
(
userDisableRecord
.
getOperation_type
());
userDisableRecordModel
.
setCreatedAt
(
userDisableRecord
.
getCreatedAt
().
toLocalDateTime
().
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
)));
userDisableRecordModel
.
setUpdatedAt
(
userDisableRecord
.
getUpdatedAt
().
toLocalDateTime
().
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
)));
userDisableRecordModel
.
setCreatedBy
(
userDisableRecord
.
getCreatedBy
());
userDisableRecordModel
.
setUpdatedBy
(
userDisableRecord
.
getUpdatedBy
());
return
userDisableRecordModel
;
}
public
class
UserDisableRecordModel
{
private
Long
id
;
private
Long
userId
;
private
short
operation_type
;
private
String
reason
;
private
String
createdBy
;
private
String
updatedBy
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
LocalDateTime
createdAt
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
LocalDateTime
updatedAt
;
public
static
UserDisableRecordModel
from
(
UserDisableRecord
userDisableRecord
)
{
UserDisableRecordModel
userDisableRecordModel
=
new
UserDisableRecordModel
();
userDisableRecordModel
.
setUserId
(
userDisableRecord
.
getUserId
());
userDisableRecordModel
.
setId
(
userDisableRecord
.
getId
());
userDisableRecordModel
.
setReason
(
userDisableRecord
.
getReason
());
userDisableRecordModel
.
setOperation_type
(
userDisableRecord
.
getOperation_type
());
userDisableRecordModel
.
setCreatedAt
(
userDisableRecord
.
getCreatedAt
());
userDisableRecordModel
.
setUpdatedAt
(
userDisableRecord
.
getUpdatedAt
());
userDisableRecordModel
.
setCreatedBy
(
userDisableRecord
.
getCreatedBy
());
userDisableRecordModel
.
setUpdatedBy
(
userDisableRecord
.
getUpdatedBy
());
return
userDisableRecordModel
;
}
}
src/main/java/cn/quantgroup/xyqb/model/UserFullInfo.java
View file @
423b1579
package
cn
.
quantgroup
.
xyqb
.
model
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
Detail
;
import
cn.quantgroup.xyqb.entity.User
InfoEntity
;
import
lombok.Data
;
import
java.io.Serializable
;
...
...
@@ -36,7 +36,7 @@ public class UserFullInfo implements Serializable {
public
UserFullInfo
()
{
}
public
UserFullInfo
(
User
user
,
User
Detail
userDetail
)
{
public
UserFullInfo
(
User
user
,
User
InfoEntity
userInfoEntity
)
{
if
(
user
!=
null
)
{
this
.
id
=
user
.
getId
();
this
.
phoneNo
=
user
.
getPhoneNo
();
...
...
@@ -45,9 +45,9 @@ public class UserFullInfo implements Serializable {
this
.
uuid
=
user
.
getUuid
();
this
.
enable
=
user
.
getEnable
();
}
if
(
user
Detail
!=
null
)
{
this
.
name
=
user
Detail
.
getName
();
this
.
gender
=
Optional
.
ofNullable
(
user
Detail
.
getGender
()).
orElse
(
Gender
.
UNKNOWN
).
getName
();
if
(
user
InfoEntity
!=
null
)
{
this
.
name
=
user
InfoEntity
.
getName
();
this
.
gender
=
Optional
.
ofNullable
(
user
InfoEntity
.
getGender
()).
orElse
(
Gender
.
UNKNOWN
).
getName
();
}
}
...
...
src/main/java/cn/quantgroup/xyqb/model/UserInfo.java
View file @
423b1579
package
cn
.
quantgroup
.
xyqb
.
model
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
Detail
;
import
cn.quantgroup.xyqb.entity.User
InfoEntity
;
import
lombok.Data
;
import
org.springframework.util.Assert
;
...
...
@@ -25,14 +25,14 @@ public class UserInfo implements Serializable {
private
String
uuid
;
private
String
IdNo
;
public
UserInfo
(
User
user
,
User
Detail
userDetail
)
{
public
UserInfo
(
User
user
,
User
InfoEntity
userInfoEntity
)
{
Assert
.
notNull
(
user
,
"User信息无效"
);
this
.
id
=
user
.
getId
();
this
.
phoneNo
=
user
.
getPhoneNo
();
this
.
registerFrom
=
user
.
getRegisteredFrom
();
this
.
uuid
=
user
.
getUuid
();
if
(
user
Detail
!=
null
)
{
this
.
name
=
user
Detail
.
getName
();
if
(
user
InfoEntity
!=
null
)
{
this
.
name
=
user
InfoEntity
.
getName
();
}
}
}
src/main/java/cn/quantgroup/xyqb/model/User
Detail
Ret.java
→
src/main/java/cn/quantgroup/xyqb/model/User
Info
Ret.java
View file @
423b1579
package
cn
.
quantgroup
.
xyqb
.
model
;
import
cn.quantgroup.xyqb.entity.User
Detail
;
import
cn.quantgroup.xyqb.entity.User
InfoEntity
;
import
lombok.Data
;
import
org.apache.commons.lang.StringUtils
;
import
java.io.Serializable
;
import
java.time.LocalDate
;
import
java.time.ZoneOffset
;
/**
* Created by 11 on 2016/12/20.
*/
@Data
public
class
User
Detail
Ret
implements
Serializable
{
public
class
User
Info
Ret
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
1L
;
private
Long
id
;
private
Long
userId
;
private
String
phoneNo
;
private
String
name
;
private
String
n
ickN
ame
;
//证件号
private
String
idNo
;
//0 身份证 1 军官证 2 护照
private
IdType
idType
;
//身份证验真 0 未认证 1认证
private
Boolean
isAuthenticated
=
false
;
//0 未知 1 女 2 男
private
Gender
gender
;
...
...
@@ -36,7 +31,13 @@ public class UserDetailRet implements Serializable {
private
String
email
;
private
String
qq
;
private
String
address
;
private
Integer
provinceId
;
private
Integer
cityId
;
private
LocalDate
birthday
;
private
String
photo
;
private
Integer
tenantId
;
//创建时间
private
Long
createdAt
;
...
...
@@ -45,22 +46,26 @@ public class UserDetailRet implements Serializable {
/**
* 转换时间从timestamp到long
*
* @param userDetail
* @return return self
* @param userInfoEntity UserInfoEntity
* @return UserInfoRet
*/
public
static
UserDetailRet
getUserDetail
(
UserDetail
userDetail
)
{
long
createTimeStamp
=
userDetail
.
getCreatedAt
().
getTime
();
long
updateTimeStamp
=
userDetail
.
getUpdatedAt
().
getTime
();
UserDetailRet
userDetailRet
=
new
UserDetailRet
();
userDetailRet
.
setId
(
userDetail
.
getId
());
userDetailRet
.
setName
(
userDetail
.
getName
());
userDetailRet
.
setPhoneNo
(
userDetail
.
getPhoneNo
());
userDetailRet
.
setEmail
(
StringUtils
.
defaultIfEmpty
(
userDetail
.
getEmail
(),
""
));
userDetailRet
.
setGender
(
userDetail
.
getGender
());
userDetailRet
.
setIsAuthenticated
(
userDetail
.
getIsAuthenticated
());
userDetailRet
.
setQq
(
StringUtils
.
defaultIfEmpty
(
userDetail
.
getQq
(),
""
));
userDetailRet
.
setUserId
(
userDetail
.
getUserId
());
public
static
UserInfoRet
getUserDetail
(
UserInfoEntity
userInfoEntity
)
{
long
createTimeStamp
=
userInfoEntity
.
getCreatedAt
().
toInstant
(
ZoneOffset
.
UTC
).
toEpochMilli
();
long
updateTimeStamp
=
userInfoEntity
.
getUpdatedAt
().
toInstant
(
ZoneOffset
.
UTC
).
toEpochMilli
();
UserInfoRet
userDetailRet
=
new
UserInfoRet
();
userDetailRet
.
setId
(
userInfoEntity
.
getId
());
userDetailRet
.
setUserId
(
userInfoEntity
.
getUserId
());
userDetailRet
.
setPhoneNo
(
userInfoEntity
.
getPhoneNo
());
userDetailRet
.
setNickName
(
userInfoEntity
.
getName
());
userDetailRet
.
setGender
(
userInfoEntity
.
getGender
());
userDetailRet
.
setEmail
(
StringUtils
.
defaultIfEmpty
(
userInfoEntity
.
getEmail
(),
""
));
userDetailRet
.
setQq
(
StringUtils
.
defaultIfEmpty
(
userInfoEntity
.
getQq
(),
""
));
userDetailRet
.
setAddress
(
userInfoEntity
.
getAddress
());
userDetailRet
.
setProvinceId
(
userInfoEntity
.
getProvinceId
());
userDetailRet
.
setCityId
(
userDetailRet
.
getCityId
());
userDetailRet
.
setBirthday
(
userDetailRet
.
getBirthday
());
userDetailRet
.
setPhoto
(
userDetailRet
.
getPhoto
());
userDetailRet
.
setTenantId
(
userInfoEntity
.
getTenantId
());
userDetailRet
.
setCreatedAt
(
createTimeStamp
);
userDetailRet
.
setUpdatedAt
(
updateTimeStamp
);
return
userDetailRet
;
...
...
src/main/java/cn/quantgroup/xyqb/model/UserModel.java
View file @
423b1579
package
cn
.
quantgroup
.
xyqb
.
model
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
Detail
;
import
cn.quantgroup.xyqb.entity.User
InfoEntity
;
import
lombok.Data
;
import
org.springframework.util.Assert
;
...
...
@@ -35,7 +35,7 @@ public class UserModel implements Serializable {
public
UserModel
()
{
}
public
UserModel
(
User
user
,
User
Detail
userDetail
)
{
public
UserModel
(
User
user
,
User
InfoEntity
userDetail
)
{
Assert
.
notNull
(
user
,
"User信息无效"
);
this
.
id
=
user
.
getId
();
this
.
phoneNo
=
user
.
getPhoneNo
();
...
...
src/main/java/cn/quantgroup/xyqb/model/UserRegisterMqMessage.java
View file @
423b1579
...
...
@@ -4,6 +4,8 @@ import cn.quantgroup.xyqb.entity.User;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.time.ZoneOffset
;
/**
* Created by xuran on 2017/9/7.
...
...
@@ -33,8 +35,8 @@ public class UserRegisterMqMessage implements Serializable {
private
Long
updatedAt
;
public
UserRegisterMqMessage
(
User
user
)
{
Long
createTimeStamp
=
user
.
getCreatedAt
().
getTime
();
Long
updateTimeStamp
=
user
.
getUpdatedAt
().
getTime
();
Long
createTimeStamp
=
user
.
getCreatedAt
().
toInstant
(
ZoneOffset
.
UTC
).
toEpochMilli
();
Long
updateTimeStamp
=
user
.
getUpdatedAt
().
toInstant
(
ZoneOffset
.
UTC
).
toEpochMilli
();
this
.
setId
(
user
.
getId
());
this
.
setPhoneNo
(
user
.
getPhoneNo
());
this
.
setEnable
(
user
.
getEnable
());
...
...
@@ -42,6 +44,5 @@ public class UserRegisterMqMessage implements Serializable {
this
.
setUuid
(
user
.
getUuid
());
this
.
setCreatedAt
(
createTimeStamp
);
this
.
setUpdatedAt
(
updateTimeStamp
);
}
}
src/main/java/cn/quantgroup/xyqb/model/UserRet.java
View file @
423b1579
...
...
@@ -4,6 +4,7 @@ import cn.quantgroup.xyqb.entity.User;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.time.ZoneOffset
;
import
java.util.Objects
;
/**
...
...
@@ -47,8 +48,8 @@ public class UserRet implements Serializable {
if
(
Objects
.
isNull
(
user
)){
return
;
}
Long
createTimeStamp
=
user
.
getCreatedAt
().
getTime
();
Long
updateTimeStamp
=
user
.
getUpdatedAt
().
getTime
();
Long
createTimeStamp
=
user
.
getCreatedAt
().
toInstant
(
ZoneOffset
.
UTC
).
toEpochMilli
();
Long
updateTimeStamp
=
user
.
getUpdatedAt
().
toInstant
(
ZoneOffset
.
UTC
).
toEpochMilli
();
this
.
setId
(
user
.
getId
());
this
.
setPhoneNo
(
user
.
getPhoneNo
());
this
.
setEnable
(
user
.
getEnable
());
...
...
src/main/java/cn/quantgroup/xyqb/repository/IUserDetailRepository.java
deleted
100644 → 0
View file @
3fca5558
package
cn
.
quantgroup
.
xyqb
.
repository
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
/**
* @author mengfan.feng
* @time 2015-09-11 11:22
*/
public
interface
IUserDetailRepository
extends
JpaRepository
<
UserDetail
,
Long
>,
JpaSpecificationExecutor
<
UserDetail
>
{
UserDetail
findByUserId
(
Long
userId
);
UserDetail
findByPhoneNo
(
String
phone
);
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Modifying
@Query
(
value
=
"update user_detail set qq = ?1 where user_id = ?2"
,
nativeQuery
=
true
)
void
updateUserQq
(
String
qq
,
Long
userId
);
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Modifying
@Query
(
value
=
"update user_detail set email = ?1 where user_id = ?2"
,
nativeQuery
=
true
)
void
updateUserEmail
(
String
email
,
Long
userId
);
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Modifying
@Query
(
value
=
"update user_detail set gender = ?1 where user_id = ?2"
,
nativeQuery
=
true
)
void
updateGender
(
int
gender
,
Long
userId
);
List
<
UserDetail
>
findAll
(
Specification
<
UserDetail
>
specification
);
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Modifying
@Query
(
value
=
"update user_detail set name=?1,gender=?2 where phone_no=?3"
,
nativeQuery
=
true
)
int
updateNameAndIdNoByPhoneNo
(
String
name
,
int
gender
,
String
phoneNo
);
/**
* 按照身份证号和手机号 - 模糊查询
*
* @param phoneNo - 手机号
* @return List<UserDetail>
*/
@Query
(
value
=
"select * from user_detail where phone_no like ?1"
,
nativeQuery
=
true
)
List
<
UserDetail
>
fuzzyQueryByPhoneNo
(
String
phoneNo
);
List
<
UserDetail
>
findTop20ByPhoneNoStartingWith
(
String
phoneNo
);
UserDetail
findByUserIdAndPhoneNoAndName
(
Long
userId
,
String
phoneNo
,
String
name
);
}
src/main/java/cn/quantgroup/xyqb/repository/IUserInfoRepository.java
0 → 100644
View file @
423b1579
package
cn
.
quantgroup
.
xyqb
.
repository
;
import
cn.quantgroup.xyqb.entity.UserInfoEntity
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
public
interface
IUserInfoRepository
extends
JpaRepository
<
UserInfoEntity
,
Long
>
{
UserInfoEntity
findByUserIdAndTenantId
(
Long
userId
,
Integer
tenantId
);
UserInfoEntity
findByPhoneNoAndTenantId
(
String
phoneNo
,
Integer
tenantId
);
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Modifying
@Query
(
value
=
"update user_info set qq = ?1 where user_id = ?2 and tenant_id = ?3"
,
nativeQuery
=
true
)
void
updateUserQq
(
String
qq
,
Long
userId
,
Integer
tenantId
);
List
<
UserInfoEntity
>
findByTenantIdAndPhoneNoIn
(
Integer
tenantId
,
List
<
String
>
phoneNos
);
List
<
UserInfoEntity
>
findByTenantIdAndUserIdIn
(
Integer
tenantId
,
List
<
Long
>
userIds
);
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Modifying
@Query
(
value
=
"update user_info set email = ?1 where user_id = ?2 and tenant_id = ?3"
,
nativeQuery
=
true
)
void
updateUserEmail
(
String
email
,
Long
userId
,
Integer
tenantId
);
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Modifying
@Query
(
value
=
"update user_info set gender = ?1 where user_id = ?2 and tenant_id = ?3"
,
nativeQuery
=
true
)
void
updateGender
(
int
gender
,
Long
userId
,
Integer
tenantId
);
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Modifying
@Query
(
value
=
"update user_info set name=?1,gender=?2 where phone_no=?3 and tenant_id = ?4"
,
nativeQuery
=
true
)
int
updateNameAndGenderByPhoneNo
(
String
name
,
int
gender
,
String
phoneNo
,
Integer
tenantId
);
}
src/main/java/cn/quantgroup/xyqb/service/api/impl/UserApiServiceImpl.java
View file @
423b1579
package
cn
.
quantgroup
.
xyqb
.
service
.
api
.
impl
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
Detail
;
import
cn.quantgroup.xyqb.entity.User
InfoEntity
;
import
cn.quantgroup.xyqb.model.UserFullInfo
;
import
cn.quantgroup.xyqb.model.UserInfoRet
;
import
cn.quantgroup.xyqb.repository.IUserInfoRepository
;
import
cn.quantgroup.xyqb.service.api.IUserApiService
;
import
cn.quantgroup.xyqb.service.user.IUserDetailService
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -20,7 +21,7 @@ public class UserApiServiceImpl implements IUserApiService {
@Autowired
private
IUserService
userService
;
@Autowired
private
IUser
DetailService
userDetailService
;
private
IUser
InfoRepository
userInfoRepository
;
@Override
public
Optional
<
UserFullInfo
>
getUserFullInfoByUuid
(
String
uuid
)
{
...
...
@@ -28,7 +29,7 @@ public class UserApiServiceImpl implements IUserApiService {
if
(
null
==
user
)
{
return
Optional
.
empty
();
}
User
Detail
detail
=
userDetailService
.
findByUserId
(
user
.
ge
tId
());
User
InfoEntity
detail
=
userInfoRepository
.
findByUserIdAndTenantId
(
user
.
getId
(),
user
.
getTenan
tId
());
UserFullInfo
userFullInfo
=
new
UserFullInfo
(
user
,
detail
);
return
Optional
.
of
(
userFullInfo
);
}
...
...
@@ -39,7 +40,7 @@ public class UserApiServiceImpl implements IUserApiService {
if
(
null
==
user
)
{
return
Optional
.
empty
();
}
User
Detail
detail
=
userDetailService
.
findByUserId
(
user
.
ge
tId
());
User
InfoEntity
detail
=
userInfoRepository
.
findByUserIdAndTenantId
(
user
.
getId
(),
user
.
getTenan
tId
());
UserFullInfo
userFullInfo
=
new
UserFullInfo
(
user
,
detail
);
return
Optional
.
of
(
userFullInfo
);
}
...
...
src/main/java/cn/quantgroup/xyqb/service/page/impl/PageServiceImpl.java
View file @
423b1579
package
cn
.
quantgroup
.
xyqb
.
service
.
page
.
impl
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
Detail
;
import
cn.quantgroup.xyqb.entity.User
InfoEntity
;
import
cn.quantgroup.xyqb.model.Tuple
;
import
cn.quantgroup.xyqb.repository.IUserInfoRepository
;
import
cn.quantgroup.xyqb.service.page.IPageService
;
import
cn.quantgroup.xyqb.service.page.bean.BasePageType
;
import
cn.quantgroup.xyqb.service.user.IUserDetailService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -21,11 +21,12 @@ public class PageServiceImpl implements IPageService {
private
Map
<
String
,
BasePageType
[]>
routerDefinetion
;
@Autowired
private
IUserDetailService
userDetailService
;
private
IUserInfoRepository
userInfoRepository
;
private
BasePageType
pageIdNo
=
new
BasePageType
(
"name"
,
false
)
{
@Override
public
boolean
canPass
(
User
user
)
{
User
Detail
userDetail
=
userDetailService
.
findByUserId
(
user
.
ge
tId
());
User
InfoEntity
userDetail
=
userInfoRepository
.
findByUserIdAndTenantId
(
user
.
getId
(),
user
.
getTenan
tId
());
return
userDetail
!=
null
;
}
};
...
...
src/main/java/cn/quantgroup/xyqb/service/user/IUserDetailService.java
deleted
100644 → 0
View file @
3fca5558
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.service.user.vo.UserDetailVO
;
import
org.springframework.dao.DataIntegrityViolationException
;
import
org.springframework.data.domain.Page
;
import
java.util.List
;
/**
* Created by 11 on 2016/12/29.
*/
public
interface
IUserDetailService
{
UserDetail
findByUserId
(
Long
userId
);
UserDetail
findSlaveByUserId
(
Long
userId
);
UserDetail
saveUserDetail
(
UserDetail
userDetail
)
throws
DataIntegrityViolationException
;
UserDetail
findByPhoneNo
(
String
phoneNo
);
UserDetail
findSlaveByPhoneNo
(
String
phoneNo
);
void
updateUserQq
(
Long
userId
,
String
qq
);
void
updateUserEmail
(
Long
userId
,
String
email
);
List
<
UserDetailVO
>
searchUserDetailList
(
String
name
,
String
phoneNo
,
String
idNo
);
List
<
UserDetail
>
findByUserIdIn
(
List
<
Long
>
userIds
);
List
<
UserDetail
>
findByPhoneNos
(
List
<
String
>
phoneNos
);
List
<
UserDetail
>
findByPhoneNoStartingWith
(
String
phoneNo
);
Page
<
UserDetail
>
getUserDetailsPage
(
List
<
Long
>
userId
,
List
<
String
>
phoneNos
,
List
<
String
>
idNos
,
int
pageNumber
,
int
pageSize
,
String
sortType
);
/**
* 更新用户的身份证号
*
* @param name name
* @param phoneNo phoneNo
* @return 受影响的行数
*/
int
updateName
(
String
name
,
String
phoneNo
);
List
<
UserDetail
>
findByPhones
(
List
<
String
>
phoneNos
);
/**
* 按照身份证号和手机号 - 模糊查询
* @param phoneNo - 手机号
* @return List<UserDetail>
*/
List
<
UserDetail
>
fuzzyQueryByPhoneNo
(
String
phoneNo
);
}
src/main/java/cn/quantgroup/xyqb/service/user/IUserService.java
View file @
423b1579
...
...
@@ -56,7 +56,7 @@ public interface IUserService {
*/
int
forbiddenUser
(
Boolean
enable
,
String
phoneNo
);
List
<
UserInfo
>
findUserInfosByPhones
(
List
<
String
>
phones
);
List
<
UserInfo
>
findUserInfosByPhones
(
List
<
String
>
phones
,
Integer
tenantId
);
/**
* 修改手机号码.
...
...
@@ -65,7 +65,7 @@ public interface IUserService {
* @param newPhoneNo 新手机号
* @return 返回用户信息
*/
User
modifyPhoneNo
(
String
oldPhoneNo
,
String
newPhoneNo
);
User
modifyPhoneNo
(
String
oldPhoneNo
,
String
newPhoneNo
,
Integer
tenantId
);
/**
* 删除这个用户相关缓存
...
...
@@ -85,7 +85,7 @@ public interface IUserService {
* @param userId 用户id
* @return
*/
UserFullResp
findUserFullSearchByUserId
(
Long
userId
);
UserFullResp
findUserFullSearchByUserId
(
Long
userId
,
Integer
tenantId
);
/**
* 按照userid 或者 uuid 批量查询
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/ModifyPhoneNoServiceImpl.java
View file @
423b1579
...
...
@@ -17,7 +17,7 @@ import cn.quantgroup.xyqb.model.ModifyPhoneNoApplyStatusEnum;
import
cn.quantgroup.xyqb.model.ModifyPhoneNoProcessingStatusEnum
;
import
cn.quantgroup.xyqb.repository.IModifyPhoneNoRepository
;
import
cn.quantgroup.xyqb.repository.IModifyPhoneRecordRepository
;
import
cn.quantgroup.xyqb.repository.IUser
Detail
Repository
;
import
cn.quantgroup.xyqb.repository.IUser
Info
Repository
;
import
cn.quantgroup.xyqb.repository.IUserRepository
;
import
cn.quantgroup.xyqb.service.http.IHttpService
;
import
cn.quantgroup.xyqb.service.session.ISessionService
;
...
...
@@ -70,7 +70,7 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
@Resource
private
IModifyPhoneNoRepository
modifyPhoneNoRepository
;
@Resource
private
IUser
DetailRepository
userDetail
Repository
;
private
IUser
InfoRepository
userInfo
Repository
;
@Resource
private
ISmsService
smsService
;
@Resource
...
...
@@ -242,9 +242,6 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
if
(
ModifyPhoneNoApplyStatusEnum
.
DONE
==
auditReq
.
getApplyStatus
())
{
log
.
info
(
"audit userId = 【{}】, name = 【{}】, idCard = 【{}】, prevPhoneNo = 【{}】, "
+
"curPhoneNo = 【{}】"
,
modifyPhoneNo
.
getUserId
(),
modifyPhoneNo
.
getName
(),
modifyPhoneNo
.
getIdCard
(),
modifyPhoneNo
.
getPrevPhoneNo
(),
modifyPhoneNo
.
getCurPhoneNo
());
if
(
userDetailRepository
.
findByUserIdAndPhoneNoAndName
(
modifyPhoneNo
.
getUserId
(),
modifyPhoneNo
.
getPrevPhoneNo
(),
modifyPhoneNo
.
getName
())
==
null
)
{
throw
new
DataException
(
"姓名、身份证、电话号不符。"
);
}
if
(
userRepository
.
findByPhoneNo
(
modifyPhoneNo
.
getCurPhoneNo
())
!=
null
)
{
throw
new
DataException
(
"新手机号已存在,不支持更换。"
);
}
...
...
@@ -262,7 +259,8 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
// 如果有返回值
if
(
"0000"
.
equals
(
resultStrJson
.
getBusinessCode
())
||
"4014"
.
equals
(
resultStrJson
.
getBusinessCode
()))
{
// 同步金融修改电商
userService
.
modifyPhoneNo
(
modifyPhoneNo
.
getPrevPhoneNo
(),
modifyPhoneNo
.
getCurPhoneNo
());
User
user
=
userService
.
findById
(
modifyPhoneNo
.
getUserId
());
userService
.
modifyPhoneNo
(
modifyPhoneNo
.
getPrevPhoneNo
(),
modifyPhoneNo
.
getCurPhoneNo
(),
user
.
getTenantId
());
modifyPhoneNo
.
setApplyStatus
(
ModifyPhoneNoApplyStatusEnum
.
DONE
.
ordinal
());
modifyPhoneNo
.
setProcessingStatus
(
ModifyPhoneNoProcessingStatusEnum
.
WAIT_4_USER_FEEDBACK
.
ordinal
());
}
else
{
...
...
@@ -547,9 +545,6 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
if
(!
smsService
.
verifyPhoneAndCode
(
curPhoneNo
,
smsCode
))
{
throw
new
DataException
(
"验证码不正确。"
);
}
if
(
userDetailRepository
.
findByUserIdAndPhoneNoAndName
(
userId
,
prevPhoneNo
,
name
)
==
null
)
{
throw
new
DataException
(
"信息填写有误,请重新填写。"
);
}
if
(
userService
.
findByPhoneInDb
(
curPhoneNo
)
!=
null
)
{
throw
new
DataException
(
"填写信息有误,新手机号已注册。"
);
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserDetailServiceImpl.java
deleted
100644 → 0
View file @
3fca5558
This diff is collapsed.
Click to expand it.
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
View file @
423b1579
...
...
@@ -7,7 +7,7 @@ import cn.quantgroup.xyqb.controller.IBaseController;
import
cn.quantgroup.xyqb.controller.internal.user.resp.UserFullResp
;
import
cn.quantgroup.xyqb.entity.Merchant
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
Detail
;
import
cn.quantgroup.xyqb.entity.User
InfoEntity
;
import
cn.quantgroup.xyqb.event.PhoneNoUpdateEvent
;
import
cn.quantgroup.xyqb.exception.DataException
;
import
cn.quantgroup.xyqb.exception.UserNotExistException
;
...
...
@@ -67,10 +67,8 @@ public class UserServiceImpl implements IUserService, IBaseController {
@Autowired
private
IUserRepository
userRepository
;
@Autowired
private
IUser
DetailService
userDetailService
;
private
IUser
InfoRepository
userInfoRepository
;
@Autowired
private
ApplicationEventPublisher
applicationEventPublisher
;
...
...
@@ -253,14 +251,14 @@ public class UserServiceImpl implements IUserService, IBaseController {
@Override
public
List
<
UserInfo
>
findUserInfosByPhones
(
List
<
String
>
phones
)
{
public
List
<
UserInfo
>
findUserInfosByPhones
(
List
<
String
>
phones
,
Integer
tenantId
)
{
List
<
User
>
users
=
findByPhones
(
phones
);
if
(
CollectionUtils
.
isEmpty
(
phones
))
{
return
Collections
.
emptyList
();
}
List
<
User
Detail
>
userDetails
=
userDetailService
.
findByPhones
(
phones
);
List
<
User
InfoEntity
>
userDetails
=
userInfoRepository
.
findByTenantIdAndPhoneNoIn
(
tenantId
,
phones
);
if
(!
CollectionUtils
.
isEmpty
(
users
))
{
Map
<
Long
,
User
>
userMap
=
Maps
.
newHashMapWithExpectedSize
(
users
.
size
());
...
...
@@ -283,10 +281,10 @@ public class UserServiceImpl implements IUserService, IBaseController {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
User
modifyPhoneNo
(
String
oldPhoneNo
,
String
newPhoneNo
)
{
public
User
modifyPhoneNo
(
String
oldPhoneNo
,
String
newPhoneNo
,
Integer
tenantId
)
{
//1. 判断新手机号是否存在
User
newPhoneUser
=
userRepository
.
findByPhoneNo
(
newPhoneNo
);
User
Detail
newPhoneUserDetail
=
userDetailService
.
findByPhoneNo
(
newPhoneNo
);
User
InfoEntity
newPhoneUserDetail
=
userInfoRepository
.
findByPhoneNoAndTenantId
(
newPhoneNo
,
tenantId
);
if
(
Objects
.
nonNull
(
newPhoneUser
)
||
Objects
.
nonNull
(
newPhoneUserDetail
))
{
//新手机号已存在
throw
new
DataException
(
"新手机号存在, 用户修改手机号后新手机号注册了。"
);
...
...
@@ -303,9 +301,9 @@ public class UserServiceImpl implements IUserService, IBaseController {
User
user
=
userRepository
.
saveAndFlush
(
oldPhoneUser
);
//2.2 修改 user_detail 表
User
Detail
oldPhoneUserDetail
=
userDetailService
.
findByPhoneNo
(
oldPhoneNo
);
User
InfoEntity
oldPhoneUserDetail
=
userInfoRepository
.
findByPhoneNoAndTenantId
(
oldPhoneNo
,
tenantId
);
oldPhoneUserDetail
.
setPhoneNo
(
newPhoneNo
);
user
DetailService
.
saveUserDetail
(
oldPhoneUserDetail
);
user
InfoRepository
.
save
(
oldPhoneUserDetail
);
//3. 发送事件
PhoneNoUpdateEvent
phoneNoUpdateEvent
=
new
PhoneNoUpdateEvent
(
this
,
user
,
oldPhoneNo
);
...
...
@@ -434,9 +432,9 @@ public class UserServiceImpl implements IUserService, IBaseController {
* @return
*/
@Override
public
UserFullResp
findUserFullSearchByUserId
(
Long
userId
)
{
public
UserFullResp
findUserFullSearchByUserId
(
Long
userId
,
Integer
tenantId
)
{
User
user
=
userRepository
.
findById
(
userId
);
User
Detail
userDetail
=
userDetailService
.
findByUserId
(
user
Id
);
User
InfoEntity
userDetail
=
userInfoRepository
.
findByUserIdAndTenantId
(
userId
,
tenant
Id
);
UserFullResp
userFullResp
=
UserFullResp
.
builder
().
userId
(
userId
).
build
();
if
(
user
!=
null
)
{
...
...
src/test/java/common/JsonTest.java
View file @
423b1579
package
common
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.model.IdType
;
import
cn.quantgroup.xyqb.entity.UserInfoEntity
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
...
...
@@ -14,7 +13,7 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.junit.runners.JUnit4
;
import
java.
sql.Timestamp
;
import
java.
time.LocalDateTime
;
@Slf4j
@RunWith
(
JUnit4
.
class
)
...
...
@@ -28,10 +27,10 @@ public class JsonTest {
@Test
public
void
intFloat
(){
try
{
User
Detail
userData
=
new
UserDetail
();
User
InfoEntity
userData
=
new
UserInfoEntity
();
userData
.
setId
(
131L
);
userData
.
setUserId
(
119L
);
userData
.
setCreatedAt
(
new
Timestamp
(
1
));
userData
.
setCreatedAt
(
LocalDateTime
.
now
(
));
log
.
info
(
"序列化--GSON--成功!data:{}"
,
JSON
.
toJSONString
(
userData
));
log
.
info
(
"序列化--MAPPER--成功!data:{}"
,
MAPPER
.
writeValueAsString
(
userData
));
log
.
info
(
"序列化--JSON--成功!data:{}"
,
JSON
.
toJSONString
(
userData
,
SerializerFeature
.
config
(
JSON
.
DEFAULT_GENERATE_FEATURE
,
SerializerFeature
.
WriteEnumUsingName
,
false
)));
...
...
@@ -44,7 +43,7 @@ public class JsonTest {
@Test
public
void
gsonGson
(){
try
{
User
Detail
userData
=
JSON
.
parseObject
(
body
,
UserDetail
.
class
);
User
InfoEntity
userData
=
JSON
.
parseObject
(
body
,
UserInfoEntity
.
class
);
log
.
info
(
"GSON--成功!data:{}"
,
userData
);
}
catch
(
Exception
e
){
log
.
error
(
"GSON--失败!"
,
e
);
...
...
@@ -54,7 +53,7 @@ public class JsonTest {
@Test
public
void
jacksonObjectMapper
(){
try
{
User
Detail
userData
=
MAPPER
.
readValue
(
body
,
UserDetail
.
class
);
User
InfoEntity
userData
=
MAPPER
.
readValue
(
body
,
UserInfoEntity
.
class
);
log
.
info
(
"MAPPER--成功!data:{}"
,
userData
);
}
catch
(
Exception
e
){
log
.
error
(
"MAPPER--失败!"
,
e
);
...
...
@@ -64,9 +63,9 @@ public class JsonTest {
@Test
public
void
fastjsonJSONObject
(){
try
{
User
Detail
userData
=
JSONObject
.
parseObject
(
body
,
UserDetail
.
class
);
User
InfoEntity
userData
=
JSONObject
.
parseObject
(
body
,
UserInfoEntity
.
class
);
log
.
info
(
"JSONObject--成功!data:{}"
,
userData
);
userData
=
JSON
.
parseObject
(
body
,
User
Detail
.
class
);
userData
=
JSON
.
parseObject
(
body
,
User
InfoEntity
.
class
);
log
.
info
(
"JSONObject--成功!data:{}"
,
userData
);
}
catch
(
Exception
e
){
log
.
error
(
"JSONObject--失败!"
,
e
);
...
...
src/test/java/demo/RepsitoryJpaTest.java
View file @
423b1579
...
...
@@ -18,8 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
javax.persistence.PersistenceException
;
import
java.sql.Timestamp
;
import
java.time.Instant
;
import
java.time.LocalDateTime
;
/**
* 持久层测试用例
...
...
@@ -55,7 +54,7 @@ public class RepsitoryJpaTest {
User
user
=
new
User
();
user
.
setPhoneNo
(
phone
);
user
.
setPassword
(
password
);
user
.
setCreatedAt
(
Timestamp
.
from
(
Instant
.
now
()
));
user
.
setCreatedAt
(
LocalDateTime
.
now
(
));
user
.
setUpdatedAt
(
user
.
getCreatedAt
());
user
=
userRepository
.
save
(
user
);
User
userRep
=
userRepository
.
findByPhoneNo
(
phone
);
...
...
src/test/java/demo/RepsitoryTest.java
View file @
423b1579
...
...
@@ -15,8 +15,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.sql.Timestamp
;
import
java.time.Instant
;
import
java.time.LocalDateTime
;
/**
...
...
@@ -50,8 +49,8 @@ public class RepsitoryTest extends AbstractTransactionalJUnit4SpringContextTests
User
user
=
new
User
();
user
.
setPhoneNo
(
phone
);
user
.
setPassword
(
password
);
user
.
setCreatedAt
(
Timestamp
.
from
(
Instant
.
now
()
));
user
.
setUpdatedAt
(
user
.
getCreatedAt
());
user
.
setCreatedAt
(
LocalDateTime
.
now
(
));
user
.
setUpdatedAt
(
LocalDateTime
.
now
());
user
=
userRepository
.
save
(
user
);
User
userRep
=
userRepository
.
findByPhoneNo
(
phone
);
Assert
.
assertEquals
(
user
,
userRep
);
...
...
src/test/java/demo/ServiceTest.java
View file @
423b1579
...
...
@@ -15,8 +15,7 @@ import org.springframework.test.context.junit4.SpringRunner;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.sql.Timestamp
;
import
java.time.Instant
;
import
java.time.LocalDateTime
;
/**
* 业务层测试用例
...
...
@@ -49,7 +48,7 @@ public class ServiceTest extends AbstractTransactionalJUnit4SpringContextTests {
User
user
=
new
User
();
user
.
setPhoneNo
(
phone
);
user
.
setPassword
(
password
);
user
.
setCreatedAt
(
Timestamp
.
from
(
Instant
.
now
()
));
user
.
setCreatedAt
(
LocalDateTime
.
now
(
));
user
.
setUpdatedAt
(
user
.
getCreatedAt
());
user
=
userService
.
saveUser
(
user
);
User
userRep
=
userService
.
findByPhoneInDb
(
phone
);
...
...
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