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
提交
166e2b76
提交
166e2b76
编写于
6月 05, 2019
作者:
dong.an
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
H5登录注册
上级
ee565e7b
流水线
#9864
已失败 于阶段
in 0 second
变更
1
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
24 行增加
和
7 行删除
+24
-7
AccountController.java
.../account/account/server/controller/AccountController.java
+24
-7
未找到文件。
server/src/main/java/com/pica/cloud/account/account/server/controller/AccountController.java
浏览文件 @
166e2b76
...
...
@@ -8,12 +8,16 @@ 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.constants.CommonConstants
;
import
com.pica.cloud.foundation.utils.entity.PicaUser
;
import
com.pica.cloud.foundation.utils.utils.CommonUtil
;
import
com.pica.cloud.foundation.utils.utils.EncryptCreateUtil
;
import
com.pica.cloud.foundation.utils.utils.ValidateUtils
;
import
com.pica.cloud.foundation.utils.utils.json.Object2Map
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -21,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Date
;
import
java.util.Map
;
import
java.util.UUID
;
/**
...
...
@@ -75,7 +80,7 @@ public class AccountController extends AccountBaseController {
//已经绑定过云鹊医账号,登录成功,返回token
String
deviceType
=
super
.
getDeviceInfo
(
"device_type"
);
//1:pc 2:android 3:ios
String
newToken
=
this
.
generateToken
(
account
.
getId
()
,
deviceType
);
String
newToken
=
this
.
generateToken
(
account
,
deviceType
);
return
PicaResponse
.
toResponse
(
newToken
);
}
...
...
@@ -110,7 +115,7 @@ public class AccountController extends AccountBaseController {
//登录成功,清除旧token,生成新token
String
deviceType
=
super
.
getDeviceInfo
(
"device_type"
);
//1:pc 2:android 3:ios
String
newToken
=
this
.
generateToken
(
account
.
getId
()
,
deviceType
);
String
newToken
=
this
.
generateToken
(
account
,
deviceType
);
return
PicaResponse
.
toResponse
(
newToken
);
}
...
...
@@ -138,7 +143,7 @@ public class AccountController extends AccountBaseController {
accountService
.
createAccount
(
account
);
//创建账号
//生成token并返回
String
newToken
=
this
.
generateToken
(
account
.
getId
()
,
deviceType
);
String
newToken
=
this
.
generateToken
(
account
,
deviceType
);
return
PicaResponse
.
toResponse
(
newToken
);
}
...
...
@@ -189,11 +194,11 @@ public class AccountController extends AccountBaseController {
}
//生成H5 token
private
String
generateH5Token
(
Long
doctorId
)
{
private
String
generateH5Token
(
Account
account
)
{
String
newToken
=
StringUtils
.
EMPTY
;
try
{
//先清除旧token
String
tokenValue
=
"token-doctor-"
+
doctorId
.
toString
();
String
tokenValue
=
"token-doctor-"
+
account
.
getId
()
.
toString
();
String
oldToken
=
redisClient
.
get
(
tokenValue
+
"-h5"
);
if
(
StringUtils
.
isNotBlank
(
oldToken
))
{
redisClient
.
del
(
oldToken
);
...
...
@@ -204,6 +209,18 @@ public class AccountController extends AccountBaseController {
String
tokenKey
=
"token-"
+
newToken
;
redisClient
.
set
(
tokenKey
,
tokenValue
,
expiredSeconds
);
redisClient
.
set
(
tokenValue
+
"-h5"
,
tokenKey
,
expiredSeconds
);
//用户数据放入缓存
String
userData
=
redisClient
.
hget
(
tokenValue
,
"id"
);
if
(
StringUtils
.
isEmpty
(
userData
))
{
PicaUser
picaUser
=
new
PicaUser
();
picaUser
.
setToken
(
newToken
);
picaUser
.
setId
(
account
.
getId
().
intValue
());
picaUser
.
setMobile
(
account
.
getMobilePhone
());
picaUser
.
setCreated_time
(
account
.
getCreatTime
());
Map
<
String
,
String
>
data
=
Object2Map
.
objectToMapString
(
"yyyy-MM-dd HH:mm:ss"
,
picaUser
,
new
String
[
0
]);
data
.
put
(
"sysCode"
,
"h5"
);
data
.
forEach
((
key
,
value
)
->
{
value
=
value
==
null
?
""
:
value
;
redisClient
.
hset
(
tokenValue
,
key
,
value
);});
}
}
catch
(
Exception
ex
)
{
logger
.
error
(
"生成H5 token异常:{}"
+
ex
.
getMessage
(),
ex
);
}
...
...
@@ -211,7 +228,7 @@ public class AccountController extends AccountBaseController {
}
//清除旧token,生成新token
private
String
generateToken
(
Long
doctorId
,
String
deviceType
)
{
private
String
generateToken
(
Account
account
,
String
deviceType
)
{
String
newToken
;
switch
(
deviceType
)
{
//设备信息
case
"1"
:
//pc
...
...
@@ -224,7 +241,7 @@ public class AccountController extends AccountBaseController {
newToken
=
StringUtils
.
EMPTY
;
break
;
default
:
//H5
newToken
=
this
.
generateH5Token
(
doctorId
);
newToken
=
this
.
generateH5Token
(
account
);
}
return
newToken
;
}
...
...
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录