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
提交
cdb46f13
提交
cdb46f13
编写于
10月 14, 2019
作者:
rushui.chen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
“20191014 患者招募短信验证码逻辑处理
上级
58ea0329
流水线
#15749
已失败 于阶段
in 0 second
变更
1
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
18 行增加
和
8 行删除
+18
-8
AccountController.java
.../account/account/server/controller/AccountController.java
+18
-8
未找到文件。
server/src/main/java/com/pica/cloud/account/account/server/controller/AccountController.java
浏览文件 @
cdb46f13
...
@@ -24,12 +24,14 @@ import org.slf4j.LoggerFactory;
...
@@ -24,12 +24,14 @@ 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.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.UUID
;
/**
/**
* 账号相关controller
* 账号相关controller
*
* @author andong
* @author andong
* @create 2019/5/20
* @create 2019/5/20
*/
*/
...
@@ -49,12 +51,14 @@ public class AccountController extends AccountBaseController {
...
@@ -49,12 +51,14 @@ public class AccountController extends AccountBaseController {
private
ICacheClient
redisClient
;
private
ICacheClient
redisClient
;
@GetMapping
(
"/test"
)
@GetMapping
(
"/test"
)
public
String
test
()
{
return
"test"
;}
public
String
test
()
{
return
"test"
;
}
@ApiOperation
(
"获取登录验证码"
)
@ApiOperation
(
"获取登录验证码"
)
@GetMapping
(
"/authCode"
)
@GetMapping
(
"/authCode"
)
public
PicaResponse
<
String
>
getAuthCode
(
@ApiParam
(
value
=
"手机号"
,
required
=
true
)
@RequestParam
(
"mobilePhone"
)
String
mobilePhone
,
public
PicaResponse
<
String
>
getAuthCode
(
@ApiParam
(
value
=
"手机号"
,
required
=
true
)
@RequestParam
(
"mobilePhone"
)
String
mobilePhone
,
@ApiParam
(
value
=
"验证码类型 0默认 1注册 2修改密码 4微信登录绑定手机 5修改手机 6重置密码"
)
@RequestParam
(
value
=
"flag"
,
defaultValue
=
"0"
)
String
flag
,
@ApiParam
(
value
=
"验证码类型 0默认 1注册 2修改密码 4微信登录绑定手机 5修改手机 6重置密码
7患者招募提交问卷(效验
"
)
@RequestParam
(
value
=
"flag"
,
defaultValue
=
"0"
)
String
flag
,
@ApiParam
(
value
=
"图形验证码token"
,
required
=
true
)
@RequestParam
(
"captchaToken"
)
String
captchaToken
,
@ApiParam
(
value
=
"图形验证码token"
,
required
=
true
)
@RequestParam
(
"captchaToken"
)
String
captchaToken
,
@ApiParam
(
value
=
"图形验证码答案"
,
required
=
true
)
@RequestParam
(
"captchaAnswer"
)
String
captchaAnswer
)
{
@ApiParam
(
value
=
"图形验证码答案"
,
required
=
true
)
@RequestParam
(
"captchaAnswer"
)
String
captchaAnswer
)
{
//校验图形验证码
//校验图形验证码
...
@@ -64,9 +68,12 @@ public class AccountController extends AccountBaseController {
...
@@ -64,9 +68,12 @@ public class AccountController extends AccountBaseController {
this
.
checkMobilePhone
(
mobilePhone
);
this
.
checkMobilePhone
(
mobilePhone
);
String
authCode
=
CommonUtil
.
createValidateCode
();
//随机生成验证码
String
authCode
=
CommonUtil
.
createValidateCode
();
//随机生成验证码
String
message
=
"您的验证码是"
+
authCode
+
",在10分钟内有效。如非本人操作,请忽略本短信!"
;
String
message
=
"您的验证码是"
+
authCode
+
",在10分钟内有效。如非本人操作,请忽略本短信!"
;
//判断账号是否已经存在
long
senderId
=
0L
;
Account
account
=
accountService
.
getByMobilePhone
(
mobilePhone
);
if
(
Integer
.
parseInt
(
flag
)
!=
7
)
{
long
senderId
=
account
==
null
?
0L
:
account
.
getId
();
//判断账号是否已经存在
Account
account
=
accountService
.
getByMobilePhone
(
mobilePhone
);
senderId
=
account
==
null
?
0L
:
account
.
getId
();
}
//验证码保存到redis,失效时间10分钟
//验证码保存到redis,失效时间10分钟
redisClient
.
set
(
this
.
getAuthCodeKey
(
mobilePhone
,
flag
),
authCode
,
600
);
redisClient
.
set
(
this
.
getAuthCodeKey
(
mobilePhone
,
flag
),
authCode
,
600
);
//发送短信
//发送短信
...
@@ -212,7 +219,7 @@ public class AccountController extends AccountBaseController {
...
@@ -212,7 +219,7 @@ public class AccountController extends AccountBaseController {
redisClient
.
del
(
oldToken
);
redisClient
.
del
(
oldToken
);
}
}
//生成新token
//生成新token
int
expiredSeconds
=
30
*
24
*
60
*
60
;
//H5 token有效期30天
int
expiredSeconds
=
30
*
24
*
60
*
60
;
//H5 token有效期30天
newToken
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
).
toUpperCase
();
newToken
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
).
toUpperCase
();
String
tokenKey
=
"token-"
+
newToken
;
String
tokenKey
=
"token-"
+
newToken
;
redisClient
.
set
(
tokenKey
,
tokenValue
,
expiredSeconds
);
redisClient
.
set
(
tokenKey
,
tokenValue
,
expiredSeconds
);
...
@@ -224,11 +231,14 @@ public class AccountController extends AccountBaseController {
...
@@ -224,11 +231,14 @@ public class AccountController extends AccountBaseController {
picaUser
.
setToken
(
newToken
);
picaUser
.
setToken
(
newToken
);
picaUser
.
setId
(
account
.
getId
().
intValue
());
picaUser
.
setId
(
account
.
getId
().
intValue
());
picaUser
.
setMobile
(
account
.
getMobilePhone
());
picaUser
.
setMobile
(
account
.
getMobilePhone
());
picaUser
.
setName
(
EncryptUtils
.
decryptContent
(
account
.
getMobilePhone
(),
EncryptConstants
.
ENCRYPT_TYPE_MOBILE
,
EncryptConstants
.
ENCRYPT_DECRYPT_KEY
).
replaceAll
(
"(\\d{3})\\d{4}(\\w{4})"
,
"$1****$2"
));
picaUser
.
setName
(
EncryptUtils
.
decryptContent
(
account
.
getMobilePhone
(),
EncryptConstants
.
ENCRYPT_TYPE_MOBILE
,
EncryptConstants
.
ENCRYPT_DECRYPT_KEY
).
replaceAll
(
"(\\d{3})\\d{4}(\\w{4})"
,
"$1****$2"
));
picaUser
.
setCreated_time
(
account
.
getCreatTime
());
picaUser
.
setCreated_time
(
account
.
getCreatTime
());
Map
<
String
,
String
>
data
=
Object2Map
.
objectToMapString
(
"yyyy-MM-dd HH:mm:ss"
,
picaUser
,
new
String
[
0
]);
Map
<
String
,
String
>
data
=
Object2Map
.
objectToMapString
(
"yyyy-MM-dd HH:mm:ss"
,
picaUser
,
new
String
[
0
]);
data
.
put
(
"sysCode"
,
"h5"
);
data
.
put
(
"sysCode"
,
"h5"
);
data
.
forEach
((
key
,
value
)
->
{
value
=
value
==
null
?
""
:
value
;
redisClient
.
hset
(
tokenValue
,
key
,
value
);});
data
.
forEach
((
key
,
value
)
->
{
value
=
value
==
null
?
""
:
value
;
redisClient
.
hset
(
tokenValue
,
key
,
value
);
});
}
}
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
logger
.
error
(
"生成H5 token异常:{}"
+
ex
.
getMessage
(),
ex
);
logger
.
error
(
"生成H5 token异常:{}"
+
ex
.
getMessage
(),
ex
);
...
...
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录