提交 2145069d 编写于 作者: fengyuan.wan's avatar fengyuan.wan

Merge remote-tracking branch 'origin/dev-login0218' into dev-login0218

流水线 #22063 已失败 于阶段
in 0 second
......@@ -45,9 +45,6 @@ public class AutoCodeController extends AccountBaseController {
private final String AUTH_CODE_PREFIX = "authCode-";
private Logger logger = LoggerFactory.getLogger(AccountController.class);
@Autowired
private AccountInfoDetailMapper accountInfoDetailMapper;
@Autowired
private AccountUnionService accountUnionService;
......
......@@ -6,6 +6,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
......@@ -30,6 +31,12 @@ public class TokenController extends AccountBaseController {
return PicaResponse.toResponse(token);
}
@ApiOperation(value = "token续时")
@GetMapping(value = "/token/continue")
public PicaResponse<String> tokenContinueTime(@RequestParam(value = "seconds", required = false) Integer seconds) throws Exception {
return PicaResponse.toResponse(tokenService.tokenContinueTime(super.getToken(), super.getSourceType(), seconds));
}
}
......@@ -32,7 +32,7 @@ public enum AccountExceptionEnum {
PICA_WECHAT_UNBIND_CURRENT("216523", "正在绑定中,请稍等"),
PICA_PASSWORD_RULE_ERROR("216525","该手机号{mobile}尚未设置密码,请先设置密码。"),
PICA_PWD_MISMATCH_4("216526", "密码错误,请重试"),
PICA_PWD_MISMATCH_5("216527", "密码错误次数过多,请前往找回密码"),
PICA_PWD_MISMATCH_5("216527", "该账号{mobile}的密码错误次数已达上限请24小时后再试,或请使用其他登录方式或找回密码"),
PICA_APPLE_TOKEN_ERROR("216528", "微信登录授权identifyToken不正确"),
PICA_APPLE_BIND_OTHER("216529", "该Apple账号已绑定其他账户"),
PICA_MOBILE_BIND_OTHER("216530", "该手机号已绑定其他Apple账号"),
......
......@@ -10,4 +10,7 @@ import java.util.Map;
public interface TokenService {
String getToken(Map<String, Object> map);
String tokenContinueTime(String token, Integer sourceType, Integer seconds);
}
......@@ -159,7 +159,7 @@ public class LoginServiceImpl implements LoginService {
AccountExceptionEnum.PICA_PWD_MISMATCH_4.getMessage());
} else {
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_5.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_5.getMessage());
AccountExceptionEnum.PICA_PWD_MISMATCH_5.getMessage().replace("{mobile}", mobile));
}
} else {
redisClient.set(key, 1, Constants.PWD_ERROR_NUM_SECONDS);
......@@ -564,6 +564,7 @@ public class LoginServiceImpl implements LoginService {
resp.setBizMsg(BizTypeRespEnum.MOBILE_REG_TRUE.getMsg());
}
}else if(bizType.equals(3)){
// 手机号规则校验
if (StringUtils.isNotEmpty(mobile) &&
!ValidateUtils.isMobile(mobile)) {
......
......@@ -2,14 +2,14 @@ package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.service.TokenService;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.account.account.server.util.TokenUtils;
import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.entity.PicaUser;
import com.pica.cloud.foundation.utils.utils.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.Map;
......@@ -56,4 +56,25 @@ public class TokenServiceImpl implements TokenService {
}
return null;
}
@Autowired
private TokenUtils tokenUtils;
/**
* @Description token续时
* @Author Chongwen.jiang
* @Date 2020/2/26 14:06
* @ModifyDate 2020/2/26 14:06
* @Params [token, sourceType] sourceType: 1.android 2.ios 3.web 4.h5 5.admin
* @Return java.lang.String
*/
@Override
public String tokenContinueTime(String token, Integer sourceType, Integer seconds) {
if(StringUtils.isEmpty(token)){
return null;
}
if(tokenUtils.tokenContinueTime(token, sourceType, seconds)){
return token;
}
return null;
}
}
......@@ -42,6 +42,33 @@ public class TokenUtils {
return StringUtils.isBlank(str);
}
/**
* @Description token续时
* @Author Chongwen.jiang
* @Date 2020/2/26 13:07
* @ModifyDate 2020/2/26 13:07
* @Params [token, sourceType]
* @Return boolean
*/
public boolean tokenContinueTime(String token, Integer sourceType, Integer seconds) {
logger.info("tokenContinueTime-token-{}, sourceType-{}, seconds-{}", token, sourceType, seconds);
// 根据不同的产品线设置token有效期(web/admin token有效期30天,ios/android/h5 token有效期24小时)
int expiredSeconds = 24 * 60 * 60;
if (sourceType != 3 && sourceType != 5) {
expiredSeconds = expiredSeconds * 30;
}
String sourceTypeRedis = AccountUtils.getSourceType(sourceType);
String key = "token-" + token;
// value = "token-doctor-{doctorId}";
String value = cacheClient.get(key);
cacheClient.set(key, value, expiredSeconds);
cacheClient.set(value + "-" + sourceTypeRedis, key, expiredSeconds);
return true;
}
/**
* 获取新的token
*
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册