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
提交
0f7347cd
提交
0f7347cd
编写于
2月 28, 2020
作者:
Chongwen.jiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
发送短信加入老业务记录风控数据接口
上级
e5e47c5e
流水线
#22157
已失败 于阶段
in 3 second
变更
4
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
89 行增加
和
19 行删除
+89
-19
pom.xml
server/pom.xml
+1
-1
ThreadPoolConfig.java
...ccount/account/server/configuration/ThreadPoolConfig.java
+31
-0
AutoCodeController.java
...account/account/server/controller/AutoCodeController.java
+47
-9
LoginServiceImpl.java
...account/account/server/service/impl/LoginServiceImpl.java
+10
-9
未找到文件。
server/pom.xml
浏览文件 @
0f7347cd
...
...
@@ -167,7 +167,7 @@
<dependency>
<groupId>
com.pica.cloud.riskcontrol
</groupId>
<artifactId>
pica-cloud-riskcontrol-client
</artifactId>
<version>
1.0.
1
</version>
<version>
1.0.
2
</version>
</dependency>
<!-- apple identifyToken校验 -->
...
...
server/src/main/java/com/pica/cloud/account/account/server/configuration/ThreadPoolConfig.java
0 → 100644
浏览文件 @
0f7347cd
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
configuration
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
java.util.concurrent.ThreadPoolExecutor
;
/**
* @Description ThreadPoolConfig
* @Author Chongwen.jiang
* @Date 2020/2/27 16:37
* @ModifyDate 2020/2/27 16:37
* @Params
* @Return
*/
@Configuration
public
class
ThreadPoolConfig
{
@Bean
(
name
=
"accountThreadPool"
)
public
ThreadPoolTaskExecutor
getExecutor
()
{
ThreadPoolTaskExecutor
executor
=
new
ThreadPoolTaskExecutor
();
executor
.
setCorePoolSize
(
3
);
executor
.
setMaxPoolSize
(
10
);
executor
.
setQueueCapacity
(
100
);
executor
.
setKeepAliveSeconds
(
60
);
executor
.
setThreadNamePrefix
(
"tims_ThreadPool"
);
executor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
executor
.
initialize
();
return
executor
;
}
}
server/src/main/java/com/pica/cloud/account/account/server/controller/AutoCodeController.java
浏览文件 @
0f7347cd
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
controller
;
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
;
...
...
@@ -31,6 +29,8 @@ 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.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
...
@@ -60,6 +60,10 @@ public class AutoCodeController extends AccountBaseController {
@Autowired
private
CheckCodeClient
rcClient
;
@Autowired
@Qualifier
(
"accountThreadPool"
)
private
ThreadPoolTaskExecutor
threadPoolTaskExecutor
;
@GetMapping
(
"/ip"
)
public
PicaResponse
getIp
(
HttpServletRequest
request
){
return
PicaResponse
.
toResponse
(
IPUtil
.
getIpAdrress
(
request
));
...
...
@@ -72,7 +76,7 @@ public class AutoCodeController extends AccountBaseController {
// 验证码类型 0默认 1注册 2微信登录绑定手机 3修改手机
// 4重置密码 5忘记密码 7患者招募提交问卷(效验) 8Appe登录绑定手机
BaseRequest
request
=
CryptoUtil
.
decrypt
(
entity
,
BaseRequest
.
class
);
AccountUtils
.
checkMobilePhone
(
request
.
getMobile
());
if
(
request
.
getBizType
()
!=
null
&&
request
.
getBizType
().
equals
(
1
))
{
// 调用风控接口
UnifiedVerificationResp
rcResp
=
this
.
rcValidate
(
...
...
@@ -83,13 +87,11 @@ public class AutoCodeController extends AccountBaseController {
request
.
getDevice_token
());
if
(
rcResp
==
null
)
{
// 风控接口调用异常也继续后面的逻辑
processSysCode
(
request
.
getMobile
(),
request
.
getFlag
());
return
PicaResponse
.
toResponse
();
return
getPicaResponse
(
request
);
}
else
{
if
(
null
==
rcResp
.
getBizCode
())
{
// 风控校验后允许发送短信验证码
processSysCode
(
request
.
getMobile
(),
request
.
getFlag
());
return
PicaResponse
.
toResponse
();
return
getPicaResponse
(
request
);
}
else
{
// 风控接口调用正常,并返回业务提示给前端
return
PicaResponse
.
toResponse
(
rcResp
);
...
...
@@ -97,14 +99,26 @@ public class AutoCodeController extends AccountBaseController {
}
}
else
{
// 老版本业务
AccountUtils
.
checkMobilePhone
(
request
.
getMobile
());
processSysCode
(
request
.
getMobile
(),
request
.
getFlag
());
// 记录风控数据
recordRcData
(
req
,
request
);
return
PicaResponse
.
toResponse
();
}
}
private
PicaResponse
getPicaResponse
(
BaseRequest
request
)
{
processSysCode
(
request
.
getMobile
(),
request
.
getFlag
());
UnifiedVerificationResp
rcResp
=
new
UnifiedVerificationResp
();
rcResp
.
setBizCode
(
1
);
rcResp
.
setBizMsg
(
"验证码发送成功"
);
return
PicaResponse
.
toResponse
(
rcResp
);
}
@ApiOperation
(
"获取短信验证码,需要图形验证码,如H5端和PC端;验证码类型 0默认 1注册 2微信登录绑定手机 3修改手机 4重置密码 5忘记密码 7患者招募提交问卷(效验)"
)
@PostMapping
(
"/account/authCode"
)
public
PicaResponse
<
String
>
getAuthCodeWithCaptcha
(
@RequestBody
EncryptEntity
entity
)
throws
Exception
{
public
PicaResponse
<
String
>
getAuthCodeWithCaptcha
(
@RequestBody
EncryptEntity
entity
,
HttpServletRequest
req
)
throws
Exception
{
BaseRequest
request
=
CryptoUtil
.
decrypt
(
entity
,
BaseRequest
.
class
);
String
mobilePhone
=
request
.
getMobile
();
String
flag
=
request
.
getFlag
()
+
""
;
...
...
@@ -127,9 +141,33 @@ public class AutoCodeController extends AccountBaseController {
logger
.
info
(
this
.
getAuthCodeKey
(
mobilePhone
,
flag
));
//发送短信
super
.
sendMobileMessage
(
mobilePhone
,
message
,
senderId
);
// 记录风控数据
recordRcData
(
req
,
request
);
return
PicaResponse
.
toResponse
(
StringUtils
.
EMPTY
);
}
/**
* @Description 记录风控数据
* @Author Chongwen.jiang
* @Date 2020/2/27 16:53
* @ModifyDate 2020/2/27 16:53
* @Params [req, request]
* @Return void
*/
private
void
recordRcData
(
HttpServletRequest
req
,
BaseRequest
request
)
{
threadPoolTaskExecutor
.
execute
(()
->
{
CheckcodeRiskReq
rec
=
new
CheckcodeRiskReq
();
rec
.
setMobile
(
request
.
getMobile
());
rec
.
setIp
(
IPUtil
.
getIpAdrress
(
req
));
rec
.
setDeviceIp
(
super
.
getDeviceInfo
(
"device_ip"
));
rec
.
setDeviceId
(
request
.
getDevice_token
());
PicaResponse
resp
=
rcClient
.
logSend
(
rec
);
logger
.
info
(
"thread execute-app-authCode resp-{}"
,
JSON
.
toJSONString
(
resp
));
});
}
@ApiOperation
(
"微信获取验证码"
)
@PostMapping
(
value
=
"/authCode/wechat"
)
public
PicaResponse
getWChatSysCode
(
@RequestBody
EncryptEntity
entity
)
throws
Exception
{
...
...
server/src/main/java/com/pica/cloud/account/account/server/service/impl/LoginServiceImpl.java
浏览文件 @
0f7347cd
...
...
@@ -662,8 +662,8 @@ public class LoginServiceImpl implements LoginService {
appleResp
=
HttpClientCloudUtils
.
getHttpExecute
(
Constants
.
APPLE_GET_PUBLIC_KEY_URL
);
//logger.info("checkIdentifyToken-appleResp:{}", appleResp);
}
catch
(
Exception
e
)
{
logger
.
info
(
"checkIdentifyToken-get apple public key fail
"
);
throw
new
PicaException
(
"get apple public key fail Exception"
,
e
.
getMessage
()
);
logger
.
info
(
"checkIdentifyToken-get apple public key fail
"
+
e
.
getMessage
()
);
throw
new
PicaException
(
"get apple public key fail Exception"
,
"get apple public key fail"
);
}
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
appleResp
);
String
keys
=
jsonObject
.
getString
(
"keys"
);
...
...
@@ -677,7 +677,8 @@ public class LoginServiceImpl implements LoginService {
Jwk
jwa
=
Jwk
.
fromValues
(
jsonObject1
);
publicKey
=
jwa
.
getPublicKey
();
}
catch
(
Exception
e
)
{
throw
new
PicaException
(
"checkIdentifyToken-generate publicKey fail"
,
e
.
getMessage
());
logger
.
info
(
"checkIdentifyToken-generate publicKey fail "
+
e
.
getMessage
());
throw
new
PicaException
(
"checkIdentifyToken-generate publicKey fail"
,
"generate publicKey fail"
);
}
// 分割前台传过来的identifyToken(jwt格式的token)用base64解码使用
if
(
identifyToken
.
split
(
"\\."
).
length
>
1
)
{
...
...
@@ -691,8 +692,8 @@ public class LoginServiceImpl implements LoginService {
// appleUserId从token中解码取出后赋值
request
.
setAppleUserId
(
sub
);
}
catch
(
Exception
e
)
{
logger
.
info
(
"checkIdentifyToken-token decode fail"
+
e
.
getMessage
());
throw
new
PicaException
(
"checkIdentifyToken-token decode fail Exception"
,
e
.
getMessage
()
);
logger
.
info
(
"checkIdentifyToken-token decode fail
"
+
e
.
getMessage
());
throw
new
PicaException
(
"checkIdentifyToken-token decode fail Exception"
,
"token decode fail"
);
}
return
this
.
verify
(
publicKey
,
identifyToken
,
aud
,
sub
,
request
);
}
...
...
@@ -725,11 +726,11 @@ public class LoginServiceImpl implements LoginService {
}
return
false
;
}
catch
(
ExpiredJwtException
e
)
{
logger
.
info
(
"checkIdentifyToken-apple token expired"
+
e
.
getMessage
());
throw
new
PicaException
(
"apple token expired Exception"
,
e
.
getMessage
()
);
logger
.
info
(
"checkIdentifyToken-apple token expired
"
+
e
.
getMessage
());
throw
new
PicaException
(
"apple token expired Exception"
,
"apple token expired"
);
}
catch
(
Exception
e
)
{
logger
.
info
(
"checkIdentifyToken-apple token illegal"
+
e
.
getMessage
());
throw
new
PicaException
(
"apple token illegal Exception"
,
e
.
getMessage
()
);
logger
.
info
(
"checkIdentifyToken-apple token illegal
"
+
e
.
getMessage
());
throw
new
PicaException
(
"apple token illegal Exception"
,
"apple token illegal"
);
}
}
...
...
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录