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
提交
e50f1f0a
提交
e50f1f0a
编写于
10月 29, 2019
作者:
rushui.chen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
20191029 接口幂等性
上级
d7475b2a
流水线
#16439
已失败 于阶段
in 0 second
变更
3
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
111 行增加
和
104 行删除
+111
-104
PasswordController.java
...account/account/server/controller/PasswordController.java
+0
-1
RegisterController.java
...account/account/server/controller/RegisterController.java
+13
-27
RegisterServiceImpl.java
...ount/account/server/service/impl/RegisterServiceImpl.java
+98
-76
未找到文件。
server/src/main/java/com/pica/cloud/account/account/server/controller/PasswordController.java
浏览文件 @
e50f1f0a
...
@@ -48,7 +48,6 @@ public class PasswordController extends AccountBaseController {
...
@@ -48,7 +48,6 @@ public class PasswordController extends AccountBaseController {
@PostMapping
(
value
=
"/modify"
)
@PostMapping
(
value
=
"/modify"
)
public
PicaResponse
modifyPassword
(
@RequestBody
EncryptEntity
entity
)
throws
Exception
{
public
PicaResponse
modifyPassword
(
@RequestBody
EncryptEntity
entity
)
throws
Exception
{
Long
doctorId
=
super
.
getDoctorIdByToken
();
Long
doctorId
=
super
.
getDoctorIdByToken
();
// AESUtil.encryptV0(picaUser.getMobile())
Doctor
doctorInfo
=
doctorService
.
getDoctorInfo
(
doctorId
.
intValue
());
Doctor
doctorInfo
=
doctorService
.
getDoctorInfo
(
doctorId
.
intValue
());
String
mobile
=
doctorInfo
.
getMobilePhone
();
String
mobile
=
doctorInfo
.
getMobilePhone
();
AccountInfoEntity
accountInfoEntity
=
accountInfoDetailMapper
.
selectByMobile
(
mobile
);
AccountInfoEntity
accountInfoEntity
=
accountInfoDetailMapper
.
selectByMobile
(
mobile
);
...
...
server/src/main/java/com/pica/cloud/account/account/server/controller/RegisterController.java
浏览文件 @
e50f1f0a
...
@@ -29,7 +29,7 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -29,7 +29,7 @@ import org.springframework.web.bind.annotation.RestController;
public
class
RegisterController
extends
AccountBaseController
{
public
class
RegisterController
extends
AccountBaseController
{
private
final
String
REPEAT_REGISTER_PREFIX
=
"repeat-register—"
;
@Autowired
@Autowired
private
RegisterService
registerService
;
private
RegisterService
registerService
;
...
@@ -47,32 +47,18 @@ public class RegisterController extends AccountBaseController {
...
@@ -47,32 +47,18 @@ public class RegisterController extends AccountBaseController {
BaseRequest
request
=
CryptoUtil
.
decrypt
(
entity
,
BaseRequest
.
class
);
BaseRequest
request
=
CryptoUtil
.
decrypt
(
entity
,
BaseRequest
.
class
);
String
mobile
=
request
.
getMobile
();
String
mobile
=
request
.
getMobile
();
//接口幂等性处理(redis中没有就进行注册逻辑,如果已经存在,就不处理)
//接口幂等性处理(redis中没有就进行注册逻辑,如果已经存在,就不处理)
String
exist
=
redisClient
.
get
(
REPEAT_REGISTER_PREFIX
+
mobile
);
String
authCode
=
request
.
getAuthCode
();
if
(
StringUtils
.
isBlank
(
exist
))
{
String
flag
=
AccountTypeEnum
.
SYSCODE_TYPE_REGISTER
.
getCode
()
+
""
;
String
authCode
=
request
.
getAuthCode
();
accountUtils
.
checkMobilePhoneAndAuthCode
(
mobile
,
flag
,
authCode
);
String
flag
=
AccountTypeEnum
.
SYSCODE_TYPE_REGISTER
.
getCode
()
+
""
;
accountUtils
.
checkPassword
(
request
.
getPassword
());
accountUtils
.
checkMobilePhoneAndAuthCode
(
mobile
,
flag
,
authCode
);
accountUtils
.
checkPassword
(
request
.
getPassword
());
LoginResult
result
=
null
;
redisClient
.
set
(
REPEAT_REGISTER_PREFIX
+
mobile
,
mobile
,
30
);
request
.
setFlag
(
AccountTypeEnum
.
SYSCODE_TYPE_REGISTER
.
getCode
());
LoginResult
result
=
null
;
request
.
setProductType
(
super
.
getProductType
());
try
{
request
.
setSourceType
(
super
.
getSourceType
());
request
.
setFlag
(
AccountTypeEnum
.
SYSCODE_TYPE_REGISTER
.
getCode
());
request
.
setLoginIp
(
super
.
getIpAddr
());
request
.
setProductType
(
super
.
getProductType
());
result
=
registerService
.
register
(
request
);
request
.
setSourceType
(
super
.
getSourceType
());
return
PicaResponse
.
toResponse
(
result
);
request
.
setLoginIp
(
super
.
getIpAddr
());
result
=
registerService
.
register
(
request
);
}
catch
(
Exception
e
)
{
//向上抛出异常,让异常处理框架捕获到
throw
new
AccountException
(
AccountExceptionEnum
.
PICA_REGISTER_FAIL
);
}
finally
{
//如果在注册过程中抛出异常,就删除redis中的注册标记
redisClient
.
del
(
REPEAT_REGISTER_PREFIX
+
mobile
);
}
redisClient
.
del
(
REPEAT_REGISTER_PREFIX
+
mobile
);
return
PicaResponse
.
toResponse
(
result
);
}
else
{
return
PicaResponse
.
toResponse
(
null
,
AccountExceptionEnum
.
PICA_ALREADY_REGISTER
.
getCode
(),
"正在注册中,请勿重复提交"
);
}
}
}
//"sourceType":6 表示长海项目
//"sourceType":6 表示长海项目
...
...
server/src/main/java/com/pica/cloud/account/account/server/service/impl/RegisterServiceImpl.java
浏览文件 @
e50f1f0a
...
@@ -16,10 +16,13 @@ import com.pica.cloud.account.account.server.util.AESUtil;
...
@@ -16,10 +16,13 @@ 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.AccountUtils
;
import
com.pica.cloud.account.account.server.util.ExecutorServiceUtils
;
import
com.pica.cloud.account.account.server.util.ExecutorServiceUtils
;
import
com.pica.cloud.account.account.server.util.TokenUtils
;
import
com.pica.cloud.account.account.server.util.TokenUtils
;
import
com.pica.cloud.foundation.entity.PicaResponse
;
import
com.pica.cloud.foundation.redis.ICacheClient
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
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.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
...
@@ -31,6 +34,8 @@ import java.util.concurrent.ExecutorService;
...
@@ -31,6 +34,8 @@ import java.util.concurrent.ExecutorService;
@Service
@Service
public
class
RegisterServiceImpl
implements
RegisterService
{
public
class
RegisterServiceImpl
implements
RegisterService
{
private
final
String
REPEAT_REGISTER_PREFIX
=
"repeat-register—"
;
private
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
private
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
@Autowired
@Autowired
...
@@ -61,7 +66,8 @@ public class RegisterServiceImpl implements RegisterService {
...
@@ -61,7 +66,8 @@ public class RegisterServiceImpl implements RegisterService {
private
AgreementLogEntityMapper
agreementLogEntityMapper
;
private
AgreementLogEntityMapper
agreementLogEntityMapper
;
@Autowired
@Autowired
private
DoctorMapper
doctorMapper
;
@Qualifier
(
"cacheMigrateClient"
)
private
ICacheClient
redisClient
;
/**
/**
* 1)注册功能:默认未完善信息;
* 1)注册功能:默认未完善信息;
...
@@ -74,83 +80,99 @@ public class RegisterServiceImpl implements RegisterService {
...
@@ -74,83 +80,99 @@ public class RegisterServiceImpl implements RegisterService {
@Override
@Override
public
LoginResult
register
(
BaseRequest
baseRequest
)
{
public
LoginResult
register
(
BaseRequest
baseRequest
)
{
String
mobile
=
baseRequest
.
getMobile
();
String
mobile
=
baseRequest
.
getMobile
();
String
mobileEncrypt
=
AESUtil
.
encryptV0
(
mobile
);
//对注册接口做幂等性处理:注册成功,删除缓存,注册失败提示用户
AccountInfoEntity
accountInfoEntity
=
accountInfoDetailMapper
.
selectByMobile
(
mobileEncrypt
);
String
exist
=
redisClient
.
get
(
REPEAT_REGISTER_PREFIX
+
mobile
);
if
(
accountInfoEntity
==
null
)
{
if
(
StringUtils
.
isBlank
(
exist
))
{
Date
currentTime
=
new
Date
();
String
mobileEncrypt
=
AESUtil
.
encryptV0
(
mobile
);
int
productType
=
baseRequest
.
getProductType
();
AccountInfoEntity
accountInfoEntity
=
accountInfoDetailMapper
.
selectByMobile
(
mobileEncrypt
);
int
sourceType
=
baseRequest
.
getSourceType
();
if
(
accountInfoEntity
==
null
)
{
String
password
=
baseRequest
.
getPassword
();
redisClient
.
set
(
REPEAT_REGISTER_PREFIX
+
mobile
,
mobile
,
30
);
AccountInfoEntity
accountInfo
=
new
AccountInfoEntity
();
try
{
accountInfo
.
setMobilePhone
(
mobileEncrypt
);
Date
currentTime
=
new
Date
();
if
(
StringUtils
.
isEmpty
(
password
))
{
int
productType
=
baseRequest
.
getProductType
();
password
=
""
;
int
sourceType
=
baseRequest
.
getSourceType
();
}
String
password
=
baseRequest
.
getPassword
();
accountInfo
.
setPassword
(
password
);
AccountInfoEntity
accountInfo
=
new
AccountInfoEntity
();
accountInfo
.
setCreatedTime
(
currentTime
);
accountInfo
.
setMobilePhone
(
mobileEncrypt
);
accountInfo
.
setCreatedId
(
0
);
if
(
StringUtils
.
isEmpty
(
password
))
{
accountInfo
.
setModifiedId
(
0
);
password
=
""
;
accountInfo
.
setModifiedTime
(
currentTime
);
}
accountInfo
.
setRegTime
(
currentTime
);
accountInfo
.
setPassword
(
password
);
accountInfo
.
setDeleteFlag
(
1
);
accountInfo
.
setCreatedTime
(
currentTime
);
accountInfo
.
setSex
(
0
);
accountInfo
.
setCreatedId
(
0
);
accountInfo
.
setRegisterProduct
(
productType
);
accountInfo
.
setModifiedId
(
0
);
accountInfo
.
setRegisterSource
(
sourceType
);
accountInfo
.
setModifiedTime
(
currentTime
);
accountInfoDetailMapper
.
insertSelective
(
accountInfo
);
accountInfo
.
setRegTime
(
currentTime
);
Integer
acctId
=
accountInfo
.
getId
();
accountInfo
.
setDeleteFlag
(
1
);
accountInfoDetailMapper
.
updateCreateInfo
(
acctId
);
accountInfo
.
setSex
(
0
);
if
(
productType
==
AccountTypeEnum
.
PRODUCT_TYPE_HEALTH
.
getCode
())
{
accountInfo
.
setRegisterProduct
(
productType
);
AccountPatientInfoEntity
accountPatientInfoEntity
=
new
AccountPatientInfoEntity
();
accountInfo
.
setRegisterSource
(
sourceType
);
accountPatientInfoEntity
.
setAcctId
(
acctId
);
accountInfoDetailMapper
.
insertSelective
(
accountInfo
);
accountPatientInfoEntity
.
setDeleteFlag
(
1
);
Integer
acctId
=
accountInfo
.
getId
();
accountPatientInfoEntity
.
setCreateId
(
acctId
);
accountInfoDetailMapper
.
updateCreateInfo
(
acctId
);
accountPatientInfoEntity
.
setModifyId
(
acctId
);
if
(
productType
==
AccountTypeEnum
.
PRODUCT_TYPE_HEALTH
.
getCode
())
{
accountPatientInfoEntity
.
setCreateTime
(
currentTime
);
AccountPatientInfoEntity
accountPatientInfoEntity
=
new
AccountPatientInfoEntity
();
accountPatientInfoEntity
.
setModifyTime
(
currentTime
);
accountPatientInfoEntity
.
setAcctId
(
acctId
);
accountUserInfoMapper
.
insertSelective
(
accountPatientInfoEntity
);
accountPatientInfoEntity
.
setDeleteFlag
(
1
);
accountPatientInfoEntity
.
setCreateId
(
acctId
);
accountPatientInfoEntity
.
setModifyId
(
acctId
);
accountPatientInfoEntity
.
setCreateTime
(
currentTime
);
accountPatientInfoEntity
.
setModifyTime
(
currentTime
);
accountUserInfoMapper
.
insertSelective
(
accountPatientInfoEntity
);
}
else
{
Account
account
=
new
Account
();
account
.
setAcctId
(
acctId
);
account
.
setMobilePhone
(
mobileEncrypt
);
account
.
setDeleteFlag
(
1
);
account
.
setCreatId
(
0L
);
account
.
setModifyId
(
0L
);
account
.
setCreatTime
(
currentTime
);
account
.
setModifyTime
(
currentTime
);
account
.
setFirstLoginTime
(
currentTime
);
account
.
setLastLoginTime
(
currentTime
);
account
.
setPassword
(
password
);
accountMapper
.
insertSelective
(
account
);
}
Long
userId
=
accountUtils
.
getUserIdByAcctId
(
productType
,
acctId
);
Account
account
=
new
Account
();
account
.
setId
(
userId
);
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
);
result
.
setEntireFlag
(
1
);
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
();
DataOutputStream
dos
=
new
DataOutputStream
(
bos
);
try
{
dos
.
writeLong
(
userId
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
queueProducer
.
send
(
bos
.
toByteArray
());
LogLoginEntity
entity
=
AccountLogEntityUtils
.
getLogLoginEntity
(
acctId
,
productType
,
baseRequest
.
getSourceType
(),
AccountTypeEnum
.
LOGIN_REGISTER
.
getCode
(),
baseRequest
.
getLoginIp
(),
AccountTypeEnum
.
LOGIN_STATUS_SUCCESS
.
getCode
(),
AccountTypeEnum
.
LOG_TYPE_LOGIN
.
getCode
());
picaLogUtils
.
info
(
entity
);
processAgreement
(
userId
);
redisClient
.
del
(
REPEAT_REGISTER_PREFIX
+
mobile
);
return
result
;
}
catch
(
Exception
e
)
{
//向上抛出异常,让异常处理框架捕获到
throw
new
AccountException
(
AccountExceptionEnum
.
PICA_REGISTER_FAIL
);
}
finally
{
//如果在注册过程中抛出异常,就删除redis中的注册标记
redisClient
.
del
(
REPEAT_REGISTER_PREFIX
+
mobile
);
}
}
else
{
}
else
{
Account
account
=
new
Account
();
throw
new
AccountException
(
AccountExceptionEnum
.
PICA_ALREADY_REGISTER
);
account
.
setAcctId
(
acctId
);
account
.
setMobilePhone
(
mobileEncrypt
);
account
.
setDeleteFlag
(
1
);
account
.
setCreatId
(
0L
);
account
.
setModifyId
(
0L
);
account
.
setCreatTime
(
currentTime
);
account
.
setModifyTime
(
currentTime
);
account
.
setFirstLoginTime
(
currentTime
);
account
.
setLastLoginTime
(
currentTime
);
account
.
setPassword
(
password
);
accountMapper
.
insertSelective
(
account
);
}
Long
userId
=
accountUtils
.
getUserIdByAcctId
(
productType
,
acctId
);
Account
account
=
new
Account
();
account
.
setId
(
userId
);
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
);
result
.
setEntireFlag
(
1
);
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
();
DataOutputStream
dos
=
new
DataOutputStream
(
bos
);
try
{
dos
.
writeLong
(
userId
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
queueProducer
.
send
(
bos
.
toByteArray
());
LogLoginEntity
entity
=
AccountLogEntityUtils
.
getLogLoginEntity
(
acctId
,
productType
,
baseRequest
.
getSourceType
(),
AccountTypeEnum
.
LOGIN_REGISTER
.
getCode
(),
baseRequest
.
getLoginIp
(),
AccountTypeEnum
.
LOGIN_STATUS_SUCCESS
.
getCode
(),
AccountTypeEnum
.
LOG_TYPE_LOGIN
.
getCode
());
picaLogUtils
.
info
(
entity
);
processAgreement
(
userId
);
return
result
;
}
else
{
}
else
{
throw
new
AccountException
(
AccountExceptionEnum
.
PICA_ALREADY_REGISTER
);
throw
new
AccountException
(
AccountExceptionEnum
.
PICA_ALREADY_REGISTER
);
}
}
}
}
...
@@ -204,7 +226,7 @@ public class RegisterServiceImpl implements RegisterService {
...
@@ -204,7 +226,7 @@ public class RegisterServiceImpl implements RegisterService {
doctorServiceClient.prefectInfo(prefectInfoReq);
doctorServiceClient.prefectInfo(prefectInfoReq);
*/
*/
}
else
{
}
else
{
throw
new
AccountException
(
AccountExceptionEnum
.
PICA_ALREADY_REGISTER
.
getCode
(),
AccountExceptionEnum
.
PICA_ALREADY_REGISTER
.
getCode
());
throw
new
AccountException
(
AccountExceptionEnum
.
PICA_ALREADY_REGISTER
.
getCode
(),
AccountExceptionEnum
.
PICA_ALREADY_REGISTER
.
getCode
());
}
}
}
}
...
...
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录