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
提交
e4ba1910
提交
e4ba1910
编写于
1月 13, 2020
作者:
rushui.chen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
20200113 完善验证码注册流程
上级
f5a75439
流水线
#20726
已失败 于阶段
in 0 second
变更
3
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
5 行增加
和
73 行删除
+5
-73
Test.java
...main/java/com/pica/cloud/account/account/server/Test.java
+2
-2
LoginServiceImpl.java
...account/account/server/service/impl/LoginServiceImpl.java
+2
-1
AccountUtils.java
.../pica/cloud/account/account/server/util/AccountUtils.java
+1
-70
未找到文件。
server/src/main/java/com/pica/cloud/account/account/server/Test.java
浏览文件 @
e4ba1910
...
...
@@ -136,8 +136,8 @@ public class Test {
BaseRequest
loginRegister
=
null
;
loginRegister
=
new
BaseRequest
();
loginRegister
.
setMobile
(
"1302411
9995
"
);
loginRegister
.
setAuthCode
(
"
439160
"
);
loginRegister
.
setMobile
(
"1302411
2588
"
);
loginRegister
.
setAuthCode
(
"
529196
"
);
String
registerString4
=
JSONObject
.
toJSONString
(
loginRegister
);
//AES CONTENT
String
contentResult4
=
AESUtil
.
aesEncrypt
(
registerString4
,
"YCPQPx4qpQjEjDea"
);
...
...
server/src/main/java/com/pica/cloud/account/account/server/service/impl/LoginServiceImpl.java
浏览文件 @
e4ba1910
...
...
@@ -151,10 +151,11 @@ public class LoginServiceImpl implements LoginService {
String
mobile
=
baseRequest
.
getMobile
();
AccountInfoEntity
accountInfoEntity
=
accountInfoDetailMapper
.
selectByMobile
(
AESUtil
.
encryptV0
(
mobile
));
if
(
accountInfoEntity
==
null
)
{
//
一键注册和登录验证码的逻辑不同
//
说明是注册功能
accountUtils
.
checkRegisterMobilePhoneAndAuthCode
(
baseRequest
.
getMobile
(),
baseRequest
.
getFlag
()+
""
,
baseRequest
.
getAuthCode
());
return
registerService
.
register
(
baseRequest
);
}
else
{
//登录功能
accountUtils
.
checkMobilePhoneAndAuthCode
(
baseRequest
.
getMobile
(),
AccountTypeEnum
.
SYSCODE_TYPE_LOGIN
.
getCode
()
+
""
,
baseRequest
.
getAuthCode
());
return
processLogin
(
baseRequest
,
accountInfoEntity
.
getId
(),
AccountTypeEnum
.
LOGIN_CODE
.
getCode
());
}
...
...
server/src/main/java/com/pica/cloud/account/account/server/util/AccountUtils.java
浏览文件 @
e4ba1910
...
...
@@ -2,9 +2,7 @@ package com.pica.cloud.account.account.server.util;
import
com.alibaba.fastjson.JSONObject
;
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.AccountTypeEnum
;
import
com.pica.cloud.account.account.server.mapper.AccountPatientInfoMapper
;
import
com.pica.cloud.account.account.server.mapper.DoctorMapper
;
import
com.pica.cloud.foundation.entity.PicaException
;
...
...
@@ -15,7 +13,6 @@ import org.apache.commons.lang3.StringUtils;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.stereotype.Component
;
/**
...
...
@@ -58,24 +55,6 @@ public class AccountUtils {
return
AUTH_CODE_PREFIX
+
flag
+
"-"
+
AESUtil
.
encryptV0
(
mobilePhone
);
}
//校验验证码
public
void
checkAuthCode
(
String
mobile
,
String
type
,
String
sysCode
)
{
String
flag
=
org
.
apache
.
commons
.
lang
.
StringUtils
.
isBlank
(
type
)
?
"0"
:
type
;
if
(
org
.
apache
.
commons
.
lang
.
StringUtils
.
isBlank
(
sysCode
))
{
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"短信验证码错误"
);
}
String
authCodeKey
=
AccountUtils
.
getAuthCodeKey
(
mobile
,
flag
);
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
))
{
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"短信验证码错误"
);
}
//清除验证码
cacheClient
.
del
(
authCodeKey
);
}
//手机号和验证码校验
public
void
checkMobilePhoneAndAuthCode
(
String
mobile
,
String
type
,
String
sysCode
)
{
if
(
StringUtils
.
isBlank
(
mobile
)
||
!
ValidateUtils
.
isMobile
(
mobile
))
{
...
...
@@ -86,20 +65,9 @@ public class AccountUtils {
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"短信验证码错误"
);
}
String
authCodeKey
=
getAuthCodeKey
(
mobile
,
flag
);
String
authCodeCount
=
AUTH_CODE_COUNT_PREFIX
+
flag
+
"-"
+
AESUtil
.
encryptV0
(
mobile
);
logger
.
info
(
"验证码缓存信息----->:"
+
this
.
getAuthCodeKey
(
mobile
,
flag
));
// 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(), "短信验证码已失效,请重新获取");
// }
if
(!
org
.
apache
.
commons
.
lang
.
StringUtils
.
equals
(
sysCode
,
cacheCode
))
{
cacheClient
.
incr
(
authCodeCount
);
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"短信验证码错误"
);
}
cacheClient
.
del
(
authCodeKey
);
...
...
@@ -110,14 +78,10 @@ public class AccountUtils {
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
;
if
(
org
.
apache
.
commons
.
lang
.
StringUtils
.
isBlank
(
sysCode
))
{
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"短信验证码为空"
);
}
//获取验证码的key
String
authCodeKey
=
RegisterCodeKeyUtils
.
getRegisterKey
(
mobile
,
sysCode
);
//从redis中删除短信验证码,如果能够删除成功,说明验证码正确
//100,99
Long
num
=
cacheClient
.
decr
(
authCodeKey
);
logger
.
info
(
"key"
+
authCodeKey
);
logger
.
info
(
"success"
+
num
);
...
...
@@ -132,19 +96,6 @@ public class AccountUtils {
}
/**
* 请求参数解密、反序列化
*
* @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
);
}
/**
* 获取终端来源
*
...
...
@@ -177,26 +128,6 @@ public class AccountUtils {
* @return
*/
public
Long
getUserIdByAcctId
(
Integer
productType
,
Integer
AcctId
)
{
Long
userId
=
null
;
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
;
return
doctorInfoMapper
.
selectUserIdByAcctId
(
AcctId
);
}
/**
* 校验手机号是否注册过
*
* @param mobile
*/
// public boolean checkRegisterMobile(String mobile) {
// String encrypt = AESUtil.encryptV0(mobile);
// AccountContact accountContact = accountContactServer.selectByMobile(encrypt);
// return (accountContact != null && accountContact.getAcctId() != null);
// }
}
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录