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
提交
95a6a0af
提交
95a6a0af
编写于
7月 07, 2022
作者:
xinxu.wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
小程序授权登录之后,获取用户token
上级
201369a0
流水线
#48358
已失败 于阶段
变更
4
流水线
1
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
225 行增加
和
0 行删除
+225
-0
pom.xml
server/pom.xml
+6
-0
AccountController.java
.../account/account/server/controller/AccountController.java
+42
-0
LoginController.java
...ud/account/account/server/controller/LoginController.java
+39
-0
AesAuthCodeAppletReq.java
...t/account/server/entity/AesBean/AesAuthCodeAppletReq.java
+138
-0
未找到文件。
server/pom.xml
浏览文件 @
95a6a0af
...
...
@@ -284,6 +284,12 @@
<artifactId>
pica-cloud-message-client
</artifactId>
<version>
1.0.6-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
com.pica.cloud.wechat
</groupId>
<artifactId>
pica-cloud-applet-client
</artifactId>
<version>
1.1.0
</version>
</dependency>
</dependencies>
<dependencyManagement>
...
...
server/src/main/java/com/pica/cloud/account/account/server/controller/AccountController.java
浏览文件 @
95a6a0af
...
...
@@ -25,8 +25,12 @@ import com.pica.cloud.foundation.service.starter.interceptor.EnabledLoginValidat
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.StringUtil
;
import
com.pica.cloud.foundation.utils.utils.ValidateUtils
;
import
com.pica.cloud.foundation.utils.utils.json.Object2Map
;
import
com.pica.cloud.wechat.applet.client.AppletServiceClient
;
import
com.pica.cloud.wechat.applet.common.model.AppletModel
;
import
com.pica.cloud.wechat.applet.common.req.AppletReq
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
...
...
@@ -67,6 +71,9 @@ public class AccountController extends AccountBaseController {
@Autowired
private
DoctorService
doctorService
;
@Autowired
private
AppletServiceClient
appletServiceClient
;
@GetMapping
(
"/test"
)
public
String
test
()
{
return
"{\"status\":\"UP\"}"
;
...
...
@@ -98,6 +105,41 @@ public class AccountController extends AccountBaseController {
return
PicaResponse
.
toResponse
(
StringUtils
.
EMPTY
);
}
@ApiOperation
(
"获取登录验证码"
)
@GetMapping
(
"/authCode/applet"
)
public
PicaResponse
<
String
>
getAuthCodeApplet
(
@ApiParam
(
value
=
"手机号"
,
required
=
true
)
@RequestParam
(
"mobilePhone"
)
String
mobilePhone
,
@ApiParam
(
value
=
"验证码类型 0默认 1注册 2修改密码 4微信登录绑定手机 5修改手机 6重置密码 7患者招募提交问卷(效验"
)
@RequestParam
(
value
=
"flag"
,
defaultValue
=
"0"
)
String
flag
,
@ApiParam
(
value
=
"小程序code"
,
required
=
true
)
@RequestParam
(
"code"
)
String
code
,
@ApiParam
(
value
=
"小程序类型"
,
required
=
true
)
@RequestParam
(
"type"
)
Integer
type
)
{
AppletReq
appletReq
=
new
AppletReq
();
appletReq
.
setCode
(
code
);
appletReq
.
setType
(
type
);
AppletModel
appletModel
=
appletServiceClient
.
code2Session
(
appletReq
).
getData
();
if
(
StringUtil
.
isNull
(
appletModel
)
||
StringUtil
.
isNull
(
appletModel
.
getUnionId
()))
{
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"小程序code解密失败"
);
}
this
.
checkMobilePhone
(
mobilePhone
);
String
authCode
=
CommonUtil
.
createValidateCode
();
//随机生成验证码
String
message
=
"您的验证码是"
+
authCode
+
",在10分钟内有效。如非本人操作,请忽略本短信!"
;
long
senderId
=
0L
;
if
(
Integer
.
parseInt
(
flag
)
!=
7
)
{
//判断账号是否已经存在
Account
account
=
accountService
.
getByMobilePhone
(
mobilePhone
);
if
(
StringUtil
.
isNull
(
account
))
{
throw
new
PicaException
(
PicaResultCode
.
RESULE_DATA_NONE
.
code
(),
"请先至云鹊医App注册认证后使用"
);
}
senderId
=
account
==
null
?
0L
:
account
.
getId
();
}
//验证码保存到redis,失效时间10分钟
redisClient
.
set
(
this
.
getAuthCodeKey
(
mobilePhone
,
flag
),
authCode
,
600
);
//发送短信
super
.
sendMobileMessage
(
mobilePhone
,
message
,
senderId
);
return
PicaResponse
.
toResponse
(
StringUtils
.
EMPTY
);
}
@ApiOperation
(
"教培项目校验短信验证码"
)
@GetMapping
(
"/check/authCode"
)
public
PicaResponse
checkAuthCode
(
@ApiParam
(
value
=
"手机号"
,
required
=
true
)
@RequestParam
(
"mobilePhone"
)
String
mobilePhone
,
...
...
server/src/main/java/com/pica/cloud/account/account/server/controller/LoginController.java
浏览文件 @
95a6a0af
...
...
@@ -3,6 +3,7 @@ package com.pica.cloud.account.account.server.controller;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.pica.cloud.account.account.common.req.LoginAppletReq
;
import
com.pica.cloud.account.account.server.entity.AesBean.AesAuthCodeAppletReq
;
import
com.pica.cloud.account.account.server.entity.AesBean.AesAuthCodeReq
;
import
com.pica.cloud.account.account.server.entity.*
;
import
com.pica.cloud.account.account.server.enums.AccountExceptionEnum
;
...
...
@@ -26,6 +27,9 @@ import com.pica.cloud.foundation.redis.ICacheClient;
import
com.pica.cloud.foundation.service.starter.interceptor.EnabledLoginValidate
;
import
com.pica.cloud.foundation.utils.annotation.LoginPermission
;
import
com.pica.cloud.foundation.utils.utils.StringUtil
;
import
com.pica.cloud.wechat.applet.client.AppletServiceClient
;
import
com.pica.cloud.wechat.applet.common.model.AppletModel
;
import
com.pica.cloud.wechat.applet.common.req.AppletReq
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.catalina.servlet4preview.http.HttpServletRequest
;
...
...
@@ -76,6 +80,10 @@ public class LoginController extends AccountBaseController {
private
IntactUtil
intactUtil
;
@Autowired
private
TokenUtils
tokenUtils
;
@Autowired
private
AppletServiceClient
appletServiceClient
;
/**
* 密码登录接口(app、H5、web)
*
...
...
@@ -553,7 +561,38 @@ public class LoginController extends AccountBaseController {
account1
.
setRegisterSource
(
4
);
String
newToken
=
tokenUtils
.
generateToken
(
account1
);
int
expiredSeconds
=
24
*
60
*
60
*
30
;
cacheClient
.
set
(
"token-doctor-unionid-"
+
req
.
getUnionid
(),
newToken
,
expiredSeconds
);
cacheClient
.
set
(
"token-unionid-"
+
newToken
,
req
.
getUnionid
(),
expiredSeconds
);
intactUtil
.
sendIntact
(
batchNo
,
"login/applet"
,
com
.
pica
.
cloud
.
foundation
.
completeness
.
contract
.
constants
.
CommonConstants
.
INTACT_CONTENT_LOG_STATUS_3
,
"req:"
+
JSON
.
toJSONString
(
req
));
return
PicaResponse
.
toResponse
(
newToken
);
}
@ApiOperation
(
"云鹊医助手小程序授权登录"
)
@PostMapping
(
"/login/applet/authCode"
)
public
PicaResponse
<
LoginResult
>
loginAppletAuthCode
(
@RequestBody
AesAuthCodeAppletReq
authCodeReq
)
{
AppletReq
appletReq
=
new
AppletReq
();
appletReq
.
setCode
(
authCodeReq
.
getCode
());
appletReq
.
setType
(
authCodeReq
.
getType
());
AppletModel
appletModel
=
appletServiceClient
.
code2Session
(
appletReq
).
getData
();
if
(
StringUtil
.
isNull
(
appletModel
)
||
StringUtil
.
isNull
(
appletModel
.
getUnionId
()))
{
throw
new
PicaException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
"小程序code解密失败"
);
}
BaseRequest
request
=
new
BaseRequest
();
request
.
setMobile
(
authCodeReq
.
getMobile
());
request
.
setAuthCode
(
authCodeReq
.
getAuthCode
());
logger
.
info
(
"login-register:{}"
,
JSONObject
.
toJSONString
(
request
));
request
.
setProductType
(
1
);
request
.
setSourceType
(
4
);
request
.
setLoginIp
(
super
.
getIpAddr
());
request
.
setUserTokenTourist
(
super
.
getUserTokenTourist
());
LoginResult
login
=
loginService
.
loginAndRegister
(
request
);
if
(
StringUtil
.
isNotNull
(
login
))
{
int
expiredSeconds
=
24
*
60
*
60
*
30
;
cacheClient
.
set
(
"token-doctor-unionid-"
+
appletModel
.
getUnionId
(),
login
.
getToken
(),
expiredSeconds
);
cacheClient
.
set
(
"token-unionid-"
+
login
.
getToken
(),
appletModel
.
getUnionId
(),
expiredSeconds
);
}
return
PicaResponse
.
toResponse
(
login
);
}
}
server/src/main/java/com/pica/cloud/account/account/server/entity/AesBean/AesAuthCodeAppletReq.java
0 → 100644
浏览文件 @
95a6a0af
// Copyright 2016-2101 Pica.
package
com
.
pica
.
cloud
.
account
.
account
.
server
.
entity
.
AesBean
;
/**
* @ClassName AesAuthCodeAppletReq
* @Description TODO
* @Author xinxu.wang
* @Date 2022/7/5 18:33
* @ModifyDate 2022/7/5 18:33
* @Version 1.0
*/
public
class
AesAuthCodeAppletReq
{
private
Integer
bizType
;
private
String
device_token
;
private
String
mobile
;
private
Integer
flag
;
private
String
token
;
private
String
authCode
;
private
String
password
;
private
String
code
;
private
Integer
type
;
/**
* 加密后的密文
*/
private
String
key
;
/**
* 加密后的数据
*/
private
String
content
;
// 是否需要校验该设备登录的手机号
private
Boolean
checkFlag
=
false
;
public
Integer
getType
()
{
return
type
;
}
public
void
setType
(
Integer
type
)
{
this
.
type
=
type
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
Boolean
getCheckFlag
()
{
return
checkFlag
;
}
public
void
setCheckFlag
(
Boolean
checkFlag
)
{
this
.
checkFlag
=
checkFlag
;
}
public
Integer
getBizType
()
{
return
bizType
;
}
public
void
setBizType
(
Integer
bizType
)
{
this
.
bizType
=
bizType
;
}
public
String
getDevice_token
()
{
return
device_token
;
}
public
void
setDevice_token
(
String
device_token
)
{
this
.
device_token
=
device_token
;
}
public
String
getMobile
()
{
return
mobile
;
}
public
void
setMobile
(
String
mobile
)
{
this
.
mobile
=
mobile
;
}
public
Integer
getFlag
()
{
return
flag
;
}
public
void
setFlag
(
Integer
flag
)
{
this
.
flag
=
flag
;
}
public
String
getKey
()
{
return
key
;
}
public
void
setKey
(
String
key
)
{
this
.
key
=
key
;
}
public
String
getContent
()
{
return
content
;
}
public
void
setContent
(
String
content
)
{
this
.
content
=
content
;
}
public
String
getToken
()
{
return
token
;
}
public
void
setToken
(
String
token
)
{
this
.
token
=
token
;
}
public
String
getAuthCode
()
{
return
authCode
;
}
public
void
setAuthCode
(
String
authCode
)
{
this
.
authCode
=
authCode
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
}
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录