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
30485d11
Commit
30485d11
authored
Apr 28, 2018
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现内部免密调用接口:包括:重置用户敏感信息,激活、禁用、重置密码、重置账号、重置身份证号、姓名
parent
1aa38b5d
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
276 additions
and
148 deletions
+276
-148
UserQueryLogController.java
.../controller/external/queryLog/UserQueryLogController.java
+2
-4
InnerController.java
...tgroup/xyqb/controller/external/user/InnerController.java
+212
-119
IUserDetailRepository.java
.../cn/quantgroup/xyqb/repository/IUserDetailRepository.java
+7
-0
IUserRepository.java
...n/java/cn/quantgroup/xyqb/repository/IUserRepository.java
+7
-0
IUserService.java
...in/java/cn/quantgroup/xyqb/service/user/IUserService.java
+11
-0
UserDetailServiceImpl.java
...ntgroup/xyqb/service/user/impl/UserDetailServiceImpl.java
+2
-2
UserServiceImpl.java
...cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
+18
-6
IdcardValidator.java
src/main/java/cn/quantgroup/xyqb/util/IdcardValidator.java
+17
-17
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/queryLog/UserQueryLogController.java
View file @
30485d11
...
@@ -194,9 +194,8 @@ public class UserQueryLogController {
...
@@ -194,9 +194,8 @@ public class UserQueryLogController {
}
}
userDetailPage
=
userDetailService
.
getUserDetailsPage
(
null
,
queryV
,
null
,
pageId
,
pageSize
,
"auto"
);
userDetailPage
=
userDetailService
.
getUserDetailsPage
(
null
,
queryV
,
null
,
pageId
,
pageSize
,
"auto"
);
}
else
if
(
Objects
.
equals
(
key
,
"idNo"
)){
}
else
if
(
Objects
.
equals
(
key
,
"idNo"
)){
IdcardValidator
iv
=
new
IdcardValidator
();
for
(
String
idno:
queryV
){
for
(
String
idno:
queryV
){
if
(!
iv
.
is18Idcard
(
idno
)&&!
iv
.
is15Idcard
(
idno
)){
if
(!
IdcardValidator
.
is18Idcard
(
idno
)&&!
IdcardValidator
.
is15Idcard
(
idno
)){
return
JsonResult
.
buildErrorStateResult
(
"查询的身份证号"
+
idno
+
"格式有误"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"查询的身份证号"
+
idno
+
"格式有误"
,
null
);
}
}
}
}
...
@@ -405,9 +404,8 @@ public class UserQueryLogController {
...
@@ -405,9 +404,8 @@ public class UserQueryLogController {
userDetails
=
userDetailService
.
findByPhoneNos
(
queryV
);
userDetails
=
userDetailService
.
findByPhoneNos
(
queryV
);
}
else
if
(
Objects
.
equals
(
key
,
"idNo"
)){
}
else
if
(
Objects
.
equals
(
key
,
"idNo"
)){
IdcardValidator
iv
=
new
IdcardValidator
();
for
(
String
idno:
queryV
){
for
(
String
idno:
queryV
){
if
(!
iv
.
is18Idcard
(
idno
)&&!
iv
.
is15Idcard
(
idno
)){
if
(!
IdcardValidator
.
is18Idcard
(
idno
)&&!
IdcardValidator
.
is15Idcard
(
idno
)){
return
JsonResult
.
buildErrorStateResult
(
"查询的身份证号"
+
idno
+
"格式有误"
,
idno
);
return
JsonResult
.
buildErrorStateResult
(
"查询的身份证号"
+
idno
+
"格式有误"
,
idno
);
}
}
}
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/external/user/InnerController.java
View file @
30485d11
...
@@ -32,6 +32,7 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -32,6 +32,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.math.NumberUtils
;
import
org.apache.commons.lang3.math.NumberUtils
;
import
org.apache.http.HttpStatus
;
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.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -857,30 +858,6 @@ public class InnerController implements IBaseController {
...
@@ -857,30 +858,6 @@ public class InnerController implements IBaseController {
return
JsonResult
.
buildSuccessResult
(
null
,
null
==
wechatUserInfo
?
null
:
wechatUserInfo
.
getOpenId
());
return
JsonResult
.
buildSuccessResult
(
null
,
null
==
wechatUserInfo
?
null
:
wechatUserInfo
.
getOpenId
());
}
}
/**
* 激活/启用 用户
* @param userId
* @return
*/
@LogHttpCaller
@RequestMapping
(
"/user/active"
)
public
JsonResult
activeUser
(
Long
userId
)
{
boolean
flushed
=
flushUserStatus
(
userId
,
true
);
return
JsonResult
.
buildSuccessResult
(
"用户已激活."
,
flushed
);
}
/**
* 注销/禁用 用户
* @param userId
* @return
*/
@LogHttpCaller
@RequestMapping
(
"/user/disable"
)
public
JsonResult
forbiddenUser
(
Long
userId
)
{
boolean
flushed
=
flushUserStatus
(
userId
,
false
);
return
JsonResult
.
buildSuccessResult
(
"用户已禁用."
,
flushed
);
}
/**
/**
* 刷新用户激活状态
* 刷新用户激活状态
* @param userId - 用户主键
* @param userId - 用户主键
...
@@ -1005,29 +982,6 @@ public class InnerController implements IBaseController {
...
@@ -1005,29 +982,6 @@ public class InnerController implements IBaseController {
return
JsonResult
.
buildErrorStateResult
(
"主库不提供查询"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"主库不提供查询"
,
null
);
}
}
/**
* 重置密码接口,供内部人员使用(例如绝影)
*/
@LogHttpCaller
@RequestMapping
(
"/user/password/reset/{key}/{phone}"
)
public
JsonResult
resetPassword
(
@PathVariable
(
"key"
)
String
key
,
@PathVariable
(
"phone"
)
String
phone
)
{
log
.
info
(
"密码重置请求,phone:[{}]"
,
phone
);
if
(
StringUtils
.
isBlank
(
key
))
{
return
JsonResult
.
buildErrorStateResult
(
"用户密码重置失败."
,
null
);
}
if
(!
"ecf75c1f-2ccb-4661-8e4b-2874c0f45a2b"
.
equalsIgnoreCase
(
key
))
{
log
.
error
(
"密码重置失败,key错误!@!,phone:[{}]"
,
phone
);
return
JsonResult
.
buildErrorStateResult
(
"用户密码重置失败."
,
null
);
}
try
{
userService
.
resetPassword
(
phone
,
"123456"
);
//默认重置的密码是123456
return
JsonResult
.
buildSuccessResult
(
"用户密码已重置."
,
"null"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"密码重置失败,phone[{}],err:[{}]"
,
phone
,
e
);
}
return
JsonResult
.
buildErrorStateResult
(
"用户密码重置失败."
,
null
);
}
/**
/**
* 保存用户信息,地址信息,联系人信息
* 保存用户信息,地址信息,联系人信息
*/
*/
...
@@ -1132,78 +1086,6 @@ public class InnerController implements IBaseController {
...
@@ -1132,78 +1086,6 @@ public class InnerController implements IBaseController {
return
JsonResult
.
buildSuccessResult
(
null
,
userList
);
return
JsonResult
.
buildSuccessResult
(
null
,
userList
);
}
}
@LogHttpCaller
@RequestMapping
(
"/forbiddenUserWeChat"
)
public
JsonResult
forbiddenUserWeChat
(
@RequestParam
Long
userId
,
@RequestParam
String
reason
,
@RequestParam
String
content
)
{
if
(
StringUtils
.
isBlank
(
reason
)
||
null
==
userId
||
userId
<=
0
)
{
return
JsonResult
.
buildErrorStateResult
(
"参数有误"
,
null
);
}
//密文
if
(
null
!=
content
)
{
content
=
content
.
replaceAll
(
" "
,
"+"
);
}
String
str
=
AESUtil
.
decryptAfterBase64Decode
(
content
,
Constants
.
AES_KEY
);
if
(
null
==
str
||
!
str
.
equals
(
userId
.
toString
()))
{
return
JsonResult
.
buildErrorStateResult
(
"解密有误"
,
null
);
}
int
affectedRows
=
wechatService
.
forbiddenUserWeChat
(
userId
);
log
.
info
(
"用户微信禁用,userId:{},禁用的原因reason:{},受影响的行数affectedRows:{}"
,
userId
,
reason
,
affectedRows
);
return
JsonResult
.
buildSuccessResult
(
"用户禁用微信成功"
,
affectedRows
);
}
@LogHttpCaller
@RequestMapping
(
"/updateIdCard"
)
public
JsonResult
updateIdCard
(
@RequestParam
(
required
=
false
)
String
name
,
@RequestParam
(
required
=
false
)
String
idNo
,
@RequestParam
String
phoneNo
,
@RequestParam
String
reason
,
@RequestParam
String
content
)
{
//密文
if
(
null
!=
content
)
{
content
=
content
.
replaceAll
(
" "
,
"+"
);
}
String
str
=
AESUtil
.
decryptAfterBase64Decode
(
content
,
Constants
.
AES_KEY
);
if
(
null
==
str
||
!
str
.
equals
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"解密有误"
,
null
);
}
if
(
StringUtils
.
isBlank
(
name
)
&&
StringUtils
.
isBlank
(
idNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"不能全为空"
,
null
);
}
if
(
StringUtils
.
isBlank
(
phoneNo
)
||
StringUtils
.
isBlank
(
reason
))
{
return
JsonResult
.
buildErrorStateResult
(
"参数有误"
,
null
);
}
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
log
.
info
(
"手机号有误, phoneNo:{}"
,
phoneNo
);
return
JsonResult
.
buildErrorStateResult
(
"用户手机号错误"
,
null
);
}
int
affectedRows
=
userDetailService
.
updateIdCard
(
name
,
idNo
,
phoneNo
);
log
.
info
(
"更新用户的信息,name;{},idNo:{},phoneNo:{},操作的理由reason:{},受影响的行数affectedRows:{}"
,
name
,
idNo
,
phoneNo
,
reason
,
affectedRows
);
return
JsonResult
.
buildSuccessResult
(
"修改用户身份证号或姓名成功"
,
affectedRows
);
}
@LogHttpCaller
@RequestMapping
(
"/forbiddenUserOrNot"
)
public
JsonResult
forbiddenUserOrNot
(
@RequestParam
String
phoneNo
,
@RequestParam
Boolean
enable
,
@RequestParam
String
reason
,
@RequestParam
String
content
)
{
if
(
StringUtils
.
isBlank
(
phoneNo
)
||
StringUtils
.
isBlank
(
reason
))
{
return
JsonResult
.
buildErrorStateResult
(
"参数有误"
,
null
);
}
//密文
if
(
null
!=
content
)
{
content
=
content
.
replaceAll
(
" "
,
"+"
);
}
String
str
=
AESUtil
.
decryptAfterBase64Decode
(
content
,
Constants
.
AES_KEY
);
if
(
null
==
str
||
!
str
.
equals
(
phoneNo
))
{
log
.
info
(
"[forbiddenUserOrNot][禁用或激活用户]:解密有误, phoneNo:{},aes:{}"
,
phoneNo
,
AESUtil
.
encryptAndBase64Encode
(
phoneNo
,
Constants
.
AES_KEY
));
return
JsonResult
.
buildErrorStateResult
(
"解密有误"
,
null
);
}
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
log
.
info
(
"[forbiddenUserOrNot][禁用或激活用户]:用户手机号错误, phoneNo:{}"
,
phoneNo
);
return
JsonResult
.
buildErrorStateResult
(
"用户手机号错误"
,
null
);
}
int
affectedRows
=
userService
.
forbiddenUser
(
enable
,
phoneNo
);
log
.
info
(
"[forbiddenUserOrNot][禁用或激活用户]:理由:reason:{},手机号phoneNo:{},受影响的行数affectedRows:{}"
,
reason
,
phoneNo
,
affectedRows
);
return
JsonResult
.
buildSuccessResult
(
"用户禁用或重启成功成功"
,
affectedRows
);
}
private
String
genRandomPwd
()
{
private
String
genRandomPwd
()
{
int
pwdMax
=
PWD_BASE
.
length
;
int
pwdMax
=
PWD_BASE
.
length
;
// 生成的随机数
// 生成的随机数
...
@@ -1348,4 +1230,215 @@ public class InnerController implements IBaseController {
...
@@ -1348,4 +1230,215 @@ public class InnerController implements IBaseController {
return
JsonResult
.
buildErrorStateResult
(
"用户不存在"
,
validMap
);
return
JsonResult
.
buildErrorStateResult
(
"用户不存在"
,
validMap
);
}
}
/**
* 激活/启用 用户
* -- 供内部系统免密调用
* @param userId
* @return
*/
@LogHttpCaller
@RequestMapping
(
"/user/active"
)
public
JsonResult
activeUser
(
Long
userId
)
{
boolean
flushed
=
flushUserStatus
(
userId
,
true
);
return
JsonResult
.
buildSuccessResult
(
"用户已激活."
,
flushed
);
}
/**
* 注销/禁用 用户
* -- 供内部系统免密调用
* @param userId
* @return
*/
@LogHttpCaller
@RequestMapping
(
"/user/disable"
)
public
JsonResult
forbiddenUser
(
Long
userId
)
{
boolean
flushed
=
flushUserStatus
(
userId
,
false
);
return
JsonResult
.
buildSuccessResult
(
"用户已禁用."
,
flushed
);
}
/**
* 重置账号(手机号)接口
* -- 供内部系统免密调用
*
* 注意:此操作会级联更新UserDetail的phoneNo
*
* @param userId - 用户主键
* @param account - 旧账号
* @param phoneNo - 新账号
*/
@LogHttpCaller
@RequestMapping
(
"/user/resetAccount/{userId}/{account}"
)
public
JsonResult
resetAccount
(
@PathVariable
(
"userId"
)
Long
userId
,
@PathVariable
(
"account"
)
String
account
,
@RequestParam
(
"phoneNo"
)
String
phoneNo
)
{
log
.
info
(
"重置用户账号 userId:{},account_old:{},account_new:{}"
,
userId
,
account
,
phoneNo
);
if
(
ValidationUtil
.
validatePhoneNo
(
account
)
&&
ValidationUtil
.
validatePhoneNo
(
phoneNo
)){
try
{
// 重置账号
boolean
result
=
userService
.
resetAccount
(
userId
,
account
,
phoneNo
);
log
.
info
(
"重置用户账号,结果:{},account_old:{},account_new:{}"
,
result
,
account
,
(
result
?
phoneNo
:
account
));
return
JsonResult
.
buildSuccessResult
(
"用户账号已重置."
.
concat
(
String
.
valueOf
(
result
)),
(
result
?
phoneNo
:
account
));
}
catch
(
Exception
e
)
{
log
.
error
(
"账号重置失败,phone[{}],err:[{}]"
,
phoneNo
,
e
);
}
return
JsonResult
.
buildErrorStateResult
(
"用户账号重置失败."
,
"Error phone"
);
}
else
{
return
JsonResult
.
buildErrorStateResult
(
"用户账号重置失败."
,
"Error phone"
);
}
}
/**
* 重置用户实名信息接口
* -- 供内部系统免密调用
* @param userId - 用户主键
* @param idNo - 身份证号
* @param name - 姓名
*/
@LogHttpCaller
@RequestMapping
(
"/userDetail/reset/{userId}"
)
public
JsonResult
resetName
(
@PathVariable
(
"userId"
)
Long
userId
,
@RequestParam
(
"name"
)
String
name
,
@RequestParam
(
"idNo"
)
String
idNo
)
{
log
.
info
(
"重置用户实名信息 userId:{},name:{},idNo:{}"
,
userId
,
name
,
idNo
);
if
(
Objects
.
nonNull
(
userId
)
&&
ValidationUtil
.
validateChinese
(
name
)){
try
{
User
user
=
userService
.
findById
(
userId
);
int
rows
=
userDetailService
.
updateIdCard
(
name
,
idNo
,
user
.
getPhoneNo
());
log
.
info
(
"重置用户实名信息,结果:{},userId:{},name:{},idNo:{}"
,
rows
,
userId
,
name
,
idNo
);
return
JsonResult
.
buildSuccessResult
(
"用户姓名已重置."
,
name
);
}
catch
(
Exception
e
)
{
log
.
error
(
"用户姓名重置失败,userId[{}],name[{}],err:[{}]"
,
userId
,
name
,
e
);
}
return
JsonResult
.
buildErrorStateResult
(
"用户姓名重置失败."
,
"Error data"
);
}
else
{
return
JsonResult
.
buildErrorStateResult
(
"用户姓名重置失败."
,
"Error data"
);
}
}
/**
* 重置密码接口
* -- 供内部系统免密调用
*/
@LogHttpCaller
@RequestMapping
(
"/user/password/reset"
)
public
JsonResult
resetPassword
(
@RequestParam
(
"phone"
)
String
phone
)
{
if
(
ValidationUtil
.
validatePhoneNo
(
phone
)){
try
{
// 默认重置的密码是123456
String
password
=
"123456"
;
boolean
result
=
userService
.
resetPassword
(
phone
,
password
);
log
.
info
(
"重置用户密码,结果:{},phoneNo:{},password:{}"
,
result
,
phone
,
password
);
return
JsonResult
.
buildSuccessResult
(
"用户密码已重置."
.
concat
(
String
.
valueOf
(
result
)),
password
);
}
catch
(
Exception
e
)
{
log
.
error
(
"密码重置失败,phone[{}],err:[{}]"
,
phone
,
e
);
}
return
JsonResult
.
buildErrorStateResult
(
"用户密码重置失败."
,
"Error phone"
);
}
else
{
return
JsonResult
.
buildErrorStateResult
(
"用户密码重置失败."
,
"Error phone"
);
}
}
/**
* 修改实名信息接口
* -- 供内部人员使用(例如绝影)
*/
@LogHttpCaller
@RequestMapping
(
"/updateIdCard"
)
public
JsonResult
updateIdCard
(
@RequestParam
(
required
=
false
)
String
name
,
@RequestParam
(
required
=
false
)
String
idNo
,
@RequestParam
String
phoneNo
,
@RequestParam
String
reason
,
@RequestParam
String
content
)
{
//密文
if
(
null
!=
content
)
{
content
=
content
.
replaceAll
(
" "
,
"+"
);
}
String
str
=
AESUtil
.
decryptAfterBase64Decode
(
content
,
Constants
.
AES_KEY
);
if
(
null
==
str
||
!
str
.
equals
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"解密有误"
,
null
);
}
if
(
StringUtils
.
isBlank
(
name
)
&&
StringUtils
.
isBlank
(
idNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"不能全为空"
,
null
);
}
if
(
StringUtils
.
isBlank
(
phoneNo
)
||
StringUtils
.
isBlank
(
reason
))
{
return
JsonResult
.
buildErrorStateResult
(
"参数有误"
,
null
);
}
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
log
.
info
(
"手机号有误, phoneNo:{}"
,
phoneNo
);
return
JsonResult
.
buildErrorStateResult
(
"用户手机号错误"
,
null
);
}
int
affectedRows
=
userDetailService
.
updateIdCard
(
name
,
idNo
,
phoneNo
);
log
.
info
(
"更新用户的信息,name;{},idNo:{},phoneNo:{},操作的理由reason:{},受影响的行数affectedRows:{}"
,
name
,
idNo
,
phoneNo
,
reason
,
affectedRows
);
return
JsonResult
.
buildSuccessResult
(
"修改用户身份证号或姓名成功"
,
affectedRows
);
}
/**
* 重置密码接口
* -- 供内部人员使用(例如绝影)
*/
@LogHttpCaller
@RequestMapping
(
"/user/password/reset/{key}/{phone}"
)
public
JsonResult
resetPasswordByKey
(
@PathVariable
(
"key"
)
String
key
,
@PathVariable
(
"phone"
)
String
phone
)
{
log
.
info
(
"密码重置请求,phone:[{}]"
,
phone
);
if
(!
"ecf75c1f-2ccb-4661-8e4b-2874c0f45a2b"
.
equalsIgnoreCase
(
key
))
{
log
.
error
(
"密码重置失败,key错误!@!,phone:[{}]"
,
phone
);
return
JsonResult
.
buildErrorStateResult
(
"用户密码重置失败."
,
HttpStatus
.
SC_UNAUTHORIZED
);
}
return
resetPassword
(
phone
);
}
/**
* 注销/禁用 用户
* -- 供内部人员使用(例如绝影)
* @param phoneNo
* @param enable
* @param reason
* @param content
* @return
*/
@LogHttpCaller
@RequestMapping
(
"/forbiddenUserOrNot"
)
public
JsonResult
forbiddenUserOrNot
(
@RequestParam
String
phoneNo
,
@RequestParam
Boolean
enable
,
@RequestParam
String
reason
,
@RequestParam
String
content
)
{
if
(
StringUtils
.
isBlank
(
phoneNo
)
||
StringUtils
.
isBlank
(
reason
))
{
return
JsonResult
.
buildErrorStateResult
(
"参数有误"
,
null
);
}
//密文
if
(
null
!=
content
)
{
content
=
content
.
replaceAll
(
" "
,
"+"
);
}
String
str
=
AESUtil
.
decryptAfterBase64Decode
(
content
,
Constants
.
AES_KEY
);
if
(
null
==
str
||
!
str
.
equals
(
phoneNo
))
{
log
.
info
(
"[forbiddenUserOrNot][禁用或激活用户]:解密有误, phoneNo:{},aes:{}"
,
phoneNo
,
AESUtil
.
encryptAndBase64Encode
(
phoneNo
,
Constants
.
AES_KEY
));
return
JsonResult
.
buildErrorStateResult
(
"解密有误"
,
null
);
}
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
log
.
info
(
"[forbiddenUserOrNot][禁用或激活用户]:用户手机号错误, phoneNo:{}"
,
phoneNo
);
return
JsonResult
.
buildErrorStateResult
(
"用户手机号错误"
,
null
);
}
int
affectedRows
=
userService
.
forbiddenUser
(
enable
,
phoneNo
);
log
.
info
(
"[forbiddenUserOrNot][禁用或激活用户]:理由:reason:{},手机号phoneNo:{},受影响的行数affectedRows:{}"
,
reason
,
phoneNo
,
affectedRows
);
return
JsonResult
.
buildSuccessResult
(
"用户禁用或重启成功成功"
,
affectedRows
);
}
/**
* 清除微信关联
* -- 供内部人员使用(例如绝影)
* @param userId
* @param reason
* @param content
* @return
*/
@LogHttpCaller
@RequestMapping
(
"/forbiddenUserWeChat"
)
public
JsonResult
forbiddenUserWeChat
(
@RequestParam
Long
userId
,
@RequestParam
String
reason
,
@RequestParam
String
content
)
{
if
(
StringUtils
.
isBlank
(
reason
)
||
null
==
userId
||
userId
<=
0
)
{
return
JsonResult
.
buildErrorStateResult
(
"参数有误"
,
null
);
}
//密文
if
(
null
!=
content
)
{
content
=
content
.
replaceAll
(
" "
,
"+"
);
}
String
str
=
AESUtil
.
decryptAfterBase64Decode
(
content
,
Constants
.
AES_KEY
);
if
(
null
==
str
||
!
str
.
equals
(
userId
.
toString
()))
{
return
JsonResult
.
buildErrorStateResult
(
"解密有误"
,
null
);
}
int
affectedRows
=
wechatService
.
forbiddenUserWeChat
(
userId
);
log
.
info
(
"用户微信禁用,userId:{},禁用的原因reason:{},受影响的行数affectedRows:{}"
,
userId
,
reason
,
affectedRows
);
return
JsonResult
.
buildSuccessResult
(
"用户禁用微信成功"
,
affectedRows
);
}
}
}
\ No newline at end of file
src/main/java/cn/quantgroup/xyqb/repository/IUserDetailRepository.java
View file @
30485d11
...
@@ -10,6 +10,8 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -10,6 +10,8 @@ import org.springframework.transaction.annotation.Transactional;
import
java.util.List
;
import
java.util.List
;
import
static
org
.
springframework
.
transaction
.
annotation
.
Propagation
.
MANDATORY
;
/**
/**
* @author mengfan.feng
* @author mengfan.feng
* @time 2015-09-11 11:22
* @time 2015-09-11 11:22
...
@@ -54,4 +56,9 @@ public interface IUserDetailRepository extends JpaRepository<UserDetail, Long>,J
...
@@ -54,4 +56,9 @@ public interface IUserDetailRepository extends JpaRepository<UserDetail, Long>,J
@Modifying
@Modifying
@Query
(
value
=
"update user_detail set name=?1 where phone_no=?2"
,
nativeQuery
=
true
)
@Query
(
value
=
"update user_detail set name=?1 where phone_no=?2"
,
nativeQuery
=
true
)
int
updateNameByPhoneNo
(
String
name
,
String
phoneNo
);
int
updateNameByPhoneNo
(
String
name
,
String
phoneNo
);
@Transactional
(
propagation
=
MANDATORY
)
@Modifying
@Query
(
value
=
"update user_detail set phone_no=?2 where user_id=?1"
,
nativeQuery
=
true
)
int
resetPhoneNo
(
Long
userId
,
String
phoneNo
);
}
}
src/main/java/cn/quantgroup/xyqb/repository/IUserRepository.java
View file @
30485d11
...
@@ -9,6 +9,8 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -9,6 +9,8 @@ import org.springframework.transaction.annotation.Transactional;
import
java.util.List
;
import
java.util.List
;
import
static
org
.
springframework
.
transaction
.
annotation
.
Propagation
.
MANDATORY
;
/**
/**
* Created by Miraculous on 15/7/4.
* Created by Miraculous on 15/7/4.
*/
*/
...
@@ -30,4 +32,9 @@ public interface IUserRepository extends JpaRepository<User, Long>, JpaSpecifica
...
@@ -30,4 +32,9 @@ public interface IUserRepository extends JpaRepository<User, Long>, JpaSpecifica
@Query
(
value
=
"update user set enable=?1 where phone_no=?2"
,
nativeQuery
=
true
)
@Query
(
value
=
"update user set enable=?1 where phone_no=?2"
,
nativeQuery
=
true
)
int
forbiddenUser
(
Boolean
enable
,
String
phoneNo
);
int
forbiddenUser
(
Boolean
enable
,
String
phoneNo
);
@Transactional
(
propagation
=
MANDATORY
)
@Modifying
@Query
(
value
=
"update user set phone_no=?3 where id=?1 and phone_no=?2"
,
nativeQuery
=
true
)
int
resetAccount
(
Long
userId
,
String
account
,
String
phoneNo
);
}
}
src/main/java/cn/quantgroup/xyqb/service/user/IUserService.java
View file @
30485d11
...
@@ -18,6 +18,17 @@ public interface IUserService {
...
@@ -18,6 +18,17 @@ public interface IUserService {
boolean
resetPassword
(
String
phoneNo
,
String
password
);
boolean
resetPassword
(
String
phoneNo
,
String
password
);
/**
* 重置账号
* 注意:此操作会级联更新UserDetail的phoneNo
*
* @param userId - 用户主键
* @param account - 旧账号
* @param phoneNo - 新账号
* @return
*/
boolean
resetAccount
(
Long
userId
,
String
account
,
String
phoneNo
);
User
findByPhoneInDb
(
String
phone
);
User
findByPhoneInDb
(
String
phone
);
User
findByUuidInDb
(
String
uuid
);
User
findByUuidInDb
(
String
uuid
);
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserDetailServiceImpl.java
View file @
30485d11
...
@@ -215,7 +215,7 @@ public class UserDetailServiceImpl implements IUserDetailService {
...
@@ -215,7 +215,7 @@ public class UserDetailServiceImpl implements IUserDetailService {
public
int
updateIdCard
(
String
name
,
String
idNo
,
String
phoneNo
)
{
public
int
updateIdCard
(
String
name
,
String
idNo
,
String
phoneNo
)
{
UserDetail
userDetail
=
userDetailRepository
.
findByPhoneNo
(
phoneNo
);
UserDetail
userDetail
=
userDetailRepository
.
findByPhoneNo
(
phoneNo
);
if
(
null
!=
userDetail
)
{
if
(
null
!=
userDetail
)
{
if
(
!
StringUtils
.
is
Blank
(
idNo
))
{
if
(
StringUtils
.
isNot
Blank
(
idNo
))
{
try
{
try
{
IdCardInfo
idCardInfo
=
idCardService
.
getIdCardInfo
(
idNo
);
IdCardInfo
idCardInfo
=
idCardService
.
getIdCardInfo
(
idNo
);
return
userDetailRepository
.
updateIdNoByPhoneNo
(
idCardInfo
.
getIdNo
(),
Optional
.
ofNullable
(
idCardInfo
.
getGender
()).
orElse
(
Gender
.
UNKNOWN
).
ordinal
(),
phoneNo
);
return
userDetailRepository
.
updateIdNoByPhoneNo
(
idCardInfo
.
getIdNo
(),
Optional
.
ofNullable
(
idCardInfo
.
getGender
()).
orElse
(
Gender
.
UNKNOWN
).
ordinal
(),
phoneNo
);
...
@@ -224,7 +224,7 @@ public class UserDetailServiceImpl implements IUserDetailService {
...
@@ -224,7 +224,7 @@ public class UserDetailServiceImpl implements IUserDetailService {
return
0
;
return
0
;
}
}
}
}
if
(
!
StringUtils
.
is
Blank
(
name
)
&&
ValidationUtil
.
validateChinese
(
name
))
{
if
(
StringUtils
.
isNot
Blank
(
name
)
&&
ValidationUtil
.
validateChinese
(
name
))
{
return
userDetailRepository
.
updateNameByPhoneNo
(
name
,
phoneNo
);
return
userDetailRepository
.
updateNameByPhoneNo
(
name
,
phoneNo
);
}
}
}
}
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
View file @
30485d11
...
@@ -2,15 +2,11 @@ package cn.quantgroup.xyqb.service.user.impl;
...
@@ -2,15 +2,11 @@ package cn.quantgroup.xyqb.service.user.impl;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.repository.IAddressRepository
;
import
cn.quantgroup.xyqb.repository.*
;
import
cn.quantgroup.xyqb.repository.IContactRepository
;
import
cn.quantgroup.xyqb.repository.IUserBtRegisterRepository
;
import
cn.quantgroup.xyqb.repository.IUserRepository
;
import
cn.quantgroup.xyqb.service.auth.IIdCardService
;
import
cn.quantgroup.xyqb.service.auth.IIdCardService
;
import
cn.quantgroup.xyqb.service.sms.ISmsService
;
import
cn.quantgroup.xyqb.service.sms.ISmsService
;
import
cn.quantgroup.xyqb.service.user.ILkbUserService
;
import
cn.quantgroup.xyqb.service.user.ILkbUserService
;
import
cn.quantgroup.xyqb.service.user.IUserBtRegisterService
;
import
cn.quantgroup.xyqb.service.user.IUserBtRegisterService
;
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.PasswordUtil
;
import
cn.quantgroup.xyqb.util.PasswordUtil
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
...
@@ -21,6 +17,7 @@ import org.springframework.cache.annotation.CacheEvict;
...
@@ -21,6 +17,7 @@ import org.springframework.cache.annotation.CacheEvict;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
...
@@ -64,7 +61,7 @@ public class UserServiceImpl implements IUserService {
...
@@ -64,7 +61,7 @@ public class UserServiceImpl implements IUserService {
private
IIdCardService
idCardService
;
private
IIdCardService
idCardService
;
@Autowired
@Autowired
private
IUserDetail
Service
userDetailRepository
;
private
IUserDetail
Repository
userDetailRepository
;
private
Long
BAITIAO_CHANNEL
=
222L
;
private
Long
BAITIAO_CHANNEL
=
222L
;
...
@@ -166,6 +163,21 @@ public class UserServiceImpl implements IUserService {
...
@@ -166,6 +163,21 @@ public class UserServiceImpl implements IUserService {
}
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@CacheEvict
(
value
=
"usercache"
,
key
=
"'xyqbuser' + #account"
,
cacheManager
=
"cacheManager"
)
public
boolean
resetAccount
(
Long
userId
,
String
account
,
String
phoneNo
){
int
rowUser
=
userRepository
.
resetAccount
(
userId
,
account
,
phoneNo
);
if
(
rowUser
!=
1
){
throw
new
RuntimeException
(
"重置账号失败!"
);
}
int
rowUserDetail
=
userDetailRepository
.
resetPhoneNo
(
userId
,
phoneNo
);
if
(
rowUserDetail
!=
1
){
throw
new
RuntimeException
(
"重置账号失败!"
);
}
return
true
;
}
@Override
@Override
public
List
<
User
>
findRegisterUserByTime
(
String
beginTime
,
String
endTime
)
{
public
List
<
User
>
findRegisterUserByTime
(
String
beginTime
,
String
endTime
)
{
return
userRepository
.
findRegisterUserByTime
(
beginTime
,
endTime
);
return
userRepository
.
findRegisterUserByTime
(
beginTime
,
endTime
);
...
...
src/main/java/cn/quantgroup/xyqb/util/IdcardValidator.java
View file @
30485d11
...
@@ -49,7 +49,7 @@ public class IdcardValidator {
...
@@ -49,7 +49,7 @@ public class IdcardValidator {
* 51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",
* 51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",
* 63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"}
* 63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"}
*/
*/
protected
String
codeAndCity
[][]
=
{
{
"11"
,
"北京"
},
{
"12"
,
"天津"
},
protected
final
static
String
codeAndCity
[][]
=
{
{
"11"
,
"北京"
},
{
"12"
,
"天津"
},
{
"13"
,
"河北"
},
{
"14"
,
"山西"
},
{
"15"
,
"内蒙古"
},
{
"21"
,
"辽宁"
},
{
"13"
,
"河北"
},
{
"14"
,
"山西"
},
{
"15"
,
"内蒙古"
},
{
"21"
,
"辽宁"
},
{
"22"
,
"吉林"
},
{
"23"
,
"黑龙江"
},
{
"31"
,
"上海"
},
{
"32"
,
"江苏"
},
{
"22"
,
"吉林"
},
{
"23"
,
"黑龙江"
},
{
"31"
,
"上海"
},
{
"32"
,
"江苏"
},
{
"33"
,
"浙江"
},
{
"34"
,
"安徽"
},
{
"35"
,
"福建"
},
{
"36"
,
"江西"
},
{
"33"
,
"浙江"
},
{
"34"
,
"安徽"
},
{
"35"
,
"福建"
},
{
"36"
,
"江西"
},
...
@@ -60,16 +60,16 @@ public class IdcardValidator {
...
@@ -60,16 +60,16 @@ public class IdcardValidator {
{
"65"
,
"新疆"
},
{
"71"
,
"台湾"
},
{
"81"
,
"香港"
},
{
"82"
,
"澳门"
},
{
"65"
,
"新疆"
},
{
"71"
,
"台湾"
},
{
"81"
,
"香港"
},
{
"82"
,
"澳门"
},
{
"91"
,
"国外"
}
};
{
"91"
,
"国外"
}
};
private
String
cityCode
[]
=
{
"11"
,
"12"
,
"13"
,
"14"
,
"15"
,
"21"
,
"22"
,
private
final
static
String
cityCode
[]
=
{
"11"
,
"12"
,
"13"
,
"14"
,
"15"
,
"21"
,
"22"
,
"23"
,
"31"
,
"32"
,
"33"
,
"34"
,
"35"
,
"36"
,
"37"
,
"41"
,
"42"
,
"43"
,
"23"
,
"31"
,
"32"
,
"33"
,
"34"
,
"35"
,
"36"
,
"37"
,
"41"
,
"42"
,
"43"
,
"44"
,
"45"
,
"46"
,
"50"
,
"51"
,
"52"
,
"53"
,
"54"
,
"61"
,
"62"
,
"63"
,
"44"
,
"45"
,
"46"
,
"50"
,
"51"
,
"52"
,
"53"
,
"54"
,
"61"
,
"62"
,
"63"
,
"64"
,
"65"
,
"71"
,
"81"
,
"82"
,
"91"
};
"64"
,
"65"
,
"71"
,
"81"
,
"82"
,
"91"
};
// 每位加权因子
// 每位加权因子
private
int
power
[]
=
{
7
,
9
,
10
,
5
,
8
,
4
,
2
,
1
,
6
,
3
,
7
,
9
,
10
,
5
,
8
,
4
,
2
};
private
final
static
int
power
[]
=
{
7
,
9
,
10
,
5
,
8
,
4
,
2
,
1
,
6
,
3
,
7
,
9
,
10
,
5
,
8
,
4
,
2
};
// 第18位校检码
// 第18位校检码
private
String
verifyCode
[]
=
{
"1"
,
"0"
,
"X"
,
"9"
,
"8"
,
"7"
,
"6"
,
"5"
,
private
final
static
String
verifyCode
[]
=
{
"1"
,
"0"
,
"X"
,
"9"
,
"8"
,
"7"
,
"6"
,
"5"
,
"4"
,
"3"
,
"2"
};
"4"
,
"3"
,
"2"
};
/**
/**
...
@@ -78,11 +78,11 @@ public class IdcardValidator {
...
@@ -78,11 +78,11 @@ public class IdcardValidator {
* @param idcard
* @param idcard
* @return
* @return
*/
*/
public
boolean
isValidatedAllIdcard
(
String
idcard
)
{
public
final
static
boolean
isValidatedAllIdcard
(
String
idcard
)
{
if
(
idcard
.
length
()
==
15
)
{
if
(
idcard
.
length
()
==
15
)
{
idcard
=
this
.
convertIdcarBy15bit
(
idcard
);
idcard
=
convertIdcarBy15bit
(
idcard
);
}
}
return
this
.
isValidate18Idcard
(
idcard
);
return
isValidate18Idcard
(
idcard
);
}
}
/**
/**
...
@@ -119,7 +119,7 @@ public class IdcardValidator {
...
@@ -119,7 +119,7 @@ public class IdcardValidator {
* @param idcard
* @param idcard
* @return
* @return
*/
*/
public
boolean
isValidate18Idcard
(
String
idcard
)
{
public
final
static
boolean
isValidate18Idcard
(
String
idcard
)
{
// 非18位为假
// 非18位为假
if
(
idcard
.
length
()
!=
18
)
{
if
(
idcard
.
length
()
!=
18
)
{
return
false
;
return
false
;
...
@@ -165,7 +165,7 @@ public class IdcardValidator {
...
@@ -165,7 +165,7 @@ public class IdcardValidator {
* @param idcard
* @param idcard
* @return
* @return
*/
*/
public
boolean
isValidate15Idcard
(
String
idcard
)
{
public
final
static
boolean
isValidate15Idcard
(
String
idcard
)
{
// 非15位为假
// 非15位为假
if
(
idcard
.
length
()
!=
15
)
{
if
(
idcard
.
length
()
!=
15
)
{
return
false
;
return
false
;
...
@@ -259,7 +259,7 @@ public class IdcardValidator {
...
@@ -259,7 +259,7 @@ public class IdcardValidator {
* @param idcard
* @param idcard
* @return
* @return
*/
*/
public
String
convertIdcarBy15bit
(
String
idcard
)
{
public
final
static
String
convertIdcarBy15bit
(
String
idcard
)
{
String
idcard17
=
null
;
String
idcard17
=
null
;
// 非15位身份证
// 非15位身份证
if
(
idcard
.
length
()
!=
15
)
{
if
(
idcard
.
length
()
!=
15
)
{
...
@@ -314,7 +314,7 @@ public class IdcardValidator {
...
@@ -314,7 +314,7 @@ public class IdcardValidator {
* @param idcard
* @param idcard
* @return
* @return
*/
*/
public
boolean
isIdcard
(
String
idcard
)
{
public
final
static
boolean
isIdcard
(
String
idcard
)
{
return
idcard
==
null
||
""
.
equals
(
idcard
)
?
false
:
Pattern
.
matches
(
return
idcard
==
null
||
""
.
equals
(
idcard
)
?
false
:
Pattern
.
matches
(
"(^\\d{15}$)|(\\d{17}(?:\\d|x|X)$)"
,
idcard
);
"(^\\d{15}$)|(\\d{17}(?:\\d|x|X)$)"
,
idcard
);
}
}
...
@@ -325,7 +325,7 @@ public class IdcardValidator {
...
@@ -325,7 +325,7 @@ public class IdcardValidator {
* @param idcard
* @param idcard
* @return
* @return
*/
*/
public
boolean
is15Idcard
(
String
idcard
)
{
public
final
static
boolean
is15Idcard
(
String
idcard
)
{
return
idcard
==
null
||
""
.
equals
(
idcard
)
?
false
:
Pattern
.
matches
(
return
idcard
==
null
||
""
.
equals
(
idcard
)
?
false
:
Pattern
.
matches
(
"^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$"
,
"^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$"
,
idcard
);
idcard
);
...
@@ -337,7 +337,7 @@ public class IdcardValidator {
...
@@ -337,7 +337,7 @@ public class IdcardValidator {
* @param idcard
* @param idcard
* @return
* @return
*/
*/
public
boolean
is18Idcard
(
String
idcard
)
{
public
final
static
boolean
is18Idcard
(
String
idcard
)
{
return
Pattern
return
Pattern
.
matches
(
.
matches
(
"^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([\\d|x|X]{1})$"
,
"^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([\\d|x|X]{1})$"
,
...
@@ -350,7 +350,7 @@ public class IdcardValidator {
...
@@ -350,7 +350,7 @@ public class IdcardValidator {
* @param str
* @param str
* @return
* @return
*/
*/
public
boolean
isDigital
(
String
str
)
{
public
final
static
boolean
isDigital
(
String
str
)
{
return
str
==
null
||
""
.
equals
(
str
)
?
false
:
str
.
matches
(
"^[0-9]*$"
);
return
str
==
null
||
""
.
equals
(
str
)
?
false
:
str
.
matches
(
"^[0-9]*$"
);
}
}
...
@@ -360,7 +360,7 @@ public class IdcardValidator {
...
@@ -360,7 +360,7 @@ public class IdcardValidator {
* @param bit
* @param bit
* @return
* @return
*/
*/
public
int
getPowerSum
(
int
[]
bit
)
{
public
final
static
int
getPowerSum
(
int
[]
bit
)
{
int
sum
=
0
;
int
sum
=
0
;
...
@@ -385,7 +385,7 @@ public class IdcardValidator {
...
@@ -385,7 +385,7 @@ public class IdcardValidator {
* @param sum17
* @param sum17
* @return 校验位
* @return 校验位
*/
*/
public
String
getCheckCodeBySum
(
int
sum17
)
{
public
final
static
String
getCheckCodeBySum
(
int
sum17
)
{
String
checkCode
=
null
;
String
checkCode
=
null
;
switch
(
sum17
%
11
)
{
switch
(
sum17
%
11
)
{
case
10
:
case
10
:
...
@@ -432,7 +432,7 @@ public class IdcardValidator {
...
@@ -432,7 +432,7 @@ public class IdcardValidator {
* @return
* @return
* @throws NumberFormatException
* @throws NumberFormatException
*/
*/
public
int
[]
converCharToInt
(
char
[]
c
)
throws
NumberFormatException
{
public
final
static
int
[]
converCharToInt
(
char
[]
c
)
throws
NumberFormatException
{
int
[]
a
=
new
int
[
c
.
length
];
int
[]
a
=
new
int
[
c
.
length
];
int
k
=
0
;
int
k
=
0
;
for
(
char
temp
:
c
)
{
for
(
char
temp
:
c
)
{
...
...
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