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
提交
e7386bc4
提交
e7386bc4
编写于
2月 21, 2020
作者:
Chongwen.jiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
密码登录接口
找回密码接口 微信授权登录接口 统一验证接口 发送验证码接口修改
上级
89b97cc9
流水线
#21905
已失败 于阶段
in 0 second
变更
11
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
303 行增加
和
170 行删除
+303
-170
AutoCodeController.java
...account/account/server/controller/AutoCodeController.java
+92
-7
LoginController.java
...ud/account/account/server/controller/LoginController.java
+1
-7
PasswordController.java
...account/account/server/controller/PasswordController.java
+45
-5
AccountExceptionEnum.java
...ud/account/account/server/enums/AccountExceptionEnum.java
+3
-4
BizTypeRespEnum.java
...a/cloud/account/account/server/enums/BizTypeRespEnum.java
+15
-19
BaseRequest.java
...om/pica/cloud/account/account/server/req/BaseRequest.java
+1
-1
LoginService.java
...ca/cloud/account/account/server/service/LoginService.java
+1
-1
PasswordService.java
...cloud/account/account/server/service/PasswordService.java
+2
-1
LoginServiceImpl.java
...account/account/server/service/impl/LoginServiceImpl.java
+133
-122
PasswordServiceImpl.java
...ount/account/server/service/impl/PasswordServiceImpl.java
+4
-2
AccountUtils.java
.../pica/cloud/account/account/server/util/AccountUtils.java
+6
-1
未找到文件。
server/src/main/java/com/pica/cloud/account/account/server/controller/AutoCodeController.java
浏览文件 @
e7386bc4
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
controller
;
import
com.
pica.cloud.account.account.server.entity.Account
;
import
com.
pica.cloud.account.account.server.entity.AccountInfoEntity
;
import
com.
alibaba.fastjson.JSON
;
import
com.
alibaba.fastjson.JSONObject
;
import
com.pica.cloud.account.account.server.entity.AccountUnionEntity
;
import
com.pica.cloud.account.account.server.entity.EncryptEntity
;
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.enums.BizTypeRespEnum
;
import
com.pica.cloud.account.account.server.exception.AccountException
;
import
com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper
;
import
com.pica.cloud.account.account.server.req.BaseRequest
;
import
com.pica.cloud.account.account.server.resp.UnifiedVerificationResp
;
import
com.pica.cloud.account.account.server.service.AccountService
;
import
com.pica.cloud.account.account.server.service.AccountUnionService
;
import
com.pica.cloud.account.account.server.service.CaptchaService
;
...
...
@@ -25,16 +27,15 @@ import com.pica.cloud.foundation.utils.utils.ValidateUtils;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.ibatis.logging.Log
;
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.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Objects
;
@Api
(
description
=
"短信验证码资源"
)
@RestController
public
class
AutoCodeController
extends
AccountBaseController
{
...
...
@@ -61,10 +62,32 @@ public class AutoCodeController extends AccountBaseController {
@ApiOperation
(
"获取短信验证码,无需图形验证码,如app端"
)
@PostMapping
(
value
=
"/authCode"
)
public
PicaResponse
getAuthCode
(
@RequestBody
EncryptEntity
entity
)
throws
Exception
{
// 验证码类型 0默认 1注册 2微信登录绑定手机 3修改手机
// 4重置密码 5忘记密码 7患者招募提交问卷(效验) 8Appe登录绑定手机
BaseRequest
request
=
CryptoUtil
.
decrypt
(
entity
,
BaseRequest
.
class
);
AccountUtils
.
checkMobilePhone
(
request
.
getMobile
());
processSysCode
(
request
.
getMobile
(),
request
.
getFlag
());
return
PicaResponse
.
toResponse
();
if
(
request
.
getBizType
()
!=
null
&&
request
.
getBizType
().
equals
(
1
)){
// TODO 调用风控接口
UnifiedVerificationResp
rcResp
=
rcValidate
(
request
.
getMobile
(),
request
.
getFlag
());
if
(
rcResp
==
null
){
// 风控接口调用异常也继续后面的逻辑
processSysCode
(
request
.
getMobile
(),
request
.
getFlag
());
return
PicaResponse
.
toResponse
();
}
else
{
if
(
null
==
rcResp
.
getBizCode
()){
// 风控校验后允许发送短信验证码
processSysCode
(
request
.
getMobile
(),
request
.
getFlag
());
return
PicaResponse
.
toResponse
();
}
else
{
// 风控接口调用正常,并返回业务提示给前端
return
PicaResponse
.
toResponse
(
rcResp
);
}
}
}
else
{
// 老版本业务
processSysCode
(
request
.
getMobile
(),
request
.
getFlag
());
return
PicaResponse
.
toResponse
();
}
}
@ApiOperation
(
"获取短信验证码,需要图形验证码,如H5端和PC端;验证码类型 0默认 1注册 2微信登录绑定手机 3修改手机 4重置密码 5忘记密码 7患者招募提交问卷(效验)"
)
...
...
@@ -183,4 +206,66 @@ public class AutoCodeController extends AccountBaseController {
return
PicaResponse
.
toResponse
(
cacheCode
);
}
/**
* @Description 调用风控接口
* @Author Chongwen.jiang
* @Date 2020/2/21 17:12
* @ModifyDate 2020/2/21 17:12
* @Params [mobile]
* @Return com.pica.cloud.account.account.server.resp.UnifiedVerificationResp
*/
private
UnifiedVerificationResp
rcValidate
(
String
mobile
,
Integer
flag
)
{
// 调用风控接口
PicaResponse
picaResponse
=
null
;
if
(
picaResponse
!=
null
&&
PicaResultCode
.
SUCCESS
.
code
().
equals
(
picaResponse
.
getCode
()))
{
Object
data
=
picaResponse
.
getData
();
if
(
Objects
.
nonNull
(
data
))
{
JSONObject
respData
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
data
),
JSONObject
.
class
);
if
(
StringUtils
.
isNotEmpty
(
respData
.
getString
(
"processCode"
)))
{
Integer
processCode
=
Integer
.
valueOf
(
respData
.
getString
(
"processCode"
));
if
(
null
!=
processCode
)
{
if
(
processCode
.
equals
(
BizTypeRespEnum
.
RC_SEND_FAIL
.
getCode
()))
{
UnifiedVerificationResp
resp
=
new
UnifiedVerificationResp
();
resp
.
setBizCode
(
BizTypeRespEnum
.
RC_SEND_FAIL
.
getCode
());
resp
.
setBizMsg
(
BizTypeRespEnum
.
RC_SEND_FAIL
.
getMsg
());
return
resp
;
}
else
if
(
processCode
.
equals
(
BizTypeRespEnum
.
RC_TRIGGER
.
getCode
()))
{
UnifiedVerificationResp
resp
=
new
UnifiedVerificationResp
();
resp
.
setBizCode
(
BizTypeRespEnum
.
RC_TRIGGER
.
getCode
());
resp
.
setBizMsg
(
BizTypeRespEnum
.
RC_TRIGGER
.
getMsg
());
return
resp
;
}
else
if
(
processCode
.
equals
(
BizTypeRespEnum
.
RC_BLACKLIST
.
getCode
()))
{
UnifiedVerificationResp
resp
=
new
UnifiedVerificationResp
();
resp
.
setBizCode
(
BizTypeRespEnum
.
RC_BLACKLIST
.
getCode
());
resp
.
setBizMsg
(
BizTypeRespEnum
.
RC_BLACKLIST
.
getMsg
());
return
resp
;
}
else
if
(
processCode
.
equals
(
BizTypeRespEnum
.
RC_DAY_LIMIT
.
getCode
()))
{
UnifiedVerificationResp
resp
=
new
UnifiedVerificationResp
();
resp
.
setBizCode
(
BizTypeRespEnum
.
RC_DAY_LIMIT
.
getCode
());
resp
.
setBizMsg
(
BizTypeRespEnum
.
RC_DAY_LIMIT
.
getMsg
());
return
resp
;
}
else
if
(
processCode
.
equals
(
BizTypeRespEnum
.
RC_60_SECOND_LIMIT
.
getCode
()))
{
UnifiedVerificationResp
resp
=
new
UnifiedVerificationResp
();
resp
.
setBizCode
(
BizTypeRespEnum
.
RC_60_SECOND_LIMIT
.
getCode
());
// 获取剩余秒数
Long
time
=
cacheClient
.
get
(
this
.
getAuthCodeKey
(
mobile
,
flag
.
toString
())
+
"-secure"
,
Long
.
class
);
int
remainTime
=
59
-
(
int
)
(
System
.
currentTimeMillis
()
-
time
)
/
1000
;
if
(
remainTime
>
0
)
{
resp
.
setBizMsg
(
BizTypeRespEnum
.
RC_60_SECOND_LIMIT
.
getMsg
()
.
replace
(
"{remainTime}"
,
String
.
valueOf
(
remainTime
)));
}
return
resp
;
}
}
}
}
// processCode=1(允许发送短信验证码)
return
new
UnifiedVerificationResp
();
}
else
{
return
null
;
}
}
}
server/src/main/java/com/pica/cloud/account/account/server/controller/LoginController.java
浏览文件 @
e7386bc4
...
...
@@ -15,13 +15,10 @@ import com.pica.cloud.account.account.server.util.CryptoUtil;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.pica.cloud.foundation.redis.CacheClient
;
import
com.pica.cloud.foundation.redis.ICacheClient
;
import
com.pica.cloud.foundation.utils.entity.DeviceInfo
;
import
com.pica.cloud.foundation.utils.utils.CommonUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.HashMap
;
...
...
@@ -212,10 +209,7 @@ public class LoginController extends AccountBaseController {
@PostMapping
(
"/unifiedVerification"
)
public
PicaResponse
unifiedVerification
(
@RequestBody
EncryptEntity
entity
)
throws
Exception
{
BaseRequest
request
=
CryptoUtil
.
decrypt
(
entity
,
BaseRequest
.
class
);
return
PicaResponse
.
toResponse
(
loginService
.
preLoginValidate
(
request
,
super
.
getDeviceInfo
(
"deviceId"
),
super
.
getIpAddr
()));
return
PicaResponse
.
toResponse
(
loginService
.
preLoginValidate
(
request
));
}
}
server/src/main/java/com/pica/cloud/account/account/server/controller/PasswordController.java
浏览文件 @
e7386bc4
...
...
@@ -3,18 +3,18 @@ package com.pica.cloud.account.account.server.controller;
import
com.pica.cloud.account.account.server.entity.AccountInfoEntity
;
import
com.pica.cloud.account.account.server.entity.Doctor
;
import
com.pica.cloud.account.account.server.entity.EncryptEntity
;
import
com.pica.cloud.account.account.server.en
ums.AccountTypeEnum
;
import
com.pica.cloud.account.account.server.en
tity.LoginResult
;
import
com.pica.cloud.account.account.server.enums.AccountExceptionEnum
;
import
com.pica.cloud.account.account.server.exception.AccountException
;
import
com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper
;
import
com.pica.cloud.account.account.server.req.BaseRequest
;
import
com.pica.cloud.account.account.server.service.DoctorService
;
import
com.pica.cloud.account.account.server.service.PasswordService
;
import
com.pica.cloud.account.account.server.service.RegisterService
;
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.CryptoUtil
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.pica.cloud.foundation.utils.entity.PicaUser
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -38,6 +38,8 @@ public class PasswordController extends AccountBaseController {
@Autowired
private
DoctorService
doctorService
;
@Autowired
private
RegisterService
registerService
;
/**
* 重置密码
...
...
@@ -78,19 +80,57 @@ public class PasswordController extends AccountBaseController {
@PostMapping
(
value
=
"/reset"
)
public
PicaResponse
forgetPassword
(
@RequestBody
EncryptEntity
entity
)
throws
Exception
{
BaseRequest
request
=
CryptoUtil
.
decrypt
(
entity
,
BaseRequest
.
class
);
if
(
super
.
getSourceType
()==
2
){
if
(
request
.
getBizType
()
!=
null
&&
request
.
getBizType
().
equals
(
1
))
{
AccountInfoEntity
account
=
accountInfoDetailMapper
.
selectByMobile
(
AESUtil
.
encryptV0
(
request
.
getMobile
()));
if
(
account
==
null
)
{
if
(
super
.
getSourceType
()==
2
){
accountUtils
.
checkMobilePhoneAndAuthCode
(
request
.
getMobile
(),
"5"
,
request
.
getAuthCode
());
}
else
{
accountUtils
.
checkMobilePhoneAndAuthCode
(
request
.
getMobile
(),
"4"
,
request
.
getAuthCode
());
}
if
(
StringUtils
.
isEmpty
(
request
.
getPassword
()))
{
throw
new
AccountException
(
AccountExceptionEnum
.
PICA_PASSWORD_ERROR
);
}
// 新版-未注册-则默认注册
LoginResult
result
=
registerService
.
register
(
request
);
// 已补全密码
result
.
setEntireFlag
(
3
);
return
PicaResponse
.
toResponse
(
result
);
}
else
{
// 新版-已注册了的则找回密码
return
reSetPwd
(
request
,
account
);
}
}
else
{
// 老版
return
reSetPwd
(
request
,
null
);
}
}
/**
* @Description 找回密码
* @Author Chongwen.jiang
* @Date 2020/2/21 20:07
* @ModifyDate 2020/2/21 20:07
* @Params [request, entity]
* @Return com.pica.cloud.foundation.entity.PicaResponse
*/
private
PicaResponse
reSetPwd
(
BaseRequest
request
,
AccountInfoEntity
entity
)
{
// 4重置密码 5忘记密码
if
(
super
.
getSourceType
()
==
2
){
// ios
accountUtils
.
checkMobilePhoneAndAuthCode
(
request
.
getMobile
(),
"5"
,
request
.
getAuthCode
());
if
(
StringUtils
.
isEmpty
(
request
.
getPassword
()))
{
throw
new
AccountException
(
AccountExceptionEnum
.
PICA_PASSWORD_ERROR
);
}
passwordService
.
forgetPassword
(
request
);
passwordService
.
forgetPassword
(
request
,
entity
);
return
PicaResponse
.
toResponse
();
}
else
{
accountUtils
.
checkMobilePhoneAndAuthCode
(
request
.
getMobile
(),
"4"
,
request
.
getAuthCode
());
if
(
StringUtils
.
isEmpty
(
request
.
getPassword
()))
{
throw
new
AccountException
(
AccountExceptionEnum
.
PICA_PASSWORD_ERROR
);
}
passwordService
.
forgetPassword
(
request
);
passwordService
.
forgetPassword
(
request
,
entity
);
return
PicaResponse
.
toResponse
();
}
}
...
...
server/src/main/java/com/pica/cloud/account/account/server/enums/AccountExceptionEnum.java
浏览文件 @
e7386bc4
...
...
@@ -30,10 +30,9 @@ public enum AccountExceptionEnum {
PICA_WECHAT_UNBIND
(
"216522"
,
"该微信号已绑定其他云鹊医账户,你可以使用微信登录云鹊医,在「设置」页解除绑定"
),
PICA_WECHAT_BIND_OTHER
(
"216524"
,
"该手机号已绑定其他微信号,你可以在「设置」页解除绑定"
),
PICA_WECHAT_UNBIND_CURRENT
(
"216523"
,
"正在绑定中,请稍等"
),
PICA_PASSWORD_RULE_ERROR
(
"216525"
,
"请设置正确的密码格式"
),
PICA_PWD_ERROR
(
"216526"
,
"密码错误,请重试"
),
PICA_PWD_ERROR_2
(
"216527"
,
"密码错误次数过多,请前往找回密码"
),
PICA_APPLE_BIND_OTHER
(
"216528"
,
"该手机号已绑定其他苹果账号"
),
PICA_PASSWORD_RULE_ERROR
(
"216525"
,
"该手机号{mobile}尚未设置密码,请先设置密码。"
),
PICA_PWD_MISMATCH_4
(
"216526"
,
"密码错误,请重试"
),
PICA_PWD_MISMATCH_5
(
"216527"
,
"密码错误次数过多,请前往找回密码"
),
xxx_xxx
(
""
,
""
);
...
...
server/src/main/java/com/pica/cloud/account/account/server/enums/BizTypeRespEnum.java
浏览文件 @
e7386bc4
...
...
@@ -10,26 +10,22 @@ package com.pica.cloud.account.account.server.enums;
*/
public
enum
BizTypeRespEnum
{
MOBILE_REG_FALSE
(
1
,
"请输入正确的手机号"
),
MOBILE_REG_TRUE
(
2
,
"手机号符合规则
"
),
// 风控禁止发送
RC_SEND_FAIL
(
2
,
"发送失败
"
),
RC_TRIGGER
(
3
,
"需要触发风控滑动验证"
),
RC_NOT_TRIGGER
(
4
,
"不需要触发风控滑动验证"
),
MOBILE_NOT_REGIST
(
5
,
"该手机号{mobile}尚未设置密码,请先设置密码。"
),
MOBILE_REGISTED
(
6
,
"手机号已注册"
),
MOBILE_NOT_SETED_PASSWORD
(
7
,
"该手机号{mobile}尚未设置密码,请先设置密码。"
),
MOBILE_SETED_PASSWORD
(
8
,
"手机号已设置密码"
),
/*PWD_REG_FALSE(9, "请设置正确的密码格式"),
PWD_REG_TRUE(10, "密码格式正确"),*/
PWD_MATCH_DB
(
11
,
"密码正确"
),
PWD_MISMATCH_4
(
12
,
"密码错误,请重试"
),
PWD_MISMATCH_5
(
13
,
"密码错误次数过多,请前往找回密码"
),
MOBILE_BINDED_WECHAT
(
14
,
"该手机号已绑定其他微信号,你可以在「设置」页解除绑定"
),
MOBILE_NOT_BINDED_WECHAT
(
15
,
"该手机号未绑定微信"
),
MOBILE_BINDED_APPLE
(
16
,
"该手机号已绑定其他苹果账号"
),
MOBILE_NOT_BINDED_APPLE
(
17
,
"该手机号未绑定苹果账号"
),
XXX
(
10
,
"xxxxxx"
);
// 账号、IP、设备在黑名单内,前端提示发送成功,后端不发送短信
RC_BLACKLIST
(
4
,
"发送成功"
),
RC_DAY_LIMIT
(
5
,
"今日获取验证码次数以超过上限,请使用账户密码登录"
),
RC_60_SECOND_LIMIT
(
6
,
"验证码发送频率过高,请{remainTime}秒后再试"
),
MOBILE_REG_FALSE
(
7
,
"请输入正确的手机号"
),
MOBILE_REG_TRUE
(
8
,
"手机号符合规则"
),
MOBILE_NOT_REGIST
(
9
,
"该手机号{mobile}尚未设置密码,请先设置密码。"
),
MOBILE_NOT_SETED_PASSWORD
(
10
,
"该手机号{mobile}尚未设置密码,请先设置密码。"
),
MOBILE_SETED_PASSWORD
(
11
,
"手机号已设置密码"
),
XXX
(
0
,
"xxxxxx"
);
private
Integer
code
;
private
String
msg
;
...
...
server/src/main/java/com/pica/cloud/account/account/server/req/BaseRequest.java
浏览文件 @
e7386bc4
...
...
@@ -36,7 +36,7 @@ public class BaseRequest {
private
String
captchaAnswer
;
@ApiModelProperty
(
"苹果用户id"
)
private
String
appleUserId
;
@ApiModelProperty
(
"业务类型,1-
验证码登录,2-密码登录,3-找回密码,4-微信登录,5-Apple登录
"
)
@ApiModelProperty
(
"业务类型,1-
新老业务区分标识,2-手机号格式校验业务,3-密码登录校验业务
"
)
private
Integer
bizType
;
public
String
getCaptchaToken
()
{
...
...
server/src/main/java/com/pica/cloud/account/account/server/service/LoginService.java
浏览文件 @
e7386bc4
...
...
@@ -65,5 +65,5 @@ public interface LoginService {
* @Params [request]
* @Return com.pica.cloud.foundation.entity.PicaResponse
*/
UnifiedVerificationResp
preLoginValidate
(
BaseRequest
request
,
String
deviceId
,
String
ip
);
UnifiedVerificationResp
preLoginValidate
(
BaseRequest
request
);
}
server/src/main/java/com/pica/cloud/account/account/server/service/PasswordService.java
浏览文件 @
e7386bc4
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
service
;
import
com.pica.cloud.account.account.server.entity.AccountInfoEntity
;
import
com.pica.cloud.account.account.server.req.BaseRequest
;
public
interface
PasswordService
{
...
...
@@ -18,5 +19,5 @@ public interface PasswordService {
*
* @param request 参数模型
*/
void
forgetPassword
(
BaseRequest
request
);
void
forgetPassword
(
BaseRequest
request
,
AccountInfoEntity
entity
);
}
server/src/main/java/com/pica/cloud/account/account/server/service/impl/LoginServiceImpl.java
浏览文件 @
e7386bc4
...
...
@@ -5,7 +5,6 @@ import com.pica.cloud.account.account.server.constants.Constants;
import
com.pica.cloud.account.account.server.entity.*
;
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.enums.BizTypeEnum
;
import
com.pica.cloud.account.account.server.enums.BizTypeRespEnum
;
import
com.pica.cloud.account.account.server.log.AccountLogEntityUtils
;
import
com.pica.cloud.account.account.server.log.AccountLogUtils
;
...
...
@@ -108,53 +107,110 @@ public class LoginServiceImpl implements LoginService {
String
mobile
=
request
.
getMobile
();
String
encrypt
=
AESUtil
.
encryptV0
(
mobile
);
AccountInfoEntity
accountInfoEntity
=
accountInfoDetailMapper
.
selectByMobile
(
encrypt
);
logger
.
info
(
"bizType:{}, account not null:{}"
,
request
.
getBizType
(),
accountInfoEntity
!=
null
);
if
(
accountInfoEntity
!=
null
)
{
String
oldPwd
=
accountInfoEntity
.
getPassword
();
String
password
=
request
.
getPassword
();
if
(
password
.
equals
(
oldPwd
))
{
Date
currentTime
=
new
Date
();
Integer
acctId
=
accountInfoEntity
.
getId
();
int
productType
=
request
.
getProductType
();
int
sourceType
=
request
.
getSourceType
();
Doctor
doctorInfo
=
doctorInfoMapper
.
getDoctorInfoByMobile
(
encrypt
);
Integer
userId
=
0
;
if
(
productType
==
AccountTypeEnum
.
PRODUCT_TYPE_DOCTOR
.
getCode
())
{
userId
=
doctorInfo
.
getId
();
}
else
if
(
productType
==
AccountTypeEnum
.
PRODUCT_TYPE_HEALTH
.
getCode
())
{
AccountPatientInfoEntity
accountPatientInfoEntity
=
accountPatientInfoMapper
.
selectByAcctId
(
acctId
);
userId
=
accountPatientInfoEntity
.
getId
();
}
Account
account
=
new
Account
();
account
.
setId
(
userId
.
longValue
());
account
.
setAcctId
(
acctId
);
account
.
setCreatTime
(
currentTime
);
account
.
setMobilePhone
(
mobile
);
account
.
setRegisterSource
(
sourceType
);
String
newToken
=
tokenUtils
.
generateToken
(
account
);
LoginResult
result
=
new
LoginResult
();
result
.
setToken
(
newToken
);
result
.
setUserId
(
userId
.
longValue
());
result
.
setMobile
(
mobile
);
result
.
setDoctorId
(
EncryptUtils
.
encryptContent
(
userId
+
""
,
EncryptConstants
.
ENCRYPT_TYPE_ID
));
if
(
productType
==
AccountTypeEnum
.
PRODUCT_TYPE_DOCTOR
.
getCode
())
{
result
.
setEntireFlag
(
doctorInfo
.
getEntireFlag
());
if
(
null
!=
request
.
getBizType
()
&&
request
.
getBizType
().
equals
(
1
))
{
// 新版-未设置密码
if
(
StringUtils
.
isEmpty
(
oldPwd
))
{
throw
new
PicaException
(
AccountExceptionEnum
.
PICA_PASSWORD_RULE_ERROR
.
getCode
(),
AccountExceptionEnum
.
PICA_PASSWORD_RULE_ERROR
.
getMessage
()
.
replace
(
"{mobile}"
,
mobile
));
}
else
{
if
(
password
.
equals
(
oldPwd
))
{
return
pwdLoginCorrect
(
request
,
mobile
,
encrypt
,
accountInfoEntity
);
}
else
{
// 从缓存取出当前账号密码错误次数
logger
.
info
(
"new login failure:"
+
mobile
);
String
key
=
Constants
.
PWD_ERROR_NUM_KEY
.
replace
(
"{mobile}"
,
mobile
);
if
(
redisClient
.
exists
(
key
))
{
int
errorCount
=
Integer
.
parseInt
(
redisClient
.
get
(
key
));
errorCount
=
errorCount
+
1
;
redisClient
.
set
(
key
,
errorCount
,
Constants
.
PWD_ERROR_NUM_SECONDS
);
if
(
errorCount
<=
4
)
{
throw
new
PicaException
(
AccountExceptionEnum
.
PICA_PWD_MISMATCH_4
.
getCode
(),
AccountExceptionEnum
.
PICA_PWD_MISMATCH_4
.
getMessage
());
}
else
{
throw
new
PicaException
(
AccountExceptionEnum
.
PICA_PWD_MISMATCH_5
.
getCode
(),
AccountExceptionEnum
.
PICA_PWD_MISMATCH_5
.
getMessage
());
}
}
else
{
redisClient
.
set
(
key
,
1
,
Constants
.
PWD_ERROR_NUM_SECONDS
);
throw
new
PicaException
(
AccountExceptionEnum
.
PICA_PWD_MISMATCH_4
.
getCode
(),
AccountExceptionEnum
.
PICA_PWD_MISMATCH_4
.
getMessage
());
}
}
}
LogLoginEntity
entity
=
AccountLogEntityUtils
.
getLogLoginEntity
(
acctId
,
productType
,
sourceType
,
AccountTypeEnum
.
LOGIN_PWD
.
getCode
(),
request
.
getLoginIp
(),
AccountTypeEnum
.
LOGIN_STATUS_SUCCESS
.
getCode
(),
AccountTypeEnum
.
LOG_TYPE_LOGIN
.
getCode
());
picaLogUtils
.
info
(
entity
);
return
result
;
}
else
{
logger
.
info
(
"login failure:"
+
mobile
);
throw
new
PicaException
(
AccountExceptionEnum
.
PICA_PASSWORD_ERROR
.
getCode
(),
AccountExceptionEnum
.
PICA_PASSWORD_ERROR
.
getMessage
());
// 旧版本
if
(
password
.
equals
(
oldPwd
))
{
return
pwdLoginCorrect
(
request
,
mobile
,
encrypt
,
accountInfoEntity
);
}
else
{
logger
.
info
(
"login failure:"
+
mobile
);
throw
new
PicaException
(
AccountExceptionEnum
.
PICA_PASSWORD_ERROR
.
getCode
(),
AccountExceptionEnum
.
PICA_PASSWORD_ERROR
.
getMessage
());
}
}
}
else
{
throw
new
PicaException
(
AccountExceptionEnum
.
PICA_NOT_REGISTER
.
getCode
(),
AccountExceptionEnum
.
PICA_NOT_REGISTER
.
getMessage
());
if
(
null
!=
request
.
getBizType
()
&&
request
.
getBizType
().
equals
(
1
))
{
// 新版-未注册
throw
new
PicaException
(
AccountExceptionEnum
.
PICA_PASSWORD_RULE_ERROR
.
getCode
(),
AccountExceptionEnum
.
PICA_PASSWORD_RULE_ERROR
.
getMessage
()
.
replace
(
"{mobile}"
,
mobile
));
}
else
{
throw
new
PicaException
(
AccountExceptionEnum
.
PICA_NOT_REGISTER
.
getCode
(),
AccountExceptionEnum
.
PICA_NOT_REGISTER
.
getMessage
());
}
}
}
/**
* @Description 密码登录-密码正确逻辑
* @Author Chongwen.jiang
* @Date 2020/2/21 19:13
* @ModifyDate 2020/2/21 19:13
* @Params [request, mobile, encrypt, accountInfoEntity]
* @Return com.pica.cloud.account.account.server.entity.LoginResult
*/
private
LoginResult
pwdLoginCorrect
(
BaseRequest
request
,
String
mobile
,
String
encrypt
,
AccountInfoEntity
accountInfoEntity
)
{
Date
currentTime
=
new
Date
();
Integer
acctId
=
accountInfoEntity
.
getId
();
int
productType
=
request
.
getProductType
();
int
sourceType
=
request
.
getSourceType
();
Doctor
doctorInfo
=
doctorInfoMapper
.
getDoctorInfoByMobile
(
encrypt
);
Integer
userId
=
0
;
if
(
productType
==
AccountTypeEnum
.
PRODUCT_TYPE_DOCTOR
.
getCode
())
{
userId
=
doctorInfo
.
getId
();
}
else
if
(
productType
==
AccountTypeEnum
.
PRODUCT_TYPE_HEALTH
.
getCode
())
{
AccountPatientInfoEntity
accountPatientInfoEntity
=
accountPatientInfoMapper
.
selectByAcctId
(
acctId
);
userId
=
accountPatientInfoEntity
.
getId
();
}
Account
account
=
new
Account
();
account
.
setId
(
userId
.
longValue
());
account
.
setAcctId
(
acctId
);
account
.
setCreatTime
(
currentTime
);
account
.
setMobilePhone
(
mobile
);
account
.
setRegisterSource
(
sourceType
);
String
newToken
=
tokenUtils
.
generateToken
(
account
);
LoginResult
result
=
new
LoginResult
();
result
.
setToken
(
newToken
);
result
.
setUserId
(
userId
.
longValue
());
result
.
setMobile
(
mobile
);
result
.
setDoctorId
(
EncryptUtils
.
encryptContent
(
userId
+
""
,
EncryptConstants
.
ENCRYPT_TYPE_ID
));
if
(
productType
==
AccountTypeEnum
.
PRODUCT_TYPE_DOCTOR
.
getCode
())
{
result
.
setEntireFlag
(
doctorInfo
.
getEntireFlag
());
}
LogLoginEntity
entity
=
AccountLogEntityUtils
.
getLogLoginEntity
(
acctId
,
productType
,
sourceType
,
AccountTypeEnum
.
LOGIN_PWD
.
getCode
(),
request
.
getLoginIp
(),
AccountTypeEnum
.
LOGIN_STATUS_SUCCESS
.
getCode
(),
AccountTypeEnum
.
LOG_TYPE_LOGIN
.
getCode
());
picaLogUtils
.
info
(
entity
);
return
result
;
}
@Override
public
LoginResult
loginAndRegister
(
BaseRequest
baseRequest
)
{
String
mobile
=
baseRequest
.
getMobile
();
...
...
@@ -206,7 +262,8 @@ public class LoginServiceImpl implements LoginService {
@Transactional
public
LoginResult
loginByWeChat
(
BaseRequest
request
)
{
WeChatEntity
weChatEntity
=
null
;
if
(
request
.
getFlag
()
==
1
)
{
if
(
null
!=
request
.
getBizType
()
&&
request
.
getBizType
().
equals
(
1
))
{
// h5微信登录
weChatEntity
=
WeChatUtils
.
getAuthorizationInfo
(
appIdH5
,
appSecretH5
,
request
.
getWeChatCode
());
}
else
{
...
...
@@ -418,69 +475,52 @@ public class LoginServiceImpl implements LoginService {
* @Return com.pica.cloud.foundation.entity.PicaResponse
*/
@Override
public
UnifiedVerificationResp
preLoginValidate
(
BaseRequest
request
,
String
deviceId
,
String
ip
)
{
public
UnifiedVerificationResp
preLoginValidate
(
BaseRequest
request
)
{
UnifiedVerificationResp
resp
=
new
UnifiedVerificationResp
();
Integer
bizType
=
request
.
getBizType
();
String
mobile
=
request
.
getMobile
();
String
password
=
request
.
getPassword
();
if
(
null
==
bizType
)
{
logger
.
info
(
"bizType is null"
);
return
resp
;
}
// 手机号规则校验
if
(
StringUtils
.
isNotEmpty
(
mobile
)
&&
!
ValidateUtils
.
isMobile
(
mobile
))
{
resp
.
setBizCode
(
BizTypeRespEnum
.
MOBILE_REG_FALSE
.
getCode
());
resp
.
setBizMsg
(
BizTypeRespEnum
.
MOBILE_REG_FALSE
.
getMsg
());
}
else
{
resp
.
setBizCode
(
BizTypeRespEnum
.
MOBILE_REG_TRUE
.
getCode
());
resp
.
setBizMsg
(
BizTypeRespEnum
.
MOBILE_REG_TRUE
.
getMsg
());
}
if
(
BizTypeEnum
.
LOGIN_AUTH_CODE
.
getCode
().
equals
(
bizType
))
{
// TODO 局域网ip
invokeRCInterface
(
resp
,
mobile
,
ip
,
deviceId
,
""
);
}
else
if
(
BizTypeEnum
.
LOGIN_PWD
.
getCode
().
equals
(
bizType
))
{
// 密码登录相关校验
pwdLoginPreValidate
(
resp
,
mobile
,
password
);
}
else
if
(
BizTypeEnum
.
FIND_PASSWORD
.
getCode
().
equals
(
bizType
))
{
// TODO 局域网ip
invokeRCInterface
(
resp
,
mobile
,
ip
,
deviceId
,
""
);
}
else
if
(
BizTypeEnum
.
LOGIN_WE_CHAT
.
getCode
().
equals
(
bizType
))
{
if
(
StringUtils
.
isNotEmpty
(
mobile
))
{
// 判断手机号是否绑定了微信
AccountInfoEntity
accountInfo
=
accountInfoDetailMapper
.
selectByMobile
(
AESUtil
.
encryptV0
(
mobile
));
AccountUnionEntity
accountUnionEntityAccount
=
accountUnionMapper
.
selectByAcctId
(
accountInfo
.
getId
());
if
(
accountUnionEntityAccount
!=
null
)
{
resp
.
setBizCode
(
BizTypeRespEnum
.
MOBILE_BINDED_WECHAT
.
getCode
());
resp
.
setBizMsg
(
BizTypeRespEnum
.
MOBILE_BINDED_WECHAT
.
getMsg
());
}
else
{
resp
.
setBizCode
(
BizTypeRespEnum
.
MOBILE_NOT_BINDED_WECHAT
.
getCode
());
resp
.
setBizMsg
(
BizTypeRespEnum
.
MOBILE_NOT_BINDED_WECHAT
.
getMsg
());
// TODO 局域网ip
invokeRCInterface
(
resp
,
mobile
,
ip
,
deviceId
,
""
);
}
}
}
else
if
(
BizTypeEnum
.
LOGIN_APPLE
.
getCode
().
equals
(
bizType
))
{
if
(
StringUtils
.
isNotEmpty
(
mobile
))
{
// 判断手机号是否绑定了苹果
AccountInfoEntity
accountInfo
=
accountInfoDetailMapper
.
selectByMobile
(
AESUtil
.
encryptV0
(
mobile
));
AccountUnionEntity
accountUnionEntityAccount
=
accountUnionMapper
.
selectByAcctId
(
accountInfo
.
getId
());
if
(
accountUnionEntityAccount
!=
null
)
{
resp
.
setBizCode
(
BizTypeRespEnum
.
MOBILE_BINDED_APPLE
.
getCode
());
resp
.
setBizMsg
(
BizTypeRespEnum
.
MOBILE_BINDED_APPLE
.
getMsg
());
}
else
{
resp
.
setBizCode
(
BizTypeRespEnum
.
MOBILE_BINDED_APPLE
.
getCode
());
resp
.
setBizMsg
(
BizTypeRespEnum
.
MOBILE_BINDED_APPLE
.
getMsg
());
// TODO 局域网ip
invokeRCInterface
(
resp
,
mobile
,
ip
,
deviceId
,
""
);
}
if
(
bizType
.
equals
(
2
))
{
// 手机号规则校验
if
(
StringUtils
.
isNotEmpty
(
mobile
)
&&
!
ValidateUtils
.
isMobile
(
mobile
))
{
resp
.
setBizCode
(
BizTypeRespEnum
.
MOBILE_REG_FALSE
.
getCode
());
resp
.
setBizMsg
(
BizTypeRespEnum
.
MOBILE_REG_FALSE
.
getMsg
());
}
else
{
resp
.
setBizCode
(
BizTypeRespEnum
.
MOBILE_REG_TRUE
.
getCode
());
resp
.
setBizMsg
(
BizTypeRespEnum
.
MOBILE_REG_TRUE
.
getMsg
());
}
}
else
if
(
bizType
.
equals
(
3
)){
// 手机号规则校验
if
(
StringUtils
.
isNotEmpty
(
mobile
)
&&
!
ValidateUtils
.
isMobile
(
mobile
))
{
resp
.
setBizMsg
(
BizTypeRespEnum
.
MOBILE_REG_FALSE
.
getMsg
());
resp
.
setBizCode
(
BizTypeRespEnum
.
MOBILE_REG_FALSE
.
getCode
());
return
resp
;
}
// 手机号是否注册
AccountInfoEntity
accountInfo
=
accountInfoDetailMapper
.
selectByMobile
(
AESUtil
.
encryptV0
(
mobile
));
if
(
accountInfo
==
null
)
{
resp
.
setBizCode
(
BizTypeRespEnum
.
MOBILE_NOT_REGIST
.
getCode
());
resp
.
setBizMsg
(
BizTypeRespEnum
.
MOBILE_NOT_REGIST
.
getMsg
()
.
replace
(
"{mobile}"
,
mobile
));
return
resp
;
}
// 手机号是否设置了密码
if
(
StringUtils
.
isEmpty
(
accountInfo
.
getPassword
()))
{
resp
.
setBizCode
(
BizTypeRespEnum
.
MOBILE_NOT_SETED_PASSWORD
.
getCode
());
resp
.
setBizMsg
(
BizTypeRespEnum
.
MOBILE_NOT_SETED_PASSWORD
.
getMsg
()
.
replace
(
"{mobile}"
,
mobile
));
}
else
{
resp
.
setBizMsg
(
BizTypeRespEnum
.
MOBILE_SETED_PASSWORD
.
getMsg
());
resp
.
setBizCode
(
BizTypeRespEnum
.
MOBILE_SETED_PASSWORD
.
getCode
());
}
}
return
resp
;
}
...
...
@@ -494,7 +534,7 @@ public class LoginServiceImpl implements LoginService {
* @Return void
*/
private
void
pwdLoginPreValidate
(
UnifiedVerificationResp
resp
,
String
mobile
,
String
password
)
{
if
(
StringUtils
.
isNotEmpty
(
mobile
))
{
/*
if (StringUtils.isNotEmpty(mobile)) {
// 判断手机号是否注册(未注册,提示去找回密码,找回密码页有注册逻辑)
AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(mobile));
if (accountInfo == null) {
...
...
@@ -517,7 +557,7 @@ public class LoginServiceImpl implements LoginService {
resp.setBizMsg(BizTypeRespEnum.MOBILE_SETED_PASSWORD.getMsg());
}
}
}
}
*/
/*if (StringUtils.isNotEmpty(password)) {
// 判断密码是否正确
...
...
@@ -551,33 +591,4 @@ public class LoginServiceImpl implements LoginService {
}*/
}
/**
* @Description 调用风控接口
* @Author Chongwen.jiang
* @Date 2020/2/20 22:24
* @ModifyDate 2020/2/20 22:24
* @Params [resp, mobile, ip(出口ip), deviceId, intranetIp(局域网ip)]
* @Return void
*/
private
void
invokeRCInterface
(
UnifiedVerificationResp
resp
,
String
mobile
,
String
ip
,
String
deviceId
,
String
intranetIp
)
{
logger
.
info
(
"invokeRCInterface-mobile:{}, ip:{}, deviceId:{}, intranetIp:{}"
,
mobile
,
ip
,
deviceId
,
intranetIp
);
if
(
StringUtils
.
isEmpty
(
mobile
)){
return
;
}
// TODO 调用风控接口
String
processCode
=
"200"
;
if
(
"200"
.
equals
(
processCode
))
{
resp
.
setBizCode
(
BizTypeRespEnum
.
RC_NOT_TRIGGER
.
getCode
());
resp
.
setBizMsg
(
BizTypeRespEnum
.
RC_NOT_TRIGGER
.
getMsg
());
}
else
{
resp
.
setBizCode
(
BizTypeRespEnum
.
RC_TRIGGER
.
getCode
());
resp
.
setBizMsg
(
BizTypeRespEnum
.
RC_TRIGGER
.
getMsg
());
}
}
}
server/src/main/java/com/pica/cloud/account/account/server/service/impl/PasswordServiceImpl.java
浏览文件 @
e7386bc4
...
...
@@ -65,8 +65,10 @@ public class PasswordServiceImpl implements PasswordService {
@Override
@Transactional
public
void
forgetPassword
(
BaseRequest
request
)
{
AccountInfoEntity
entity
=
accountInfoDetailMapper
.
selectByMobile
(
AESUtil
.
encryptV0
(
request
.
getMobile
()));
public
void
forgetPassword
(
BaseRequest
request
,
AccountInfoEntity
entity
)
{
if
(
entity
==
null
)
{
entity
=
accountInfoDetailMapper
.
selectByMobile
(
AESUtil
.
encryptV0
(
request
.
getMobile
()));
}
if
(
entity
!=
null
)
{
String
password
=
request
.
getPassword
();
Integer
accId
=
entity
.
getId
();
...
...
server/src/main/java/com/pica/cloud/account/account/server/util/AccountUtils.java
浏览文件 @
e7386bc4
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
util
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.pica.cloud.account.account.server.controller.AccountController
;
import
com.pica.cloud.account.account.server.enums.AccountExceptionEnum
;
import
com.pica.cloud.account.account.server.enums.BizTypeRespEnum
;
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.resp.UnifiedVerificationResp
;
import
com.pica.cloud.foundation.entity.PicaException
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.pica.cloud.foundation.entity.PicaResultCode
;
import
com.pica.cloud.foundation.redis.ICacheClient
;
import
com.pica.cloud.foundation.utils.utils.ValidateUtils
;
...
...
@@ -15,6 +19,7 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.Objects
;
import
java.util.regex.Pattern
;
/**
...
...
@@ -24,7 +29,6 @@ import java.util.regex.Pattern;
public
class
AccountUtils
{
@Autowired
private
ICacheClient
cacheClient
;
private
Logger
logger
=
LoggerFactory
.
getLogger
(
AccountController
.
class
);
...
...
@@ -141,4 +145,5 @@ public class AccountUtils {
public
Long
getUserIdByAcctId
(
Integer
productType
,
Integer
AcctId
)
{
return
doctorInfoMapper
.
selectUserIdByAcctId
(
AcctId
);
}
}
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录