提交 4dbf8f79 编写于 作者: Chongwen.jiang's avatar Chongwen.jiang

1.协议名称获取

2.首次唤起app签订协议接口
3.统一校验接口
4.微信授权登录接口增加入参区分
上级 c5ee68c9
流水线 #21855 已失败 于阶段
in 1 second
......@@ -151,6 +151,12 @@
<artifactId>xxl-job-core</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.pica.cloud.patient</groupId>
<artifactId>pica-cloud-smartcontract-client</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
<dependencyManagement>
......
......@@ -45,4 +45,9 @@ public class Constants {
*/
public static final String TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
/** 密码登录错误次数缓存key */
public static final String PWD_ERROR_NUM_KEY = "pwd-error-{mobile}";
/** 密码登录错误次数缓存时长*/
public static final int PWD_ERROR_NUM_SECONDS = 24 * 60 * 60;
}
......@@ -15,6 +15,7 @@ import com.pica.cloud.account.account.server.util.CryptoUtil;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.redis.CacheClient;
import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.entity.DeviceInfo;
import com.pica.cloud.foundation.utils.utils.CommonUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -206,4 +207,15 @@ public class LoginController extends AccountBaseController {
}
return PicaResponse.toResponse(resultWeb);
}
@ApiOperation(value = "统一校验(传空则不会校验)")
@PostMapping("/unifiedVerification")
public PicaResponse unifiedVerification(@RequestBody EncryptEntity entity) throws Exception{
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
return PicaResponse.toResponse(loginService.preLoginValidate(
request,
super.getDeviceInfo("deviceId"),
super.getIpAddr()));
}
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.service.ProtocolService;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.patient.smartcontract.common.req.BatchSignReq;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @ClassName ProtocolController
* @Description 协议相关
* @Author Chongwen.jiang
* @Date 2020/2/20 10:48
* @ModifyDate 2020/2/20 10:48
* @Version 1.0
*/
@Api(description = "协议相关")
@RequestMapping("/protocol")
@RestController
public class ProtocolController extends AccountBaseController {
@Autowired
private ProtocolService protocolService;
@ApiOperation(value = "批量查询指定类型协议")
@GetMapping("/names")
public PicaResponse get(){
return PicaResponse.toResponse(
protocolService.getProtocolNames());
}
@ApiOperation(value = "首次唤起App签订协议")
@PostMapping("/firstCallApp")
public PicaResponse firstCallApp(@RequestBody BatchSignReq req){
String appVersion = super.getDeviceInfo("appVersion");
protocolService.firstCallAppSignProtocol(req, appVersion);
return PicaResponse.toResponse();
}
}
......@@ -29,7 +29,13 @@ public enum AccountExceptionEnum {
PICA_WECHAT_CODE_ERROR("216521", "微信登录授权code不正确"),
PICA_WECHAT_UNBIND("216522", "该微信号已绑定其他云鹊医账户,你可以使用微信登录云鹊医,在「设置」页解除绑定"),
PICA_WECHAT_BIND_OTHER("216524", "该手机号已绑定其他微信号,你可以在「设置」页解除绑定"),
PICA_WECHAT_UNBIND_CURRENT("216523", "正在绑定中,请稍等");
PICA_WECHAT_UNBIND_CURRENT("216523", "正在绑定中,请稍等"),
PICA_PASSWORD_RULE_ERROR("216525","请设置正确的密码格式"),
PICA_PWD_ERROR("216526", "密码错误,请重试"),
PICA_PWD_ERROR_2("216527", "密码错误次数过多,请前往找回密码"),
PICA_APPLE_BIND_OTHER("216528", "该手机号已绑定其他苹果账号"),
xxx_xxx("","");
private String code;
......
package com.pica.cloud.account.account.server.enums;
/**
* @Description 统一校验业务类型枚举类
* @Author Chongwen.jiang
* @Date 2020/2/20 18:19
* @ModifyDate 2020/2/20 18:19
* @Params
* @Return
*/
public enum BizTypeEnum {
LOGIN_AUTH_CODE(1, "验证码登录"),
LOGIN_PWD(2, "密码登录"),
FIND_PASSWORD(3, "找回密码"),
LOGIN_WE_CHAT(4, "微信登录"),
LOGIN_APPLE(5, "苹果登录"),
XXX(10, "xxxxxx");
private Integer code;
private String type;
BizTypeEnum(Integer code, String type) {
this.code = code;
this.type = type;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
package com.pica.cloud.account.account.server.enums;
/**
* @Description 统一校验响应枚举类
* @Author Chongwen.jiang
* @Date 2020/2/20 18:19
* @ModifyDate 2020/2/20 18:19
* @Params
* @Return
*/
public enum BizTypeRespEnum {
MOBILE_REG_FALSE(1, "请输入正确的手机号"),
MOBILE_REG_TRUE(2, "手机号符合规则"),
RC_TRIGGER(3, "需要触发风控滑动验证"),
RC_NOT_TRIGGER(4, "不需要触发风控滑动验证"),
MOBILE_NOT_REGIST(5, "该手机号{mobile}尚未设置密码,请先设置密码。"),
MOBILE_REGISTED(6, "手机号已注册"),
MOBILE_NOT_SETED_PASSWORD(7, "该手机号{mobile}尚未设置密码,请先设置密码。"),
MOBILE_SETED_PASSWORD(8, "手机号未设置密码"),
PWD_REG_FALSE(9, "请设置正确的密码格式"),
PWD_REG_TRUE(10, "密码格式正确"),
PWD_MATCH_DB(11, "密码正确"),
PWD_MISMATCH_4(12, "密码错误,请重试"),
PWD_MISMATCH_5(13, "密码错误次数过多,请前往找回密码"),
MOBILE_BINDED_WECHAT(14, "该手机号已绑定其他微信号,你可以在「设置」页解除绑定"),
MOBILE_NOT_BINDED_WECHAT(15, "该手机号未绑定微信"),
MOBILE_BINDED_APPLE(16, "该手机号已绑定其他苹果账号"),
MOBILE_NOT_BINDED_APPLE(17, "该手机号未绑定苹果账号"),
LOGIN_PWD(2, "密码登录"),
FIND_PASSWORD(3, "找回密码"),
LOGIN_WE_CHAT(4, "微信登录"),
LOGIN_APPLE(5, "苹果登录"),
XXX(10, "xxxxxx");
private Integer code;
private String msg;
BizTypeRespEnum(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setType(String msg) {
this.msg = msg;
}
}
......@@ -34,6 +34,10 @@ public class BaseRequest {
private String captchaToken;
@ApiModelProperty("图片验证码答案")
private String captchaAnswer;
@ApiModelProperty("苹果用户id")
private String appleUserId;
@ApiModelProperty("业务类型,1-验证码登录,2-密码登录,3-找回密码,4-微信登录,5-Apple登录")
private Integer bizType;
public String getCaptchaToken() {
return captchaToken;
......@@ -146,4 +150,20 @@ public class BaseRequest {
public void setWeChatLoginType(Integer weChatLoginType) {
this.weChatLoginType = weChatLoginType;
}
public String getAppleUserId() {
return appleUserId;
}
public void setAppleUserId(String appleUserId) {
this.appleUserId = appleUserId;
}
public Integer getBizType() {
return bizType;
}
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.resp;
import io.swagger.annotations.ApiModel;
/**
* @ClassName UnifiedVerificationResp
* @Description 统一验证响应类
* @Author Chongwen.jiang
* @Date 2020/2/20 20:48
* @ModifyDate 2020/2/20 20:48
* @Version 1.0
*/
@ApiModel(value = "UnifiedVerificationResp", description = "统一验证响应类")
public class UnifiedVerificationResp {
private Integer bizCode;
private String bizMsg;
public Integer getBizCode() {
return bizCode;
}
public void setBizCode(Integer bizCode) {
this.bizCode = bizCode;
}
public String getBizMsg() {
return bizMsg;
}
public void setBizMsg(String bizMsg) {
this.bizMsg = bizMsg;
}
}
......@@ -3,6 +3,10 @@ package com.pica.cloud.account.account.server.service;
import com.pica.cloud.account.account.server.entity.LoginResult;
import com.pica.cloud.account.account.server.entity.PICAPDoctor;
import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.resp.UnifiedVerificationResp;
import com.pica.cloud.foundation.entity.PicaResponse;
import java.util.Map;
public interface LoginService {
/**
......@@ -52,4 +56,14 @@ public interface LoginService {
String bindWeChat(long doctorId, BaseRequest request);
PICAPDoctor queryDoctor(long doctorId);
/**
* @Description 统一校验(传空则不会校验)
* @Author Chongwen.jiang
* @Date 2020/2/20 16:55
* @ModifyDate 2020/2/20 16:55
* @Params [request]
* @Return com.pica.cloud.foundation.entity.PicaResponse
*/
UnifiedVerificationResp preLoginValidate(BaseRequest request,String deviceId, String ip);
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.service;
import com.pica.cloud.patient.smartcontract.common.req.BatchSignReq;
import com.pica.cloud.patient.smartcontract.common.resp.ProtocolResp;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* @ClassName ProtocolService
* @Description 协议相关接口
* @Author Chongwen.jiang
* @Date 2020/2/20 11:00
* @ModifyDate 2020/2/20 11:00
* @Version 1.0
*/
public interface ProtocolService {
/**
* @Description 批量查询指定类型协议
* @Author Chongwen.jiang
* @Date 2020/2/20 11:27
* @ModifyDate 2020/2/20 11:27
* @Params [protocolTypes, appVersion]
* @Return java.util.List<com.pica.cloud.patient.smartcontract.common.resp.ProtocolResp>
*/
List<ProtocolResp> getProtocolNames();
/**
* @Description 首次唤起app签订协议
* @Author Chongwen.jiang
* @Date 2020/2/20 11:31
* @ModifyDate 2020/2/20 11:31
* @Params [req]
* @Return void
*/
void firstCallAppSignProtocol(@RequestBody BatchSignReq req, String appVersion);
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.service.impl;
import com.alibaba.fastjson.JSON;
import com.pica.cloud.account.account.server.service.ProtocolService;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.entity.PicaResultCode;
import com.pica.cloud.foundation.entity.PicaWarnException;
import com.pica.cloud.patient.smartcontract.client.SmartContractClient;
import com.pica.cloud.patient.smartcontract.common.req.BatchSignReq;
import com.pica.cloud.patient.smartcontract.common.resp.ProtocolResp;
import com.pica.cloud.patient.smartcontract.common.utils.ReturnUtil;
import groovy.util.logging.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/**
* @ClassName ProtocolServiceImpl
* @Description 协议相关业务层
* @Author Chongwen.jiang
* @Date 2020/2/20 11:01
* @ModifyDate 2020/2/20 11:01
* @Version 1.0
*/
@Service
public class ProtocolServiceImpl implements ProtocolService {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private SmartContractClient smartContractClient;
/**
* @Description 批量查询指定类型协议
* @Author Chongwen.jiang
* @Date 2020/2/20 11:26
* @ModifyDate 2020/2/20 11:26
* @Params [protocolTypes, appVersion]
* @Return java.util.List<com.pica.cloud.patient.smartcontract.common.resp.ProtocolResp>
*/
@Override
public List<ProtocolResp> getProtocolNames() {
List<Integer> protocolTypes = new ArrayList<>();
// 用户协议
protocolTypes.add(2);
// 隐私协议
protocolTypes.add(3);
// 运营商认证协议
protocolTypes.add(12);
BatchSignReq req = new BatchSignReq();
req.setTypes(protocolTypes);
PicaResponse picaResponse = smartContractClient.queryProtocol(req);
if(Objects.isNull(picaResponse)){
throw new PicaWarnException(
PicaResultCode.INTERFACE_INVOKE_EXCEPTION.code(),
PicaResultCode.INTERFACE_INVOKE_EXCEPTION.message());
}
if(!PicaResultCode.SUCCESS.code().equals(picaResponse.getCode())){
throw new PicaWarnException(
picaResponse.getCode(),
picaResponse.getMessage());
}
List<ProtocolResp> resp = JSON.parseArray(
JSON.toJSONString(picaResponse.getData()),
ProtocolResp.class);
return resp;
}
/**
* @Description 首次唤起app签订协议
* @Author Chongwen.jiang
* @Date 2020/2/20 11:31
* @ModifyDate 2020/2/20 11:31
* @Params [req]
* @Return void
*/
@Override
public void firstCallAppSignProtocol(BatchSignReq req, String appVersion) {
if(StringUtils.isEmpty(appVersion)) {
logger.info("firstCallAppSignProtocol-appVersion is null ");
return;
}
PicaResponse resp = smartContractClient.firstCallAppSignProtocol(req);
logger.info("firstCallAppSignProtocol-resp:{}", JSON.toJSONString(resp));
if(Objects.isNull(resp)){
throw new PicaWarnException(
PicaResultCode.INTERFACE_INVOKE_EXCEPTION.code(),
PicaResultCode.INTERFACE_INVOKE_EXCEPTION.message());
}
if(!PicaResultCode.SUCCESS.code().equals(resp.getCode())){
throw new PicaWarnException(
resp.getCode(),
resp.getMessage());
}
}
}
......@@ -15,6 +15,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.regex.Pattern;
/**
* 账户工具类
*/
......@@ -36,20 +38,29 @@ public class AccountUtils {
private static final String AUTH_CODE_PREFIX = "authCode-";
private static final String AUTH_CODE_COUNT_PREFIX = "authCode-count-";
//手机格式校验
//手机非空和格式校验
public static void checkMobilePhone(String mobilePhone) {
if (StringUtils.isBlank(mobilePhone) || !ValidateUtils.isMobile(mobilePhone)) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "请输入正确的手机号");
}
}
//手机格式校验
//密码非空判断
public static void checkPassword(String password) {
if (StringUtils.isBlank(password)) {
throw new PicaException(AccountExceptionEnum.PICA_NOT_EMPTY.getCode(), AccountExceptionEnum.PICA_NOT_EMPTY.getMessage());
}
}
public static boolean checkPasswordRule(String password){
String regex = "^(?=.*[0-9])(?=.*[a-zA-Z])(.{6,16})$";
boolean pass = password.matches(regex);
if(password.length() < 6 || password.length() > 16 || !pass){
return false;
}
return true;
}
//获取验证码redis key
public static String getAuthCodeKey(String mobilePhone, String flag) {
return AUTH_CODE_PREFIX + flag + "-" + AESUtil.encryptV0(mobilePhone);
......
......@@ -26,7 +26,6 @@ public class TokenUtils {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private ICacheClient cacheClient;
@Autowired
......
......@@ -36,6 +36,9 @@ memcached.url=192.168.130.230:11211
#微信登陆
weChatAppID=wx5103ed453ef2dbe8
weChatAppSecret=6faa9bef3302786c08b2baf278613f38
#h5使用的云鹊医公众号
weChatAppIDH5=wx08b383d002c73f26
weChatAppSecretH5=b3a6be25c9f62423b88a3d0611f060d1
weChatURL=https://api.weixin.qq.com/sns/userinfo?
#是否开启双写模式,是否需要向p_doctor表写数据
......
......@@ -40,6 +40,8 @@ memcached.url=172.19.121.31:11211
#微信登陆
weChatAppID=wx5103ed453ef2dbe8
weChatAppSecret=6faa9bef3302786c08b2baf278613f38
weChatAppIDH5=wx2c577552a2d28550
weChatAppSecretH5=397a92bda46180efa2c2a235b74a409a
weChatURL=https://api.weixin.qq.com/sns/userinfo?
#是否开启双写模式,是否需要向p_doctor表写数据
......
......@@ -39,6 +39,8 @@ memcached.url=192.168.130.230:11211
#微信登陆
weChatAppID=wx5103ed453ef2dbe8
weChatAppSecret=6faa9bef3302786c08b2baf278613f38
weChatAppIDH5=wxcaad75b7fff5659c
weChatAppSecretH5=3d6eea715bc34489b49925b3dbde9c8b
weChatURL=https://api.weixin.qq.com/sns/userinfo?
#是否开启双写模式,是否需要向p_doctor表写数据
......
......@@ -39,6 +39,8 @@ memcached.url=192.168.130.230:11211
#微信登陆
weChatAppID=wx5103ed453ef2dbe8
weChatAppSecret=6faa9bef3302786c08b2baf278613f38
weChatAppIDH5=wx342ef0e5afee54a7
weChatAppSecretH5=3859052f07d3f87cda644bf073927ef1
weChatURL=https://api.weixin.qq.com/sns/userinfo?
#是否开启双写模式,是否需要向p_doctor表写数据
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册