Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
P
pica-cloud-account
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
Close sidebar
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
com.pica.cloud.account
pica-cloud-account
提交
a94fcbb7
提交
a94fcbb7
编写于
1月 14, 2020
作者:
hujun
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev-20200109-smscode' into 'release'
Dev 20200109 smscode 合并当前分支到release分支 See merge request
!10
上级
f7935d22
e4ba1910
流水线
#20752
已失败 于阶段
in 0 second
变更
14
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
172 行增加
和
161 行删除
+172
-161
Test.java
...main/java/com/pica/cloud/account/account/server/Test.java
+24
-6
AccountController.java
.../account/account/server/controller/AccountController.java
+4
-2
AutoCodeController.java
...account/account/server/controller/AutoCodeController.java
+19
-2
LoginController.java
...ud/account/account/server/controller/LoginController.java
+0
-1
RegisterController.java
...account/account/server/controller/RegisterController.java
+2
-1
AccountRepeatDataJob.java
...loud/account/account/server/job/AccountRepeatDataJob.java
+0
-3
DoctorLogHandler.java
...ca/cloud/account/account/server/job/DoctorLogHandler.java
+15
-15
DoctorRepeatDataJob.java
...cloud/account/account/server/job/DoctorRepeatDataJob.java
+17
-17
HospitalLogHandler.java
.../cloud/account/account/server/job/HospitalLogHandler.java
+15
-15
LoginServiceImpl.java
...account/account/server/service/impl/LoginServiceImpl.java
+4
-0
RegisterServiceImpl.java
...ount/account/server/service/impl/RegisterServiceImpl.java
+23
-33
AESUtil.java
...a/com/pica/cloud/account/account/server/util/AESUtil.java
+3
-3
AccountUtils.java
.../pica/cloud/account/account/server/util/AccountUtils.java
+19
-63
RegisterCodeKeyUtils.java
...oud/account/account/server/util/RegisterCodeKeyUtils.java
+27
-0
未找到文件。
server/src/main/java/com/pica/cloud/account/account/server/Test.java
浏览文件 @
a94fcbb7
...
@@ -106,8 +106,8 @@ public class Test {
...
@@ -106,8 +106,8 @@ public class Test {
System
.
out
.
println
(
"--------------------获取验证码接口-------------"
);
System
.
out
.
println
(
"--------------------获取验证码接口-------------"
);
BaseRequest
authCode
=
new
BaseRequest
();
BaseRequest
authCode
=
new
BaseRequest
();
authCode
.
setFlag
(
4
);
authCode
.
setFlag
(
1
);
authCode
.
setMobile
(
"1302411
26
88"
);
authCode
.
setMobile
(
"1302411
99
88"
);
String
authCodeStr
=
JSONObject
.
toJSONString
(
authCode
);
String
authCodeStr
=
JSONObject
.
toJSONString
(
authCode
);
System
.
out
.
println
(
authCodeStr
);
System
.
out
.
println
(
authCodeStr
);
String
contentResult2
=
AESUtil
.
aesEncrypt
(
authCodeStr
,
"YCPQPx4qpQjEjDea"
);
String
contentResult2
=
AESUtil
.
aesEncrypt
(
authCodeStr
,
"YCPQPx4qpQjEjDea"
);
...
@@ -121,9 +121,9 @@ public class Test {
...
@@ -121,9 +121,9 @@ public class Test {
//获取注册参数
//获取注册参数
BaseRequest
register
=
null
;
BaseRequest
register
=
null
;
register
=
new
BaseRequest
();
register
=
new
BaseRequest
();
register
.
setMobile
(
"1302411
26
88"
);
register
.
setMobile
(
"1302411
99
88"
);
register
.
setPassword
(
"D0DCBF0D12A6B1E7FBFA2CE5848F3EFF"
);
register
.
setPassword
(
"D0DCBF0D12A6B1E7FBFA2CE5848F3EFF"
);
register
.
setAuthCode
(
"
11305
8"
);
register
.
setAuthCode
(
"
86857
8"
);
String
registerString3
=
JSONObject
.
toJSONString
(
register
);
String
registerString3
=
JSONObject
.
toJSONString
(
register
);
String
contentResult3
=
AESUtil
.
aesEncrypt
(
registerString3
,
"YCPQPx4qpQjEjDea"
);
String
contentResult3
=
AESUtil
.
aesEncrypt
(
registerString3
,
"YCPQPx4qpQjEjDea"
);
String
keyResult3
=
RSAUtil
.
encrypt
(
"YCPQPx4qpQjEjDea"
,
publicKey
);
String
keyResult3
=
RSAUtil
.
encrypt
(
"YCPQPx4qpQjEjDea"
,
publicKey
);
...
@@ -136,8 +136,8 @@ public class Test {
...
@@ -136,8 +136,8 @@ public class Test {
BaseRequest
loginRegister
=
null
;
BaseRequest
loginRegister
=
null
;
loginRegister
=
new
BaseRequest
();
loginRegister
=
new
BaseRequest
();
loginRegister
.
setMobile
(
"13024112
081
"
);
loginRegister
.
setMobile
(
"13024112
588
"
);
loginRegister
.
setAuthCode
(
"
163173
"
);
loginRegister
.
setAuthCode
(
"
529196
"
);
String
registerString4
=
JSONObject
.
toJSONString
(
loginRegister
);
String
registerString4
=
JSONObject
.
toJSONString
(
loginRegister
);
//AES CONTENT
//AES CONTENT
String
contentResult4
=
AESUtil
.
aesEncrypt
(
registerString4
,
"YCPQPx4qpQjEjDea"
);
String
contentResult4
=
AESUtil
.
aesEncrypt
(
registerString4
,
"YCPQPx4qpQjEjDea"
);
...
@@ -196,6 +196,24 @@ public class Test {
...
@@ -196,6 +196,24 @@ public class Test {
changeMobileEntity
.
setContent
(
changeMobileContent
);
changeMobileEntity
.
setContent
(
changeMobileContent
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
changeMobileEntity
));
System
.
out
.
println
(
JSONObject
.
toJSONString
(
changeMobileEntity
));
System
.
out
.
println
(
"---------------------------------------------------------------"
);
BaseRequest
changeMobileu
=
new
BaseRequest
();
changeMobileu
.
setMobile
(
"13024112588"
);
changeMobileu
.
setAuthCode
(
"871756"
);
changeMobileu
.
setUnionId
(
"o3EP_wNH2g4FGcUNByXJIbQyUVPI"
);
changeMobileu
.
setFlag
(
2
);
String
string1u
=
JSONObject
.
toJSONString
(
changeMobileu
);
System
.
out
.
println
(
string1u
);
String
changeMobileContentu
=
AESUtil
.
aesEncrypt
(
string1u
,
"YCPQPx4qpQjEjDea"
);
String
changeMobileKeyu
=
RSAUtil
.
encrypt
(
"YCPQPx4qpQjEjDea"
,
publicKey
);
EncryptEntity
changeMobileEntityu
=
new
EncryptEntity
();
changeMobileEntityu
.
setKey
(
changeMobileKeyu
);
changeMobileEntityu
.
setContent
(
changeMobileContentu
);
System
.
out
.
println
(
JSONObject
.
toJSONString
(
changeMobileEntityu
));
}
}
...
...
server/src/main/java/com/pica/cloud/account/account/server/controller/AccountController.java
浏览文件 @
a94fcbb7
...
@@ -9,6 +9,7 @@ import com.pica.cloud.account.account.server.req.AccountReq;
...
@@ -9,6 +9,7 @@ import com.pica.cloud.account.account.server.req.AccountReq;
import
com.pica.cloud.account.account.server.req.BaseRequest
;
import
com.pica.cloud.account.account.server.req.BaseRequest
;
import
com.pica.cloud.account.account.server.service.AccountService
;
import
com.pica.cloud.account.account.server.service.AccountService
;
import
com.pica.cloud.account.account.server.service.CaptchaService
;
import
com.pica.cloud.account.account.server.service.CaptchaService
;
import
com.pica.cloud.account.account.server.util.AccountUtils
;
import
com.pica.cloud.account.account.server.util.CryptoUtil
;
import
com.pica.cloud.account.account.server.util.CryptoUtil
;
import
com.pica.cloud.foundation.encryption.common.constants.EncryptConstants
;
import
com.pica.cloud.foundation.encryption.common.constants.EncryptConstants
;
import
com.pica.cloud.foundation.encryption.util.EncryptUtils
;
import
com.pica.cloud.foundation.encryption.util.EncryptUtils
;
...
@@ -53,8 +54,9 @@ public class AccountController extends AccountBaseController {
...
@@ -53,8 +54,9 @@ public class AccountController extends AccountBaseController {
@Autowired
@Autowired
private
CaptchaService
captchaService
;
private
CaptchaService
captchaService
;
@Autowired
@Autowired
private
ICacheClient
redisClient
;
private
ICacheClient
redisClient
;
@Autowired
private
AccountUtils
accountUtils
;
@GetMapping
(
"/test"
)
@GetMapping
(
"/test"
)
public
String
test
()
{
public
String
test
()
{
...
@@ -159,7 +161,7 @@ public class AccountController extends AccountBaseController {
...
@@ -159,7 +161,7 @@ public class AccountController extends AccountBaseController {
// @PostMapping("/register")
// @PostMapping("/register")
public
PicaResponse
<
LoginResult
>
register
(
@RequestBody
AccountReq
req
)
{
public
PicaResponse
<
LoginResult
>
register
(
@RequestBody
AccountReq
req
)
{
this
.
checkMobilePhone
(
req
.
getMobilePhone
());
this
.
checkMobilePhone
(
req
.
getMobilePhone
());
this
.
checkAuthCode
(
req
);
accountUtils
.
checkRegisterMobilePhoneAndAuthCode
(
req
.
getMobilePhone
(),
req
.
getFlag
(),
req
.
getAuthCode
()
);
String
deviceType
=
super
.
getDeviceInfo
(
"device_type"
);
//1:pc 2:android 3:ios
String
deviceType
=
super
.
getDeviceInfo
(
"device_type"
);
//1:pc 2:android 3:ios
Account
account
=
new
Account
();
Account
account
=
new
Account
();
account
.
setMobilePhone
(
EncryptUtils
.
encryptContent
(
req
.
getMobilePhone
(),
EncryptConstants
.
ENCRYPT_TYPE_MOBILE
));
account
.
setMobilePhone
(
EncryptUtils
.
encryptContent
(
req
.
getMobilePhone
(),
EncryptConstants
.
ENCRYPT_TYPE_MOBILE
));
...
...
server/src/main/java/com/pica/cloud/account/account/server/controller/AutoCodeController.java
浏览文件 @
a94fcbb7
...
@@ -15,6 +15,7 @@ import com.pica.cloud.account.account.server.service.CaptchaService;
...
@@ -15,6 +15,7 @@ import com.pica.cloud.account.account.server.service.CaptchaService;
import
com.pica.cloud.account.account.server.util.AESUtil
;
import
com.pica.cloud.account.account.server.util.AESUtil
;
import
com.pica.cloud.account.account.server.util.AccountUtils
;
import
com.pica.cloud.account.account.server.util.AccountUtils
;
import
com.pica.cloud.account.account.server.util.CryptoUtil
;
import
com.pica.cloud.account.account.server.util.CryptoUtil
;
import
com.pica.cloud.account.account.server.util.RegisterCodeKeyUtils
;
import
com.pica.cloud.foundation.entity.PicaException
;
import
com.pica.cloud.foundation.entity.PicaException
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.pica.cloud.foundation.entity.PicaResultCode
;
import
com.pica.cloud.foundation.entity.PicaResultCode
;
...
@@ -150,9 +151,14 @@ public class AutoCodeController extends AccountBaseController {
...
@@ -150,9 +151,14 @@ public class AutoCodeController extends AccountBaseController {
String
message
=
"您的验证码是"
+
authCode
+
",在10分钟内有效。如非本人操作,请忽略本短信!"
;
String
message
=
"您的验证码是"
+
authCode
+
",在10分钟内有效。如非本人操作,请忽略本短信!"
;
Integer
accountIdByMobilePhone
=
accountService
.
getAccountIdByMobilePhone
(
mobilePhone
);
Integer
accountIdByMobilePhone
=
accountService
.
getAccountIdByMobilePhone
(
mobilePhone
);
long
senderId
=
accountIdByMobilePhone
==
null
?
0L
:
accountIdByMobilePhone
;
long
senderId
=
accountIdByMobilePhone
==
null
?
0L
:
accountIdByMobilePhone
;
cacheClient
.
set
(
this
.
getAuthCodeKey
(
mobilePhone
,
flag
.
toString
()),
authCode
,
600
);
String
authCodeKey
=
getAuthCodeKey
(
mobilePhone
,
flag
.
toString
());
logger
.
info
(
"验证码缓存信息----->:"
+
this
.
getAuthCodeKey
(
mobilePhone
,
flag
.
toString
()));
boolean
set
=
cacheClient
.
set
(
authCodeKey
,
authCode
,
600
);
logger
.
info
(
cacheClient
.
get
(
authCodeKey
));
logger
.
info
(
"验证码缓存是否成功----->:"
+
set
);
logger
.
info
(
"验证码缓存信息----->:"
+
authCodeKey
);
cacheClient
.
set
(
authCodeKeySecure
,
System
.
currentTimeMillis
(),
60
);
cacheClient
.
set
(
authCodeKeySecure
,
System
.
currentTimeMillis
(),
60
);
//处理验证码原子性的问题
cacheClient
.
set
(
RegisterCodeKeyUtils
.
getRegisterKey
(
mobilePhone
,
authCode
),
100
,
600
);
super
.
sendMobileMessage
(
mobilePhone
,
message
,
senderId
);
super
.
sendMobileMessage
(
mobilePhone
,
message
,
senderId
);
}
}
...
@@ -167,4 +173,15 @@ public class AutoCodeController extends AccountBaseController {
...
@@ -167,4 +173,15 @@ public class AutoCodeController extends AccountBaseController {
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"请输入正确的手机号"
);
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"请输入正确的手机号"
);
}
}
}
}
@ApiOperation
(
"微信获取验证码"
)
@PostMapping
(
value
=
"/authCode/get"
)
public
PicaResponse
getAuthCode
(){
String
cacheCode
=
cacheClient
.
get
(
"authCode-2-j1VrU5MSc1uuZaEa82ZKfQ=="
);
return
PicaResponse
.
toResponse
(
cacheCode
);
}
}
}
server/src/main/java/com/pica/cloud/account/account/server/controller/LoginController.java
浏览文件 @
a94fcbb7
...
@@ -84,7 +84,6 @@ public class LoginController extends AccountBaseController {
...
@@ -84,7 +84,6 @@ public class LoginController extends AccountBaseController {
@PostMapping
(
value
=
"/login-register"
)
@PostMapping
(
value
=
"/login-register"
)
public
PicaResponse
<
LoginResult
>
loginAndRegister
(
@RequestBody
EncryptEntity
entity
)
throws
Exception
{
public
PicaResponse
<
LoginResult
>
loginAndRegister
(
@RequestBody
EncryptEntity
entity
)
throws
Exception
{
BaseRequest
request
=
CryptoUtil
.
decrypt
(
entity
,
BaseRequest
.
class
);
BaseRequest
request
=
CryptoUtil
.
decrypt
(
entity
,
BaseRequest
.
class
);
accountUtils
.
checkMobilePhoneAndAuthCode
(
request
.
getMobile
(),
AccountTypeEnum
.
SYSCODE_TYPE_LOGIN
.
getCode
()
+
""
,
request
.
getAuthCode
());
request
.
setProductType
(
super
.
getProductType
());
request
.
setProductType
(
super
.
getProductType
());
Integer
sourceType
=
super
.
getSourceType
();
Integer
sourceType
=
super
.
getSourceType
();
request
.
setSourceType
(
sourceType
);
request
.
setSourceType
(
sourceType
);
...
...
server/src/main/java/com/pica/cloud/account/account/server/controller/RegisterController.java
浏览文件 @
a94fcbb7
...
@@ -41,7 +41,8 @@ public class RegisterController extends AccountBaseController {
...
@@ -41,7 +41,8 @@ public class RegisterController extends AccountBaseController {
//接口幂等性处理(redis中没有就进行注册逻辑,如果已经存在,就不处理)
//接口幂等性处理(redis中没有就进行注册逻辑,如果已经存在,就不处理)
String
authCode
=
request
.
getAuthCode
();
String
authCode
=
request
.
getAuthCode
();
String
flag
=
AccountTypeEnum
.
SYSCODE_TYPE_REGISTER
.
getCode
()
+
""
;
String
flag
=
AccountTypeEnum
.
SYSCODE_TYPE_REGISTER
.
getCode
()
+
""
;
accountUtils
.
checkMobilePhoneAndAuthCode
(
mobile
,
flag
,
authCode
);
//验证码验证的原子操作
accountUtils
.
checkRegisterMobilePhoneAndAuthCode
(
mobile
,
flag
,
authCode
);
accountUtils
.
checkPassword
(
request
.
getPassword
());
accountUtils
.
checkPassword
(
request
.
getPassword
());
LoginResult
result
=
null
;
LoginResult
result
=
null
;
request
.
setFlag
(
AccountTypeEnum
.
SYSCODE_TYPE_REGISTER
.
getCode
());
request
.
setFlag
(
AccountTypeEnum
.
SYSCODE_TYPE_REGISTER
.
getCode
());
...
...
server/src/main/java/com/pica/cloud/account/account/server/job/AccountRepeatDataJob.java
浏览文件 @
a94fcbb7
...
@@ -25,8 +25,5 @@ public class AccountRepeatDataJob extends IJobHandler {
...
@@ -25,8 +25,5 @@ public class AccountRepeatDataJob extends IJobHandler {
accountInfoDetailMapper
.
processAccountRepeatData
();
accountInfoDetailMapper
.
processAccountRepeatData
();
XxlJobLogger
.
log
(
"repeat date-----"
);
XxlJobLogger
.
log
(
"repeat date-----"
);
return
SUCCESS
;
return
SUCCESS
;
}
}
}
}
server/src/main/java/com/pica/cloud/account/account/server/job/DoctorLogHandler.java
浏览文件 @
a94fcbb7
...
@@ -13,18 +13,18 @@ import org.springframework.stereotype.Component;
...
@@ -13,18 +13,18 @@ import org.springframework.stereotype.Component;
* author:crs
* author:crs
* Description:记录doctor修改记录日志
* Description:记录doctor修改记录日志
*/
*/
@JobHandler
(
value
=
"DoctorLogHandler"
)
//
@JobHandler(value = "DoctorLogHandler")
@Component
//
@Component
public
class
DoctorLogHandler
extends
IJobHandler
{
//
public class DoctorLogHandler extends IJobHandler {
//
@Autowired
//
@Autowired
private
DoctorMapper
doctorMapper
;
//
private DoctorMapper doctorMapper;
//
@Override
//
@Override
public
ReturnT
<
String
>
execute
(
String
s
)
throws
Exception
{
//
public ReturnT<String> execute(String s) throws Exception {
XxlJobLogger
.
log
(
"doctorLogRecord start-----"
);
//
XxlJobLogger.log("doctorLogRecord start-----");
Integer
rows
=
doctorMapper
.
updateDoctorModifyRecord
();
//
Integer rows = doctorMapper.updateDoctorModifyRecord();
XxlJobLogger
.
log
(
"doctorLogRecord end-----"
+
rows
);
//
XxlJobLogger.log("doctorLogRecord end-----"+rows);
return
SUCCESS
;
//
return SUCCESS;
}
//
}
}
//
}
server/src/main/java/com/pica/cloud/account/account/server/job/DoctorRepeatDataJob.java
浏览文件 @
a94fcbb7
//
package com.pica.cloud.account.account.server.job;
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
job
;
//
//
import com.pica.cloud.account.account.server.mapper.DoctorMapper;
import
com.pica.cloud.account.account.server.mapper.DoctorMapper
;
//
import com.pica.cloud.foundation.redis.ICacheClient;
import
com.pica.cloud.foundation.redis.ICacheClient
;
//
import org.slf4j.Logger;
import
org.slf4j.Logger
;
//
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.Qualifier;
import
org.springframework.beans.factory.annotation.Qualifier
;
//
//
import org.springframework.scheduling.annotation.Scheduled;
import
org.springframework.scheduling.annotation.Scheduled
;
//
import org.springframework.stereotype.Component;
import
org.springframework.stereotype.Component
;
//
/
//
**
/**
//
* Created on 2019/10/29 15:37
* Created on 2019/10/29 15:37
//
* author:crs
* author:crs
//
* Description:doctor表重复记录处理
* Description:doctor表重复记录处理
//
*/
*/
//@Component
//@Component
//public class DoctorRepeatDataJob {
//public class DoctorRepeatDataJob {
// private final String KEY = "cacheProcessDoctorRepeat";
// private final String KEY = "cacheProcessDoctorRepeat";
...
...
server/src/main/java/com/pica/cloud/account/account/server/job/HospitalLogHandler.java
浏览文件 @
a94fcbb7
...
@@ -13,18 +13,18 @@ import org.springframework.stereotype.Component;
...
@@ -13,18 +13,18 @@ import org.springframework.stereotype.Component;
* author:crs
* author:crs
* Description:记录doctor修改记录日志
* Description:记录doctor修改记录日志
*/
*/
@JobHandler
(
value
=
"HospitalLogHandler"
)
//
@JobHandler(value = "HospitalLogHandler")
@Component
//
@Component
public
class
HospitalLogHandler
extends
IJobHandler
{
//
public class HospitalLogHandler extends IJobHandler {
//
@Autowired
//
@Autowired
private
HospitalMapper
hospitalMapper
;
//
private HospitalMapper hospitalMapper;
//
@Override
//
@Override
public
ReturnT
<
String
>
execute
(
String
s
)
throws
Exception
{
//
public ReturnT<String> execute(String s) throws Exception {
XxlJobLogger
.
log
(
"hospitalLogRecord start-----"
);
//
XxlJobLogger.log("hospitalLogRecord start-----");
Integer
rows
=
hospitalMapper
.
updateDoctorModifyRecord
();
//
Integer rows = hospitalMapper.updateDoctorModifyRecord();
XxlJobLogger
.
log
(
"hospitalLogRecord end-----"
+
rows
);
//
XxlJobLogger.log("hospitalLogRecord end-----"+rows);
return
SUCCESS
;
//
return SUCCESS;
}
//
}
}
//
}
server/src/main/java/com/pica/cloud/account/account/server/service/impl/LoginServiceImpl.java
浏览文件 @
a94fcbb7
...
@@ -151,8 +151,12 @@ public class LoginServiceImpl implements LoginService {
...
@@ -151,8 +151,12 @@ public class LoginServiceImpl implements LoginService {
String
mobile
=
baseRequest
.
getMobile
();
String
mobile
=
baseRequest
.
getMobile
();
AccountInfoEntity
accountInfoEntity
=
accountInfoDetailMapper
.
selectByMobile
(
AESUtil
.
encryptV0
(
mobile
));
AccountInfoEntity
accountInfoEntity
=
accountInfoDetailMapper
.
selectByMobile
(
AESUtil
.
encryptV0
(
mobile
));
if
(
accountInfoEntity
==
null
)
{
if
(
accountInfoEntity
==
null
)
{
//说明是注册功能
accountUtils
.
checkRegisterMobilePhoneAndAuthCode
(
baseRequest
.
getMobile
(),
baseRequest
.
getFlag
()+
""
,
baseRequest
.
getAuthCode
());
return
registerService
.
register
(
baseRequest
);
return
registerService
.
register
(
baseRequest
);
}
else
{
}
else
{
//登录功能
accountUtils
.
checkMobilePhoneAndAuthCode
(
baseRequest
.
getMobile
(),
AccountTypeEnum
.
SYSCODE_TYPE_LOGIN
.
getCode
()
+
""
,
baseRequest
.
getAuthCode
());
return
processLogin
(
baseRequest
,
accountInfoEntity
.
getId
(),
AccountTypeEnum
.
LOGIN_CODE
.
getCode
());
return
processLogin
(
baseRequest
,
accountInfoEntity
.
getId
(),
AccountTypeEnum
.
LOGIN_CODE
.
getCode
());
}
}
}
}
...
...
server/src/main/java/com/pica/cloud/account/account/server/service/impl/RegisterServiceImpl.java
浏览文件 @
a94fcbb7
...
@@ -111,46 +111,35 @@ public class RegisterServiceImpl implements RegisterService {
...
@@ -111,46 +111,35 @@ public class RegisterServiceImpl implements RegisterService {
accountInfoDetailMapper
.
insertSelective
(
accountInfo
);
accountInfoDetailMapper
.
insertSelective
(
accountInfo
);
Integer
acctId
=
accountInfo
.
getId
();
Integer
acctId
=
accountInfo
.
getId
();
accountInfoDetailMapper
.
updateCreateInfo
(
acctId
);
accountInfoDetailMapper
.
updateCreateInfo
(
acctId
);
if
(
productType
==
AccountTypeEnum
.
PRODUCT_TYPE_HEALTH
.
getCode
())
{
AccountPatientInfoEntity
accountPatientInfoEntity
=
new
AccountPatientInfoEntity
();
accountPatientInfoEntity
.
setAcctId
(
acctId
);
accountPatientInfoEntity
.
setDeleteFlag
(
1
);
accountPatientInfoEntity
.
setCreateId
(
acctId
);
accountPatientInfoEntity
.
setModifyId
(
acctId
);
accountPatientInfoEntity
.
setCreateTime
(
currentTime
);
accountPatientInfoEntity
.
setModifyTime
(
currentTime
);
accountUserInfoMapper
.
insertSelective
(
accountPatientInfoEntity
);
}
else
{
Account
account
=
new
Account
();
account
.
setAcctId
(
acctId
);
account
.
setMobilePhone
(
mobileEncrypt
);
account
.
setDeleteFlag
(
1
);
account
.
setCreatId
(
0L
);
account
.
setModifyId
(
0L
);
account
.
setCreatTime
(
currentTime
);
account
.
setModifyTime
(
currentTime
);
account
.
setFirstLoginTime
(
currentTime
);
account
.
setLastLoginTime
(
currentTime
);
account
.
setRegisterSource
(
sourceType
);
account
.
setPassword
(
password
);
if
(!
StringUtils
.
isBlank
(
password
)){
account
.
setEntireFlag
(
3
);
}
accountMapper
.
insertSelective
(
account
);
}
Long
userId
=
accountUtils
.
getUserIdByAcctId
(
productType
,
acctId
);
Account
account
=
new
Account
();
Account
account
=
new
Account
();
account
.
setId
(
userId
);
account
.
setAcctId
(
acctId
);
account
.
setAcctId
(
acctId
);
account
.
setMobilePhone
(
mobileEncrypt
);
account
.
setDeleteFlag
(
1
);
account
.
setCreatId
(
0L
);
account
.
setModifyId
(
0L
);
account
.
setCreatTime
(
currentTime
);
account
.
setCreatTime
(
currentTime
);
account
.
setMobilePhone
(
mobile
);
account
.
setModifyTime
(
currentTime
);
account
.
setFirstLoginTime
(
currentTime
);
account
.
setLastLoginTime
(
currentTime
);
account
.
setRegisterSource
(
sourceType
);
account
.
setRegisterSource
(
sourceType
);
String
newToken
=
tokenUtils
.
generateToken
(
account
);
account
.
setPassword
(
password
);
if
(!
StringUtils
.
isBlank
(
password
))
{
account
.
setEntireFlag
(
3
);
}
accountMapper
.
insertSelective
(
account
);
Long
userId
=
account
.
getId
();
Account
accountToken
=
new
Account
();
accountToken
.
setId
(
userId
);
accountToken
.
setAcctId
(
acctId
);
accountToken
.
setCreatTime
(
currentTime
);
accountToken
.
setMobilePhone
(
mobile
);
accountToken
.
setRegisterSource
(
sourceType
);
String
newToken
=
tokenUtils
.
generateToken
(
accountToken
);
LoginResult
result
=
new
LoginResult
();
LoginResult
result
=
new
LoginResult
();
result
.
setToken
(
newToken
);
result
.
setToken
(
newToken
);
result
.
setUserId
(
userId
);
result
.
setUserId
(
userId
);
result
.
setEntireFlag
(
1
);
result
.
setEntireFlag
(
1
);
result
.
setDoctorId
(
EncryptUtils
.
encryptContent
(
userId
+
""
,
EncryptConstants
.
ENCRYPT_TYPE_ID
));
result
.
setDoctorId
(
EncryptUtils
.
encryptContent
(
userId
+
""
,
EncryptConstants
.
ENCRYPT_TYPE_ID
));
result
.
setMobile
(
mobile
);
result
.
setMobile
(
mobile
);
/* ByteArrayOutputStream bos = new ByteArrayOutputStream();
/* ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
DataOutputStream dos = new DataOutputStream(bos);
...
@@ -179,12 +168,13 @@ public class RegisterServiceImpl implements RegisterService {
...
@@ -179,12 +168,13 @@ public class RegisterServiceImpl implements RegisterService {
throw
new
AccountException
(
AccountExceptionEnum
.
PICA_ALREADY_REGISTER
);
throw
new
AccountException
(
AccountExceptionEnum
.
PICA_ALREADY_REGISTER
);
}
}
}
else
{
}
else
{
throw
new
AccountException
(
AccountExceptionEnum
.
PICA_ALREADY_REGISTER
);
throw
new
AccountException
(
AccountExceptionEnum
.
PICA_ALREADY_REGISTER
);
}
}
}
}
/**
/**
* 异步处理用户角色
* 异步处理用户角色
*
* @param userId
* @param userId
*/
*/
private
void
processRoleMap
(
Long
userId
)
{
private
void
processRoleMap
(
Long
userId
)
{
...
...
server/src/main/java/com/pica/cloud/account/account/server/util/AESUtil.java
浏览文件 @
a94fcbb7
...
@@ -194,10 +194,10 @@ public class AESUtil {
...
@@ -194,10 +194,10 @@ public class AESUtil {
// System.out.println("解密后:" + decrypt);
// System.out.println("解密后:" + decrypt);
//请求参数解密处理
//请求参数解密处理
String
key
=
"a
PzpkXKhX0xsgwG0L7uOiz47fKQKKW1pzzIyx9wRSoCtm4vux1+ctjKzQ77jb+Vvt4zB/z0wr7U5nszk7kXLKQR4A6nU5nt8O44CHjCHUU0dWbpPyd2TKFdZ58ZyKLsk1+Xc4wJ1HB0FQjxJefWvo5ioFYLasOpxSbKU7oHqXq4
="
;
String
key
=
"a
m1pnysCRlz80Rl/eTDj/UE/Pe8zkxb2yP73jvrUWEk3x5/lK9hi104MSmsKbl45cPzJfJXBxO+VeItkA63ZqfaUNA0ezdMd7Ord7rGqvWK+4RqAm1T3Qo3lw/5bT0GwgWMWZBrDr30NHCYLmjg6vwVbv3YCEewwQK+rL7bUXu0
="
;
String
decrypt
=
RSAUtil
.
decrypt
(
key
,
pr
ocPr
ivateKey
);
String
decrypt
=
RSAUtil
.
decrypt
(
key
,
privateKey
);
System
.
out
.
println
(
decrypt
);
System
.
out
.
println
(
decrypt
);
String
content
=
"
x/119w4nmos1xMG1DFNzBDeUP7BmyGViwXB66UCCk2HaCoJWhNg6qL1WoDMLGkiMJni8GV8fzEpd+1h9z4LA99wEkn47rbK6+MLaGkMIv+QmXzMLxThpLJNxadb2ltRyKgz5wERoFB/AH/xxgRn8kw==
"
;
String
content
=
"
d9eKA7DGhNx7295N0g82rqzaUOeAvBeuR2gXtOX3Y+VV3ei+zW0BQn9moQgN4mRT8XIzq3x2n3qiqCuOzcDvrlGC0kIcUClM0gt8xDaBw+haVpMAw/7R4FgWNPeVRL5k
"
;
String
result
=
AESUtil
.
aesDecrypt
(
content
,
decrypt
);
String
result
=
AESUtil
.
aesDecrypt
(
content
,
decrypt
);
System
.
out
.
println
(
result
);
System
.
out
.
println
(
result
);
...
...
server/src/main/java/com/pica/cloud/account/account/server/util/AccountUtils.java
浏览文件 @
a94fcbb7
...
@@ -2,9 +2,7 @@ package com.pica.cloud.account.account.server.util;
...
@@ -2,9 +2,7 @@ package com.pica.cloud.account.account.server.util;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.pica.cloud.account.account.server.controller.AccountController
;
import
com.pica.cloud.account.account.server.controller.AccountController
;
import
com.pica.cloud.account.account.server.entity.AccountPatientInfoEntity
;
import
com.pica.cloud.account.account.server.enums.AccountExceptionEnum
;
import
com.pica.cloud.account.account.server.enums.AccountExceptionEnum
;
import
com.pica.cloud.account.account.server.enums.AccountTypeEnum
;
import
com.pica.cloud.account.account.server.mapper.AccountPatientInfoMapper
;
import
com.pica.cloud.account.account.server.mapper.AccountPatientInfoMapper
;
import
com.pica.cloud.account.account.server.mapper.DoctorMapper
;
import
com.pica.cloud.account.account.server.mapper.DoctorMapper
;
import
com.pica.cloud.foundation.entity.PicaException
;
import
com.pica.cloud.foundation.entity.PicaException
;
...
@@ -15,7 +13,6 @@ import org.apache.commons.lang3.StringUtils;
...
@@ -15,7 +13,6 @@ import org.apache.commons.lang3.StringUtils;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
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.Qualifier
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
/**
/**
...
@@ -58,67 +55,45 @@ public class AccountUtils {
...
@@ -58,67 +55,45 @@ public class AccountUtils {
return
AUTH_CODE_PREFIX
+
flag
+
"-"
+
AESUtil
.
encryptV0
(
mobilePhone
);
return
AUTH_CODE_PREFIX
+
flag
+
"-"
+
AESUtil
.
encryptV0
(
mobilePhone
);
}
}
//校验验证码
//手机号和验证码校验
public
void
checkAuthCode
(
String
mobile
,
String
type
,
String
sysCode
)
{
public
void
checkMobilePhoneAndAuthCode
(
String
mobile
,
String
type
,
String
sysCode
)
{
if
(
StringUtils
.
isBlank
(
mobile
)
||
!
ValidateUtils
.
isMobile
(
mobile
))
{
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"请输入正确的手机号"
);
}
String
flag
=
org
.
apache
.
commons
.
lang
.
StringUtils
.
isBlank
(
type
)
?
"0"
:
type
;
String
flag
=
org
.
apache
.
commons
.
lang
.
StringUtils
.
isBlank
(
type
)
?
"0"
:
type
;
if
(
org
.
apache
.
commons
.
lang
.
StringUtils
.
isBlank
(
sysCode
))
{
if
(
org
.
apache
.
commons
.
lang
.
StringUtils
.
isBlank
(
sysCode
))
{
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"短信验证码错误"
);
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"短信验证码错误"
);
}
}
String
authCodeKey
=
AccountUtils
.
getAuthCodeKey
(
mobile
,
flag
);
String
authCodeKey
=
getAuthCodeKey
(
mobile
,
flag
);
logger
.
info
(
"验证码缓存信息----->:"
+
this
.
getAuthCodeKey
(
mobile
,
flag
));
String
cacheCode
=
cacheClient
.
get
(
authCodeKey
);
//从redis获取验证码
String
cacheCode
=
cacheClient
.
get
(
authCodeKey
);
//从redis获取验证码
if
(
org
.
apache
.
commons
.
lang
.
StringUtils
.
isBlank
(
cacheCode
))
{
throw
new
PicaException
(
PicaResultCode
.
RESULE_DATA_NONE
.
code
(),
"短信验证码已过期,请重新获取"
);
}
if
(!
org
.
apache
.
commons
.
lang
.
StringUtils
.
equals
(
sysCode
,
cacheCode
))
{
if
(!
org
.
apache
.
commons
.
lang
.
StringUtils
.
equals
(
sysCode
,
cacheCode
))
{
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"短信验证码错误"
);
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"短信验证码错误"
);
}
}
//清除验证码
cacheClient
.
del
(
authCodeKey
);
cacheClient
.
del
(
authCodeKey
);
}
}
//手机号和验证码校验
public
void
checkMobilePhoneAndAuthCode
(
String
mobile
,
String
type
,
String
sysCode
)
{
public
void
check
Register
MobilePhoneAndAuthCode
(
String
mobile
,
String
type
,
String
sysCode
)
{
if
(
StringUtils
.
isBlank
(
mobile
)
||
!
ValidateUtils
.
isMobile
(
mobile
))
{
if
(
StringUtils
.
isBlank
(
mobile
)
||
!
ValidateUtils
.
isMobile
(
mobile
))
{
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"请输入正确的手机号"
);
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"请输入正确的手机号"
);
}
}
String
flag
=
org
.
apache
.
commons
.
lang
.
StringUtils
.
isBlank
(
type
)
?
"0"
:
type
;
if
(
org
.
apache
.
commons
.
lang
.
StringUtils
.
isBlank
(
sysCode
))
{
if
(
org
.
apache
.
commons
.
lang
.
StringUtils
.
isBlank
(
sysCode
))
{
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"短信验证码
错误
"
);
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"短信验证码
为空
"
);
}
}
String
authCodeKey
=
AccountUtils
.
getAuthCodeKey
(
mobile
,
flag
);
String
authCodeKey
=
RegisterCodeKeyUtils
.
getRegisterKey
(
mobile
,
sysCode
);
//验证码3次校验测试不通过,直接删除
Long
num
=
cacheClient
.
decr
(
authCodeKey
);
String
authCodeCount
=
AUTH_CODE_COUNT_PREFIX
+
flag
+
"-"
+
AESUtil
.
encryptV0
(
mobile
);
logger
.
info
(
"key"
+
authCodeKey
);
logger
.
info
(
"success"
+
num
);
logger
.
info
(
"验证码缓存信息----->:"
+
this
.
getAuthCodeKey
(
mobile
,
flag
));
if
(
num
==
-
1
)
{
if
(
cacheClient
.
exists
(
authCodeCount
)
&&
Integer
.
parseInt
(
cacheClient
.
get
(
authCodeCount
))
>
2
)
{
cacheClient
.
del
(
authCodeKey
);
}
String
cacheCode
=
cacheClient
.
get
(
authCodeKey
);
//从redis获取验证码
if
(
org
.
apache
.
commons
.
lang
.
StringUtils
.
isBlank
(
cacheCode
))
{
//第四次删除计数器
cacheClient
.
del
(
authCodeCount
);
throw
new
PicaException
(
PicaResultCode
.
RESULE_DATA_NONE
.
code
(),
"短信验证码已失效,请重新获取"
);
throw
new
PicaException
(
PicaResultCode
.
RESULE_DATA_NONE
.
code
(),
"短信验证码已失效,请重新获取"
);
}
}
if
(!
org
.
apache
.
commons
.
lang
.
StringUtils
.
equals
(
sysCode
,
cacheCode
))
{
if
(
num
>
0
&&
num
<
99
)
{
cacheClient
.
incr
(
authCodeCount
);
throw
new
PicaException
(
PicaResultCode
.
RESULE_DATA_NONE
.
code
(),
"您已注册成功,请直接登录"
);
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"短信验证码错误"
);
}
}
//验证成功以后删除验证码
cacheClient
.
del
(
authCodeKey
);
cacheClient
.
del
(
authCodeKey
);
}
/**
* 请求参数解密、反序列化
*
* @param params
* @param zClass
* @param <T>
* @return
*/
public
static
<
T
>
T
getRequestEntity
(
String
params
,
Class
<
T
>
zClass
)
throws
Exception
{
String
json
=
AESUtil
.
decryptV0
(
params
);
return
JSONObject
.
parseObject
(
json
,
zClass
);
}
}
/**
/**
...
@@ -153,25 +128,6 @@ public class AccountUtils {
...
@@ -153,25 +128,6 @@ public class AccountUtils {
* @return
* @return
*/
*/
public
Long
getUserIdByAcctId
(
Integer
productType
,
Integer
AcctId
)
{
public
Long
getUserIdByAcctId
(
Integer
productType
,
Integer
AcctId
)
{
Long
userId
=
null
;
return
doctorInfoMapper
.
selectUserIdByAcctId
(
AcctId
);
if
(
productType
==
AccountTypeEnum
.
PRODUCT_TYPE_DOCTOR
.
getCode
())
{
userId
=
doctorInfoMapper
.
selectUserIdByAcctId
(
AcctId
);
}
else
if
(
productType
==
AccountTypeEnum
.
PRODUCT_TYPE_HEALTH
.
getCode
())
{
AccountPatientInfoEntity
accountPatientInfoEntity
=
accountPatientInfoMapper
.
selectByAcctId
(
AcctId
);
userId
=
accountPatientInfoEntity
.
getId
().
longValue
();
}
return
userId
;
}
}
/**
* 校验手机号是否注册过
*
* @param mobile
*/
// public boolean checkRegisterMobile(String mobile) {
// String encrypt = AESUtil.encryptV0(mobile);
// AccountContact accountContact = accountContactServer.selectByMobile(encrypt);
// return (accountContact != null && accountContact.getAcctId() != null);
// }
}
}
server/src/main/java/com/pica/cloud/account/account/server/util/RegisterCodeKeyUtils.java
0 → 100644
浏览文件 @
a94fcbb7
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
util
;
/**
* Created on 2020/1/9 16:18
* author:crs
* Description:注册验证码的key规则
*/
public
class
RegisterCodeKeyUtils
{
private
static
final
String
AUTH_CODE_PREFIX
=
"authCode-"
;
/**
* 获取注册验证码的key
*
* @param mobilePhone
* @param authCode
* @return
*/
public
static
String
getRegisterKey
(
String
mobilePhone
,
String
authCode
)
{
return
AUTH_CODE_PREFIX
+
AESUtil
.
encryptV0
(
mobilePhone
)
+
"-"
+
authCode
;
}
}
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录