记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董敬伟
liquidnet-bus-v1
Commits
30a9c638
Commit
30a9c638
authored
Jul 12, 2021
by
张国柄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发送验证码更换JAVA-API;
parent
a6bc4291
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
164 additions
and
143 deletions
+164
-143
AdamRedisConst.java
...a/com/liquidnet/service/adam/constant/AdamRedisConst.java
+5
-1
SmsMessage.java
.../src/main/java/com/liquidnet/service/base/SmsMessage.java
+1
-1
AdamLoginController.java
...iquidnet/service/adam/controller/AdamLoginController.java
+122
-117
AdamUserController.java
...liquidnet/service/adam/controller/AdamUserController.java
+24
-22
AdamRdmService.java
...va/com/liquidnet/service/adam/service/AdamRdmService.java
+10
-0
errors.properties
...et-service-adam-impl/src/main/resources/errors.properties
+2
-2
No files found.
liquidnet-bus-api/liquidnet-service-adam-api/src/main/java/com/liquidnet/service/adam/constant/AdamRedisConst.java
View file @
30a9c638
...
@@ -3,6 +3,10 @@ package com.liquidnet.service.adam.constant;
...
@@ -3,6 +3,10 @@ package com.liquidnet.service.adam.constant;
public
class
AdamRedisConst
{
public
class
AdamRedisConst
{
public
static
final
String
ADAM
=
"adam:"
;
public
static
final
String
ADAM
=
"adam:"
;
public
static
final
String
VALID
=
ADAM
.
concat
(
"valid:"
);
public
static
final
String
VALID_SMS_CODE_MOBILE
=
VALID
.
concat
(
"sms:code:mobile"
);
public
static
final
String
IDENTITY
=
ADAM
.
concat
(
"identity:"
);
public
static
final
String
IDENTITY
=
ADAM
.
concat
(
"identity:"
);
public
static
final
String
IDENTITY_MOBILE
=
IDENTITY
.
concat
(
"mobile:"
);
public
static
final
String
IDENTITY_MOBILE
=
IDENTITY
.
concat
(
"mobile:"
);
...
@@ -44,7 +48,7 @@ public class AdamRedisConst {
...
@@ -44,7 +48,7 @@ public class AdamRedisConst {
public
static
final
String
LOCK_KEY_UMEMBER_NO
=
"adam:lk:member:no"
;
public
static
final
String
LOCK_KEY_UMEMBER_NO
=
"adam:lk:member:no"
;
// // // // // // // // // //
// // // // // // // // // //
public
static
final
String
LOCK_KEY_
USMS_MOBILE
=
"adam:lk:sms
:mobile:"
;
public
static
final
String
LOCK_KEY_
SMS_CODE_MOBILE
=
"adam:lk:sms:code
:mobile:"
;
public
static
final
String
LOCK_KEY_UREGISTER
=
"adam:lk:register:"
;
public
static
final
String
LOCK_KEY_UREGISTER
=
"adam:lk:register:"
;
public
static
final
String
LOCK_KEY_UIDENTITY
=
"adam:lk:identity:"
;
public
static
final
String
LOCK_KEY_UIDENTITY
=
"adam:lk:identity:"
;
public
static
final
String
LOCK_KEY_UMEMBER_CODE
=
"adam:lk:member:code:"
;
public
static
final
String
LOCK_KEY_UMEMBER_CODE
=
"adam:lk:member:code:"
;
...
...
liquidnet-bus-common/liquidnet-common-service-base/src/main/java/com/liquidnet/service/base/SmsMessage.java
View file @
30a9c638
...
@@ -30,7 +30,7 @@ public class SmsMessage implements Serializable, Cloneable {
...
@@ -30,7 +30,7 @@ public class SmsMessage implements Serializable, Cloneable {
private
final
static
SmsMessage
instance
=
new
SmsMessage
();
private
final
static
SmsMessage
instance
=
new
SmsMessage
();
public
static
SmsMessage
getNew
()
{
public
static
SmsMessage
builder
()
{
try
{
try
{
return
(
SmsMessage
)
instance
.
clone
();
return
(
SmsMessage
)
instance
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
}
catch
(
CloneNotSupportedException
e
)
{
...
...
liquidnet-bus-service/liquidnet-service-adam/liquidnet-service-adam-impl/src/main/java/com/liquidnet/service/adam/controller/AdamLoginController.java
View file @
30a9c638
...
@@ -11,6 +11,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
...
@@ -11,6 +11,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import
com.github.xiaoymin.knife4j.annotations.ApiSupport
;
import
com.github.xiaoymin.knife4j.annotations.ApiSupport
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.common.cache.redis.util.RedisUtil
;
import
com.liquidnet.common.cache.redisson.util.RedisLockUtil
;
import
com.liquidnet.common.cache.redisson.util.RedisLockUtil
;
import
com.liquidnet.common.mq.constant.MQConst
;
import
com.liquidnet.common.sms.constant.SmsEnum
;
import
com.liquidnet.common.sms.constant.SmsEnum
;
import
com.liquidnet.common.sms.processor.SmsProcessor
;
import
com.liquidnet.common.sms.processor.SmsProcessor
;
import
com.liquidnet.commons.lang.constant.LnsEnum
;
import
com.liquidnet.commons.lang.constant.LnsEnum
;
...
@@ -24,22 +25,22 @@ import com.liquidnet.service.adam.service.AdamRdmService;
...
@@ -24,22 +25,22 @@ import com.liquidnet.service.adam.service.AdamRdmService;
import
com.liquidnet.service.adam.service.IAdamUserService
;
import
com.liquidnet.service.adam.service.IAdamUserService
;
import
com.liquidnet.service.base.ErrorMapping
;
import
com.liquidnet.service.base.ErrorMapping
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.SmsMessage
;
import
com.liquidnet.service.base.UserPathDto
;
import
com.liquidnet.service.base.UserPathDto
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.client.HttpClientErrorException
;
import
javax.validation.Valid
;
import
javax.validation.Valid
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotBlank
;
...
@@ -52,7 +53,7 @@ import java.util.HashMap;
...
@@ -52,7 +53,7 @@ import java.util.HashMap;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Objects
;
import
static
com
.
liquidnet
.
service
.
adam
.
constant
.
AdamRedisConst
.
LOCK_KEY_
USMS
_MOBILE
;
import
static
com
.
liquidnet
.
service
.
adam
.
constant
.
AdamRedisConst
.
LOCK_KEY_
SMS_CODE
_MOBILE
;
@ApiSupport
(
order
=
10010
)
@ApiSupport
(
order
=
10010
)
@Api
(
tags
=
"用户登录"
)
@Api
(
tags
=
"用户登录"
)
...
@@ -74,72 +75,60 @@ public class AdamLoginController {
...
@@ -74,72 +75,60 @@ public class AdamLoginController {
@Autowired
@Autowired
IAdamUserService
adamUserService
;
IAdamUserService
adamUserService
;
@Autowired
@Autowired
SmsProcessor
smsProcessor
;
RabbitTemplate
rabbitTemplate
;
// @Autowired
// SmsProcessor smsProcessor;
@Value
(
"${liquidnet.reviewer.app-login.mobile}"
)
@Value
(
"${liquidnet.reviewer.app-login.mobile}"
)
private
String
reviewMobile
;
private
String
reviewMobile
;
private
static
final
String
PHP_API_SMS_CODE_SEND
=
"/smsCode"
;
private
static
final
String
PHP_API_SMS_CODE_SEND
=
"/smsCode"
;
private
static
final
String
PHP_API_SMS_CODE_VALID
=
"/smsValidation"
;
private
static
final
String
PHP_API_SMS_CODE_VALID
=
"/smsValidation"
;
/*@ApiOperationSupport(order = 1)
@ApiOperation(value = "手机号密码登录")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", dataType = "String", name = "mobile", value = "手机号"),
@ApiImplicitParam(type = "form", dataType = "String", name = "password", value = "密码"),
})
@PostMapping(value = {""})
public ResponseDto<AdamLoginInfoVo> loginByPwd(@RequestParam String mobile, @RequestParam String password) {
log.info("mobile:{},pwd:{}", mobile, password);
DigestUtils.md5DigestAsHex((password + "salt_").getBytes(StandardCharsets.UTF_8));
return ResponseDto.success(AdamLoginInfoVo.getNew());
}*/
@GetMapping
(
value
=
{
"gen"
})
public
void
genID
()
{
log
.
debug
(
"-nextSnowId:{}"
,
IDGenerator
.
nextSnowId
());
log
.
debug
(
"nextMilliId:{}"
,
IDGenerator
.
nextMilliId
());
log
.
debug
(
"nextMilliId:{}"
,
IDGenerator
.
nextTimeId
());
log
.
debug
(
"nextMilliId:{}"
,
IDGenerator
.
get32UUID
());
ObjectNode
smsNode
=
JsonUtils
.
OM
().
createObjectNode
();
smsNode
.
put
(
"code"
,
"123456"
);
smsProcessor
.
aliyunDysmsSend
(
"13753596360"
,
SmsEnum
.
ADSignName
.
正在现场
.
name
(),
SmsEnum
.
ADTemplate
.
SMS_109535335
.
name
(),
smsNode
.
toString
());
ArrayNode
smsBatchPhones
=
JsonUtils
.
OM
().
createArrayNode
(),
smsBatchSignNames
=
JsonUtils
.
OM
().
createArrayNode
(),
smsBatchTemplateParams
=
JsonUtils
.
OM
().
createArrayNode
();
ObjectNode
smsBatchTemplateParam
=
JsonUtils
.
OM
().
createObjectNode
();
smsBatchPhones
.
add
(
"13753596360"
);
smsBatchPhones
.
add
(
"17701223310"
);
smsBatchSignNames
.
add
(
SmsEnum
.
ADSignName
.
正在现场
.
name
());
smsBatchSignNames
.
add
(
SmsEnum
.
ADSignName
.
正在现场
.
name
());
smsBatchTemplateParam
.
put
(
"userName"
,
"张某人"
);
// @GetMapping(value = {"gen"})
smsBatchTemplateParam
.
put
(
"aName"
,
"大美"
);
// public void genID() {
smsBatchTemplateParam
.
put
(
"time"
,
"2021-07-10"
);
// log.debug("-nextSnowId:{}", IDGenerator.nextSnowId());
smsBatchTemplateParam
.
put
(
"siteName"
,
"北京"
);
// log.debug("nextMilliId:{}", IDGenerator.nextMilliId());
smsBatchTemplateParam
.
put
(
"url"
,
"show"
);
// log.debug("nextMilliId:{}", IDGenerator.nextTimeId());
// log.debug("nextMilliId:{}", IDGenerator.get32UUID());
smsBatchTemplateParams
.
add
(
smsBatchTemplateParam
.
deepCopy
());
//
//
smsBatchTemplateParam
.
put
(
"userName"
,
"张某人"
);
// ObjectNode smsNode = JsonUtils.OM().createObjectNode();
smsBatchTemplateParam
.
put
(
"aName"
,
"大美2"
);
// smsNode.put("code", "123456");
smsBatchTemplateParam
.
put
(
"time"
,
"2021-07-11"
);
// smsProcessor.aliyunDysmsSend("13753596360",
smsBatchTemplateParam
.
put
(
"siteName"
,
"天津"
);
// SmsEnum.ADSignName.正在现场.name(), SmsEnum.ADTemplate.SMS_109535335.name(),
smsBatchTemplateParam
.
put
(
"url"
,
"show2"
);
// smsNode.toString());
smsBatchTemplateParams
.
add
(
smsBatchTemplateParam
);
//
//
smsProcessor
.
aliyunDysmsSendBatch
(
smsBatchPhones
.
toPrettyString
(),
smsBatchSignNames
.
toString
(),
SmsEnum
.
ADTemplate
.
SMS_109535335
.
name
(),
smsBatchTemplateParams
.
toString
());
//
}
// ArrayNode smsBatchPhones = JsonUtils.OM().createArrayNode(),
// smsBatchSignNames = JsonUtils.OM().createArrayNode(),
// smsBatchTemplateParams = JsonUtils.OM().createArrayNode();
// ObjectNode smsBatchTemplateParam = JsonUtils.OM().createObjectNode();
//
// smsBatchPhones.add("13753596360");
// smsBatchPhones.add("17701223310");
//
// smsBatchSignNames.add(SmsEnum.ADSignName.正在现场.name());
// smsBatchSignNames.add(SmsEnum.ADSignName.正在现场.name());
//
// smsBatchTemplateParam.put("userName", "张某人");
// smsBatchTemplateParam.put("aName", "大美");
// smsBatchTemplateParam.put("time", "2021-07-10");
// smsBatchTemplateParam.put("siteName", "北京");
// smsBatchTemplateParam.put("url", "show");
//
// smsBatchTemplateParams.add(smsBatchTemplateParam.deepCopy());
//
// smsBatchTemplateParam.put("userName", "张某人");
// smsBatchTemplateParam.put("aName", "大美2");
// smsBatchTemplateParam.put("time", "2021-07-11");
// smsBatchTemplateParam.put("siteName", "天津");
// smsBatchTemplateParam.put("url", "show2");
// smsBatchTemplateParams.add(smsBatchTemplateParam);
//
// smsProcessor.aliyunDysmsSendBatch(smsBatchPhones.toPrettyString(), smsBatchSignNames.toString(), SmsEnum.ADTemplate.SMS_109535335.name(), smsBatchTemplateParams.toString());
// }
@ApiOperationSupport
(
order
=
2
)
@ApiOperationSupport
(
order
=
2
)
@ApiOperation
(
value
=
"发送验证码"
)
@ApiOperation
(
value
=
"发送验证码"
)
...
@@ -149,36 +138,44 @@ public class AdamLoginController {
...
@@ -149,36 +138,44 @@ public class AdamLoginController {
@GetMapping
(
value
=
{
"send"
})
@GetMapping
(
value
=
{
"send"
})
public
ResponseDto
<
Object
>
sendSms
(
@Pattern
(
regexp
=
"\\d{11}"
,
message
=
"手机号格式有误"
)
@RequestParam
String
mobile
)
{
public
ResponseDto
<
Object
>
sendSms
(
@Pattern
(
regexp
=
"\\d{11}"
,
message
=
"手机号格式有误"
)
@RequestParam
String
mobile
)
{
log
.
debug
(
"send to mobile:{}"
,
mobile
);
log
.
debug
(
"send to mobile:{}"
,
mobile
);
if
(
RedisLockUtil
.
tryLock
(
LOCK_KEY_USMS_MOBILE
+
mobile
,
1
,
5
))
{
if
(
RedisLockUtil
.
tryLock
(
LOCK_KEY_SMS_CODE_MOBILE
+
mobile
,
1
,
5
))
{
Map
<
String
,
Object
>
respMap
=
null
;
// Map<String, Object> respMap = null;
String
respStr
=
null
;
// String respStr = null;
try
{
// try {
LinkedMultiValueMap
<
String
,
String
>
paramsMap
=
new
LinkedMultiValueMap
<>();
// LinkedMultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap
.
add
(
"mobile"
,
mobile
);
// paramsMap.add("mobile", mobile);
//
long
s
=
System
.
currentTimeMillis
();
// long s = System.currentTimeMillis();
respStr
=
HttpUtil
.
postToPhpApi
(
env
.
getProperty
(
"liquidnet.url-service.url"
)
+
PHP_API_SMS_CODE_SEND
,
paramsMap
);
// respStr = HttpUtil.postToPhpApi(env.getProperty("liquidnet.url-service.url") + PHP_API_SMS_CODE_SEND, paramsMap);
log
.
debug
(
"###PHP.API[{}].RESP[{}]"
,
PHP_API_SMS_CODE_SEND
,
respStr
);
// log.debug("###PHP.API[{}].RESP[{}]", PHP_API_SMS_CODE_SEND, respStr);
log
.
debug
(
"#PHP.API耗时:{}ms"
,
System
.
currentTimeMillis
()
-
s
);
// log.debug("#PHP.API耗时:{}ms", System.currentTimeMillis() - s);
respMap
=
JsonUtils
.
fromJson
(
respStr
,
Map
.
class
);
// respMap = JsonUtils.fromJson(respStr, Map.class);
}
catch
(
Exception
e
)
{
// } catch (Exception e) {
RedisLockUtil
.
unlock
(
LOCK_KEY_USMS_MOBILE
+
mobile
);
// RedisLockUtil.unlock(LOCK_KEY_USMS_MOBILE + mobile);
if
(
e
instanceof
HttpClientErrorException
)
{
// if (e instanceof HttpClientErrorException) {
log
.
error
(
"PHP.API验证码发送异常[mobile:{},respStr:{},ex:{}]"
,
mobile
,
respStr
,
e
.
getLocalizedMessage
());
// log.error("PHP.API验证码发送异常[mobile:{},respStr:{},ex:{}]", mobile, respStr, e.getLocalizedMessage());
HttpClientErrorException
ex
=
(
HttpClientErrorException
)
e
;
// HttpClientErrorException ex = (HttpClientErrorException) e;
JsonNode
exBody
=
JsonUtils
.
fromJson
(
ex
.
getResponseBodyAsString
(),
JsonNode
.
class
);
// JsonNode exBody = JsonUtils.fromJson(ex.getResponseBodyAsString(), JsonNode.class);
return
ResponseDto
.
failure
(
"10003"
,
exBody
.
get
(
"message"
).
asText
());
// return ResponseDto.failure("10003", exBody.get("message").asText());
}
// }
log
.
error
(
"PHP.API验证码发送异常[mobile:{},respStr:{}]"
,
mobile
,
respStr
,
e
);
// log.error("PHP.API验证码发送异常[mobile:{},respStr:{}]", mobile, respStr, e);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"10003"
));
// return ResponseDto.failure(ErrorMapping.get("10003"));
}
// }
if
(!
CollectionUtils
.
isEmpty
(
respMap
)
&&
StringUtils
.
equalsIgnoreCase
(
"OK"
,
(
String
)
respMap
.
get
(
"message"
)))
{
// if (!CollectionUtils.isEmpty(respMap) && StringUtils.equalsIgnoreCase("OK", (String) respMap.get("message"))) {
return
ResponseDto
.
success
();
// return ResponseDto.success();
}
else
{
// } else {
RedisLockUtil
.
unlock
(
LOCK_KEY_USMS_MOBILE
+
mobile
);
// RedisLockUtil.unlock(LOCK_KEY_USMS_MOBILE + mobile);
log
.
warn
(
"PHP.API验证码发送失败[mobile:{},respStr:{}]"
,
mobile
,
respStr
);
// log.warn("PHP.API验证码发送失败[mobile:{},respStr:{}]", mobile, respStr);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"10003"
));
// return ResponseDto.failure(ErrorMapping.get("10003"));
}
// }
String
smsCode
=
RandomStringUtils
.
randomNumeric
(
6
);
SmsMessage
smsMessage
=
SmsMessage
.
builder
().
setPhone
(
mobile
).
setSignName
(
SmsEnum
.
ADSignName
.
正在现场
.
name
())
.
setTemplateCode
(
SmsEnum
.
ADTemplate
.
SMS_109535335
.
name
())
.
setTemplateParam
(
"code"
,
smsCode
);
rabbitTemplate
.
convertAndSend
(
MQConst
.
EX_LNS_SMS_SENDER
,
MQConst
.
RK_SMS_CODE
,
smsMessage
);
adamRdmService
.
setSmsCodeByMobile
(
mobile
,
smsCode
);
return
ResponseDto
.
success
();
}
else
{
}
else
{
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"10000"
));
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"10000"
));
}
}
...
@@ -196,7 +193,8 @@ public class AdamLoginController {
...
@@ -196,7 +193,8 @@ public class AdamLoginController {
@Pattern
(
regexp
=
"\\d{6}"
,
message
=
"验证码格式有误"
)
@Pattern
(
regexp
=
"\\d{6}"
,
message
=
"验证码格式有误"
)
@RequestParam
String
code
)
{
@RequestParam
String
code
)
{
log
.
debug
(
"mobile:{},code:{}"
,
mobile
,
code
);
log
.
debug
(
"mobile:{},code:{}"
,
mobile
,
code
);
if
(!
this
.
checkSmsCode
(
mobile
,
code
))
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"10004"
));
ResponseDto
checkSmsCodeDto
=
this
.
checkSmsCode
(
mobile
,
code
);
if
(!
checkSmsCodeDto
.
isSuccess
())
return
checkSmsCodeDto
;
String
uid
=
adamRdmService
.
getUidByMobile
(
mobile
);
String
uid
=
adamRdmService
.
getUidByMobile
(
mobile
);
boolean
toRegister
=
StringUtils
.
isEmpty
(
uid
);
boolean
toRegister
=
StringUtils
.
isEmpty
(
uid
);
...
@@ -280,8 +278,9 @@ public class AdamLoginController {
...
@@ -280,8 +278,9 @@ public class AdamLoginController {
loginInfoVo
.
setUserMemberVo
(
adamRdmService
.
getUserMemberVoByUid
(
uid
));
loginInfoVo
.
setUserMemberVo
(
adamRdmService
.
getUserMemberVoByUid
(
uid
));
// loginInfoVo.setMemberVo(adamRdmService.getMemberSimpleVo());
// loginInfoVo.setMemberVo(adamRdmService.getMemberSimpleVo());
}
else
{
// 新账号注册
}
else
{
// 新账号注册
if
(!
this
.
checkSmsCode
(
parameter
.
getMobile
(),
parameter
.
getCode
()))
{
ResponseDto
checkSmsCodeDto
=
this
.
checkSmsCode
(
parameter
.
getMobile
(),
parameter
.
getCode
());
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"10004"
));
if
(!
checkSmsCodeDto
.
isSuccess
())
{
return
checkSmsCodeDto
;
}
}
AdamUserInfoVo
registerUserInfo
=
adamUserService
.
register
(
parameter
);
AdamUserInfoVo
registerUserInfo
=
adamUserService
.
register
(
parameter
);
if
(
null
==
registerUserInfo
)
{
if
(
null
==
registerUserInfo
)
{
...
@@ -369,12 +368,12 @@ public class AdamLoginController {
...
@@ -369,12 +368,12 @@ public class AdamLoginController {
/* ---------------------------- Internal Method ---------------------------- */
/* ---------------------------- Internal Method ---------------------------- */
private
boolean
checkSmsCode
(
String
mobile
,
String
code
)
{
private
ResponseDto
checkSmsCode
(
String
mobile
,
String
code
)
{
Integer
switchGrayLoginSms
=
(
Integer
)
redisUtil
.
get
(
AdamRedisConst
.
SWITCH_GRAY_LOGIN_SMS
);
Integer
switchGrayLoginSms
=
(
Integer
)
redisUtil
.
get
(
AdamRedisConst
.
SWITCH_GRAY_LOGIN_SMS
);
if
(
null
!=
switchGrayLoginSms
)
{
if
(
null
!=
switchGrayLoginSms
)
{
if
(
switchGrayLoginSms
==
615243
)
{
if
(
switchGrayLoginSms
==
615243
)
{
if
(
CurrentUtil
.
GRAY_LOGIN_SMS_CODE
.
equals
(
code
))
{
if
(
CurrentUtil
.
GRAY_LOGIN_SMS_CODE
.
equals
(
code
))
{
return
true
;
return
ResponseDto
.
success
()
;
}
}
}
}
if
(
switchGrayLoginSms
==
612543
)
{
if
(
switchGrayLoginSms
==
612543
)
{
...
@@ -382,31 +381,37 @@ public class AdamLoginController {
...
@@ -382,31 +381,37 @@ public class AdamLoginController {
Arrays
.
asList
(
LnsEnum
.
ENV
.
dev
.
name
(),
LnsEnum
.
ENV
.
test
.
name
()).
contains
(
env
.
getProperty
(
CurrentUtil
.
CK_ENV_ACTIVE
))
Arrays
.
asList
(
LnsEnum
.
ENV
.
dev
.
name
(),
LnsEnum
.
ENV
.
test
.
name
()).
contains
(
env
.
getProperty
(
CurrentUtil
.
CK_ENV_ACTIVE
))
)
{
)
{
if
(
CurrentUtil
.
GRAY_LOGIN_SMS_CODE
.
equals
(
code
))
{
if
(
CurrentUtil
.
GRAY_LOGIN_SMS_CODE
.
equals
(
code
))
{
return
true
;
return
ResponseDto
.
success
()
;
}
}
}
}
}
}
}
}
LinkedMultiValueMap
<
String
,
String
>
paramsMap
=
new
LinkedMultiValueMap
<>();
// LinkedMultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap
.
add
(
"mobile"
,
mobile
);
// paramsMap.add("mobile", mobile);
paramsMap
.
add
(
"code"
,
code
);
// paramsMap.add("code", code);
//
String
respStr
=
null
;
// String respStr = null;
try
{
// try {
respStr
=
HttpUtil
.
postToPhpApi
(
env
.
getProperty
(
"liquidnet.url-service.url"
)
+
PHP_API_SMS_CODE_VALID
,
paramsMap
);
// respStr = HttpUtil.postToPhpApi(env.getProperty("liquidnet.url-service.url") + PHP_API_SMS_CODE_VALID, paramsMap);
log
.
debug
(
"###PHP.API[{}].RESP:{}"
,
PHP_API_SMS_CODE_VALID
,
respStr
);
// log.debug("###PHP.API[{}].RESP:{}", PHP_API_SMS_CODE_VALID, respStr);
Map
respMap
=
JsonUtils
.
fromJson
(
respStr
,
Map
.
class
);
// Map respMap = JsonUtils.fromJson(respStr, Map.class);
if
(!
CollectionUtils
.
isEmpty
(
respMap
)
&&
StringUtils
.
equalsIgnoreCase
(
"OK"
,
(
String
)
respMap
.
get
(
"message"
)))
{
// if (!CollectionUtils.isEmpty(respMap) && StringUtils.equalsIgnoreCase("OK", (String) respMap.get("message"))) {
return
true
;
// return true;
}
else
{
// } else {
log
.
warn
(
"PHP.API验证码验证失败[mobile:{},code:{},respStr:{}]"
,
mobile
,
code
,
respStr
);
// log.warn("PHP.API验证码验证失败[mobile:{},code:{},respStr:{}]", mobile, code, respStr);
return
false
;
// return false;
}
// }
}
catch
(
Exception
e
)
{
// } catch (Exception e) {
log
.
error
(
"PHP.API验证码验证异常[mobile:{},code:{},respStr:{}]"
,
mobile
,
code
,
respStr
,
e
);
// log.error("PHP.API验证码验证异常[mobile:{},code:{},respStr:{}]", mobile, code, respStr, e);
return
false
;
// return false;
// }
String
smsCodeByMobile
=
adamRdmService
.
getSmsCodeByMobile
(
mobile
);
if
(
null
==
smsCodeByMobile
)
{
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"10003"
));
}
}
return
smsCodeByMobile
.
equals
(
code
)
?
ResponseDto
.
success
()
:
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"10004"
));
}
}
private
String
getMobile
(
String
accessToken
)
{
private
String
getMobile
(
String
accessToken
)
{
...
...
liquidnet-bus-service/liquidnet-service-adam/liquidnet-service-adam-impl/src/main/java/com/liquidnet/service/adam/controller/AdamUserController.java
View file @
30a9c638
...
@@ -190,7 +190,8 @@ public class AdamUserController {
...
@@ -190,7 +190,8 @@ public class AdamUserController {
@RequestParam
String
code
)
{
@RequestParam
String
code
)
{
log
.
debug
(
"mobile:{},code:{}"
,
mobile
,
code
);
log
.
debug
(
"mobile:{},code:{}"
,
mobile
,
code
);
if
(!
this
.
checkSmsCode
(
mobile
,
code
))
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"10004"
));
ResponseDto
checkSmsCodeDto
=
this
.
checkSmsCode
(
mobile
,
code
);
if
(!
checkSmsCodeDto
.
isSuccess
())
return
checkSmsCodeDto
;
return
ResponseDto
.
success
(
adamUserInfoService
.
editMobile
(
CurrentUtil
.
getCurrentUid
(),
mobile
));
return
ResponseDto
.
success
(
adamUserInfoService
.
editMobile
(
CurrentUtil
.
getCurrentUid
(),
mobile
));
}
}
...
@@ -241,10 +242,6 @@ public class AdamUserController {
...
@@ -241,10 +242,6 @@ public class AdamUserController {
public
ResponseDto
<
List
<
AdamThirdPartInfoVo
>>
bindTpa
(
@Valid
@RequestBody
AdamThirdPartParam
parameter
)
{
public
ResponseDto
<
List
<
AdamThirdPartInfoVo
>>
bindTpa
(
@Valid
@RequestBody
AdamThirdPartParam
parameter
)
{
log
.
debug
(
"login by tpa:{}"
,
JsonUtils
.
toJson
(
parameter
));
log
.
debug
(
"login by tpa:{}"
,
JsonUtils
.
toJson
(
parameter
));
if
(
StringUtils
.
isBlank
(
parameter
.
getOpenId
()))
{
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"10009"
));
}
String
currentUid
=
CurrentUtil
.
getCurrentUid
();
String
currentUid
=
CurrentUtil
.
getCurrentUid
();
String
existUid
=
adamRdmService
.
getUidByPlatformOpenId
(
parameter
.
getPlatform
(),
parameter
.
getOpenId
());
String
existUid
=
adamRdmService
.
getUidByPlatformOpenId
(
parameter
.
getPlatform
(),
parameter
.
getOpenId
());
...
@@ -307,27 +304,32 @@ public class AdamUserController {
...
@@ -307,27 +304,32 @@ public class AdamUserController {
private
static
final
String
PHP_API_SMS_CODE_VALID
=
"/smsValidation"
;
private
static
final
String
PHP_API_SMS_CODE_VALID
=
"/smsValidation"
;
private
boolean
checkSmsCode
(
String
mobile
,
String
code
)
{
private
ResponseDto
checkSmsCode
(
String
mobile
,
String
code
)
{
if
(
Arrays
.
asList
(
LnsEnum
.
ENV
.
dev
.
name
(),
LnsEnum
.
ENV
.
test
.
name
()).
contains
(
env
.
getProperty
(
CurrentUtil
.
CK_ENV_ACTIVE
))
if
(
Arrays
.
asList
(
LnsEnum
.
ENV
.
dev
.
name
(),
LnsEnum
.
ENV
.
test
.
name
()).
contains
(
env
.
getProperty
(
CurrentUtil
.
CK_ENV_ACTIVE
))
&&
CurrentUtil
.
GRAY_LOGIN_SMS_CODE
.
equals
(
code
))
{
&&
CurrentUtil
.
GRAY_LOGIN_SMS_CODE
.
equals
(
code
))
{
return
true
;
return
ResponseDto
.
success
()
;
}
}
LinkedMultiValueMap
<
String
,
String
>
paramsMap
=
new
LinkedMultiValueMap
<>();
// LinkedMultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap
.
add
(
"mobile"
,
mobile
);
// paramsMap.add("mobile", mobile);
paramsMap
.
add
(
"code"
,
code
);
// paramsMap.add("code", code);
LinkedMultiValueMap
<
String
,
String
>
headersMap
=
new
LinkedMultiValueMap
<>();
// LinkedMultiValueMap<String, String> headersMap = new LinkedMultiValueMap<>();
headersMap
.
add
(
"token"
,
null
);
// headersMap.add("token", null);
try
{
// try {
String
respStr
=
HttpUtil
.
get
(
env
.
getProperty
(
"liquidnet.url-service.url"
)
+
PHP_API_SMS_CODE_VALID
,
paramsMap
,
headersMap
);
// String respStr = HttpUtil.get(env.getProperty("liquidnet.url-service.url") + PHP_API_SMS_CODE_VALID, paramsMap, headersMap);
log
.
debug
(
"###PHP.API.RESP:{}"
,
respStr
);
// log.debug("###PHP.API.RESP:{}", respStr);
//
Map
respMap
=
JsonUtils
.
fromJson
(
respStr
,
Map
.
class
);
// Map respMap = JsonUtils.fromJson(respStr, Map.class);
//
return
StringUtils
.
equalsIgnoreCase
(
"OK"
,
(
String
)
respMap
.
get
(
"message"
));
// return StringUtils.equalsIgnoreCase("OK", (String) respMap.get("message"));
}
catch
(
Exception
e
)
{
// } catch (Exception e) {
log
.
error
(
"验证码验证异常[mobile:{},code:{}]"
,
mobile
,
code
,
e
);
// log.error("验证码验证异常[mobile:{},code:{}]", mobile, code, e);
return
false
;
// return false;
// }
String
smsCodeByMobile
=
adamRdmService
.
getSmsCodeByMobile
(
mobile
);
if
(
null
==
smsCodeByMobile
)
{
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"10003"
));
}
}
return
smsCodeByMobile
.
equals
(
code
)
?
ResponseDto
.
success
()
:
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"10004"
));
}
}
}
}
liquidnet-bus-service/liquidnet-service-adam/liquidnet-service-adam-impl/src/main/java/com/liquidnet/service/adam/service/AdamRdmService.java
View file @
30a9c638
...
@@ -35,6 +35,16 @@ public class AdamRdmService {
...
@@ -35,6 +35,16 @@ public class AdamRdmService {
return
null
==
i
?
1
:
i
;
return
null
==
i
?
1
:
i
;
}
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | <Mobile, SMS CODE> */
public
boolean
setSmsCodeByMobile
(
String
mobile
,
String
smsCode
)
{
return
redisUtil
.
set
(
AdamRedisConst
.
VALID_SMS_CODE_MOBILE
+
mobile
,
smsCode
,
15
*
60
);
}
public
String
getSmsCodeByMobile
(
String
mobile
)
{
return
(
String
)
redisUtil
.
get
(
AdamRedisConst
.
VALID_SMS_CODE_MOBILE
+
mobile
);
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | <Mobile|OPENID, UID> */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | <Mobile|OPENID, UID> */
public
boolean
setUidByMobile
(
String
mobile
,
String
uid
)
{
public
boolean
setUidByMobile
(
String
mobile
,
String
uid
)
{
...
...
liquidnet-bus-service/liquidnet-service-adam/liquidnet-service-adam-impl/src/main/resources/errors.properties
View file @
30a9c638
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
10000
=
请求频繁,稍后再试
10000
=
请求频繁,稍后再试
10001
=
10001
=
10002
=
10002
=
验证码发送失败
10003
=
验证码发送失败
10003
=
已超时,请重新获取验证码
10004
=
手机验证码错误
10004
=
手机验证码错误
10005
=
手机号获取失败,请更换登录方式
10005
=
手机号获取失败,请更换登录方式
10006
=
第三方账号未注册
10006
=
第三方账号未注册
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment