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

风控接口接入

mybatis-generator
上级 e7386bc4
流水线 #21951 已失败 于阶段
in 0 second
......@@ -157,6 +157,14 @@
<artifactId>pica-cloud-smartcontract-client</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>com.pica.cloud.riskcontrol</groupId>
<artifactId>pica-cloud-riskcontrol-client</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
<dependencyManagement>
......@@ -227,6 +235,23 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
<dependencies>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
<configurationFile>src/main/resources/mybatis-generator.xml</configurationFile>
</configuration>
</plugin>
</plugins>
</build>
</project>
......@@ -24,6 +24,9 @@ import com.pica.cloud.foundation.entity.PicaResultCode;
import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.utils.CommonUtil;
import com.pica.cloud.foundation.utils.utils.ValidateUtils;
import com.pica.cloud.riskcontrol.riskcontrol.client.CheckCodeClient;
import com.pica.cloud.riskcontrol.riskcontrol.common.req.CheckcodeRiskReq;
import com.pica.cloud.riskcontrol.riskcontrol.common.resp.CheckcodeRiskResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
......@@ -58,6 +61,9 @@ public class AutoCodeController extends AccountBaseController {
@Autowired
private ICacheClient cacheClient;
@Autowired
private CheckCodeClient rcClient;
@ApiOperation("获取短信验证码,无需图形验证码,如app端")
@PostMapping(value = "/authCode")
......@@ -216,54 +222,67 @@ public class AutoCodeController extends AccountBaseController {
*/
private UnifiedVerificationResp rcValidate(String mobile, Integer flag) {
// 调用风控接口
PicaResponse picaResponse = null;
if (picaResponse != null &&
PicaResultCode.SUCCESS.code().equals(picaResponse.getCode())) {
Object data = picaResponse.getData();
if (Objects.nonNull(data)) {
JSONObject respData = JSON.parseObject(
JSON.toJSONString(data), JSONObject.class);
if (StringUtils.isNotEmpty(respData.getString("processCode"))) {
Integer processCode = Integer.valueOf(respData.getString("processCode"));
if (null != processCode) {
if (processCode.equals(BizTypeRespEnum.RC_SEND_FAIL.getCode())) {
UnifiedVerificationResp resp = new UnifiedVerificationResp();
resp.setBizCode(BizTypeRespEnum.RC_SEND_FAIL.getCode());
resp.setBizMsg(BizTypeRespEnum.RC_SEND_FAIL.getMsg());
return resp;
} else if (processCode.equals(BizTypeRespEnum.RC_TRIGGER.getCode())) {
UnifiedVerificationResp resp = new UnifiedVerificationResp();
resp.setBizCode(BizTypeRespEnum.RC_TRIGGER.getCode());
resp.setBizMsg(BizTypeRespEnum.RC_TRIGGER.getMsg());
return resp;
} else if (processCode.equals(BizTypeRespEnum.RC_BLACKLIST.getCode())) {
UnifiedVerificationResp resp = new UnifiedVerificationResp();
resp.setBizCode(BizTypeRespEnum.RC_BLACKLIST.getCode());
resp.setBizMsg(BizTypeRespEnum.RC_BLACKLIST.getMsg());
return resp;
} else if (processCode.equals(BizTypeRespEnum.RC_DAY_LIMIT.getCode())) {
UnifiedVerificationResp resp = new UnifiedVerificationResp();
resp.setBizCode(BizTypeRespEnum.RC_DAY_LIMIT.getCode());
resp.setBizMsg(BizTypeRespEnum.RC_DAY_LIMIT.getMsg());
return resp;
} else if (processCode.equals(BizTypeRespEnum.RC_60_SECOND_LIMIT.getCode())) {
UnifiedVerificationResp resp = new UnifiedVerificationResp();
resp.setBizCode(BizTypeRespEnum.RC_60_SECOND_LIMIT.getCode());
// 获取剩余秒数
Long time = cacheClient.get(this.getAuthCodeKey(mobile, flag.toString()) + "-secure", Long.class);
int remainTime = 59 - (int) (System.currentTimeMillis() - time) / 1000;
if (remainTime > 0) {
resp.setBizMsg(BizTypeRespEnum.RC_60_SECOND_LIMIT.getMsg()
.replace("{remainTime}", String.valueOf(remainTime)));
try {
CheckcodeRiskReq rcReq = new CheckcodeRiskReq();
rcReq.setMobile(mobile);
/*rcReq.setDeviceId();
rcReq.setIp();
rcReq.setDeviceIp();*/
logger.info("rc-req:{}", JSON.toJSONString(rcReq));
PicaResponse picaResponse = rcClient.checkcodeRisk(rcReq);
logger.info("rc-resp:{}", JSON.toJSONString(picaResponse));
if (picaResponse != null &&
PicaResultCode.SUCCESS.code().equals(picaResponse.getCode())) {
Object data = picaResponse.getData();
if (Objects.nonNull(data)) {
JSONObject respData = JSON.parseObject(
JSON.toJSONString(data), JSONObject.class);
if (StringUtils.isNotEmpty(respData.getString("processCode"))) {
Integer processCode = Integer.valueOf(respData.getString("processCode"));
if (null != processCode) {
if (processCode.equals(BizTypeRespEnum.RC_SEND_FAIL.getCode())) {
UnifiedVerificationResp resp = new UnifiedVerificationResp();
resp.setBizCode(BizTypeRespEnum.RC_SEND_FAIL.getCode());
resp.setBizMsg(BizTypeRespEnum.RC_SEND_FAIL.getMsg());
return resp;
} else if (processCode.equals(BizTypeRespEnum.RC_TRIGGER.getCode())) {
UnifiedVerificationResp resp = new UnifiedVerificationResp();
resp.setBizCode(BizTypeRespEnum.RC_TRIGGER.getCode());
resp.setBizMsg(BizTypeRespEnum.RC_TRIGGER.getMsg());
return resp;
} else if (processCode.equals(BizTypeRespEnum.RC_BLACKLIST.getCode())) {
UnifiedVerificationResp resp = new UnifiedVerificationResp();
resp.setBizCode(BizTypeRespEnum.RC_BLACKLIST.getCode());
resp.setBizMsg(BizTypeRespEnum.RC_BLACKLIST.getMsg());
return resp;
} else if (processCode.equals(BizTypeRespEnum.RC_DAY_LIMIT.getCode())) {
UnifiedVerificationResp resp = new UnifiedVerificationResp();
resp.setBizCode(BizTypeRespEnum.RC_DAY_LIMIT.getCode());
resp.setBizMsg(BizTypeRespEnum.RC_DAY_LIMIT.getMsg());
return resp;
} else if (processCode.equals(BizTypeRespEnum.RC_60_SECOND_LIMIT.getCode())) {
UnifiedVerificationResp resp = new UnifiedVerificationResp();
resp.setBizCode(BizTypeRespEnum.RC_60_SECOND_LIMIT.getCode());
// 获取剩余秒数
Long time = cacheClient.get(this.getAuthCodeKey(mobile, flag.toString()) + "-secure", Long.class);
int remainTime = 59 - (int) (System.currentTimeMillis() - time) / 1000;
if (remainTime > 0) {
resp.setBizMsg(BizTypeRespEnum.RC_60_SECOND_LIMIT.getMsg()
.replace("{remainTime}", String.valueOf(remainTime)));
}
return resp;
}
return resp;
}
}
}
// processCode=1(允许发送短信验证码)
return new UnifiedVerificationResp();
} else {
return null;
}
// processCode=1(允许发送短信验证码)
return new UnifiedVerificationResp();
} else {
} catch (Exception e) {
logger.error("风控接口调用异常", e);
return null;
}
}
......
......@@ -18,6 +18,7 @@ import com.pica.cloud.foundation.redis.ICacheClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.codehaus.groovy.util.HashCodeHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -212,4 +213,28 @@ public class LoginController extends AccountBaseController {
return PicaResponse.toResponse(loginService.preLoginValidate(request));
}
@ApiOperation(value = "苹果授权登录")
@GetMapping("/login/apple")
public PicaResponse appleAuth() throws Exception{
//@RequestBody EncryptEntity entity
BaseRequest request = new BaseRequest();//CryptoUtil.decrypt(entity, BaseRequest.class);
//request.setProductType(super.getProductType());
//request.setSourceType(super.getSourceType());
request.setLoginIp(super.getIpAddr());
Map<String, Object> p = new HashMap<>();
p.put("ip", request.getLoginIp());
return PicaResponse.toResponse(p);
//return PicaResponse.toResponse(loginService.loginByApple(request));
}
@ApiOperation(value = "苹果登录绑定手机号")
@PostMapping("/login/apple/step2")
public PicaResponse appleAuthBind(@RequestBody EncryptEntity entity) throws Exception{
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setProductType(super.getProductType());
request.setSourceType(super.getSourceType());
request.setLoginIp(super.getIpAddr());
return PicaResponse.toResponse(loginService.loginByAppleStep(request));
}
}
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class AccountAppleInfo {
private Integer id;
private String appleUserId;
private String appleId;
private String info;
private Integer deleteFlag;
private Integer createdId;
private Date createdTime;
private Integer modifiedId;
private Date modifiedTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getAppleUserId() {
return appleUserId;
}
public void setAppleUserId(String appleUserId) {
this.appleUserId = appleUserId == null ? null : appleUserId.trim();
}
public String getAppleId() {
return appleId;
}
public void setAppleId(String appleId) {
this.appleId = appleId == null ? null : appleId.trim();
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info == null ? null : info.trim();
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
public Integer getCreatedId() {
return createdId;
}
public void setCreatedId(Integer createdId) {
this.createdId = createdId;
}
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Integer getModifiedId() {
return modifiedId;
}
public void setModifiedId(Integer modifiedId) {
this.modifiedId = modifiedId;
}
public Date getModifiedTime() {
return modifiedTime;
}
public void setModifiedTime(Date modifiedTime) {
this.modifiedTime = modifiedTime;
}
}
\ No newline at end of file
......@@ -33,6 +33,9 @@ public enum AccountExceptionEnum {
PICA_PASSWORD_RULE_ERROR("216525","该手机号{mobile}尚未设置密码,请先设置密码。"),
PICA_PWD_MISMATCH_4("216526", "密码错误,请重试"),
PICA_PWD_MISMATCH_5("216527", "密码错误次数过多,请前往找回密码"),
PICA_APPLE_TOKEN_ERROR("216528", "微信登录授权identifyToken不正确"),
PICA_APPLE_BIND_OTHER("216529", "该Apple账号已绑定其他账户"),
PICA_MOBILE_BIND_OTHER("216530", "该手机号已绑定其他Apple账号"),
xxx_xxx("","");
......
......@@ -13,6 +13,7 @@ public enum AccountTypeEnum {
LOGIN_WE_CHAT(3, "微信登录"),
LOGIN_OUT(4, "退出登录"),
LOGIN_REGISTER(5, "注册登录"),
LOGIN_APPLE(6, "Apple登录"),
//登录态相关枚举
LOGIN_STATUS_SUCCESS(1, "登录成功"),
......@@ -30,18 +31,23 @@ public enum AccountTypeEnum {
DEVICE_TYPE_ADMIN(5, "admin"),
//验证码获取类型: flag:0登录(默认)1注册 2微信登录绑定手机 3修改手机 4重置密码
//5忘记密码 7患者招募提交问卷(效验) 8Appe登录绑定手机
SYSCODE_TYPE_LOGIN(0, "登录"),
SYSCODE_TYPE_REGISTER(1, "注册"),
SYSCODE_TYPE_WE_CHAT(2, "微信登录绑定手机"),
SYSCODE_TYPE_MODIFY_MOBILE(3, "修改手机号"),
SYSCODE_TYPE_RESET_PASSWORD(4, "重置密码"),
SYSCODE_TYPE_FORGET_PASSWORD(5, "重置密码"),
SYSCODE_TYPE_SMO_COMIIT_QUESTIONNAIRE(6, "患者招募提交问卷"),
SYSCODE_TYPE_APPLE(8, "Appe登录绑定手机"),
//联合登录类型
UNION_LOGIN_WE_CHAT(1, "微信"),
UNION_LOGIN_QQ(2, "QQ"),
union_login_blog(3, "微博"),
UNION_LOGIN_APPLE(4, "苹果"),
//微信绑定状态
//微信/apple绑定状态
BIND_STATUS_SUCCESS(1, "已绑定"),
BIND_STATUS_FAILURE(0, "未绑定"),
......
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.AccountAppleInfo;
import org.apache.ibatis.annotations.Param;
public interface AccountAppleInfoMapper {
int insert(AccountAppleInfo record);
int insertSelective(AccountAppleInfo record);
AccountAppleInfo selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(AccountAppleInfo record);
int updateByPrimaryKey(AccountAppleInfo record);
AccountAppleInfo selectByUserId(@Param("id") String appleUserId);
}
\ No newline at end of file
......@@ -34,10 +34,16 @@ public class BaseRequest {
private String captchaToken;
@ApiModelProperty("图片验证码答案")
private String captchaAnswer;
@ApiModelProperty("苹果用户id")
private String appleUserId;
@ApiModelProperty("业务类型,1-新老业务区分标识,2-手机号格式校验业务,3-密码登录校验业务")
private Integer bizType;
@ApiModelProperty("苹果身份token")
private String identifyToken;
@ApiModelProperty("苹果用户id")
private String appleUserId;
@ApiModelProperty("appleId")
private String appleId;
@ApiModelProperty("apple用户信息(json字符串)")
private String info;
public String getCaptchaToken() {
return captchaToken;
......@@ -166,4 +172,28 @@ public class BaseRequest {
public void setBizType(Integer bizType) {
this.bizType = bizType;
}
public String getIdentifyToken() {
return identifyToken;
}
public void setIdentifyToken(String identifyToken) {
this.identifyToken = identifyToken;
}
public String getAppleId() {
return appleId;
}
public void setAppleId(String appleId) {
this.appleId = appleId;
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info;
}
}
......@@ -66,4 +66,24 @@ public interface LoginService {
* @Return com.pica.cloud.foundation.entity.PicaResponse
*/
UnifiedVerificationResp preLoginValidate(BaseRequest request);
/**
* @Description 苹果登录授权
* @Author Chongwen.jiang
* @Date 2020/2/24 10:10
* @ModifyDate 2020/2/24 10:10
* @Params [baseRequest]
* @Return com.pica.cloud.account.account.server.entity.LoginResult
*/
LoginResult loginByApple(BaseRequest baseRequest);
/**
* @Description 苹果登录绑定手机号
* @Author Chongwen.jiang
* @Date 2020/2/24 10:10
* @ModifyDate 2020/2/24 10:10
* @Params [request]
* @Return com.pica.cloud.account.account.server.entity.LoginResult
*/
LoginResult loginByAppleStep(BaseRequest request);
}
......@@ -73,6 +73,9 @@ public class LoginServiceImpl implements LoginService {
@Autowired
private ICacheClient redisClient;
@Autowired
private AccountAppleInfoMapper accountAppleInfoMapper;
@Value("${doubleWritingMode}")
private boolean doubleWritingMode;
......@@ -525,70 +528,142 @@ public class LoginServiceImpl implements LoginService {
return resp;
}
@Transactional
@Override
public LoginResult loginByApple(BaseRequest request) {
// 入参非空判断
if (StringUtils.isEmpty(request.getIdentifyToken()) ||
StringUtils.isEmpty(request.getAppleUserId()) ||
StringUtils.isEmpty(request.getAppleId())) {
throw new PicaException(AccountExceptionEnum.PICA_PARAMS_ERROR.getCode(),
AccountExceptionEnum.PICA_PARAMS_ERROR.getMessage());
}
// TODO identifyToken校验
//throw new PicaException(AccountExceptionEnum.PICA_APPLE_TOKEN_ERROR.getCode(),
//AccountExceptionEnum.PICA_APPLE_TOKEN_ERROR.getMessage());
// apple授权登录用户信息入库
AccountUnionEntity accountUnion = accountUnionMapper.selectByUnionId(request.getAppleUserId());
//是否绑定逻辑的判断
if (accountUnion != null) {
Long acctId = accountUnion.getAcctId();
Long userId = accountUtils.getUserIdByAcctId(null, acctId.intValue());
Account account = new Account();
account.setId(userId);
account.setAcctId(acctId.intValue());
account.setCreatTime(new Date());
//account.setMobilePhone(request.getMobile());
account.setMobilePhone("");
account.setRegisterSource(request.getSourceType());
String newToken = tokenUtils.generateToken(account);
LoginResult result = new LoginResult();
result.setToken(newToken);
result.setUserId(userId);
result.setBindFlag(AccountTypeEnum.BIND_STATUS_SUCCESS.getCode() + "");
result.setDoctorId(EncryptUtils.encryptContent(userId + "", EncryptConstants.ENCRYPT_TYPE_ID));
if (request.getProductType() == AccountTypeEnum.PRODUCT_TYPE_DOCTOR.getCode()) {
PICAPDoctor doctor = doctorInfoMapper.queryDoctor(userId);
result.setEntireFlag(doctor.getEntire_flag());
result.setMobile(AESUtil.decryptV0(doctor.getMobile_phone()));
}
return result;
} else {
AccountAppleInfo entity = accountAppleInfoMapper.selectByUserId(request.getAppleUserId());
//如果apple信息表数据不存在,就把用户信息存储到apple信息表中。
if (entity == null) {
processAppleInfoUser(request);
}
LoginResult result = new LoginResult();
result.setUnionId(request.getAppleUserId());
result.setBindFlag(AccountTypeEnum.BIND_STATUS_FAILURE.getCode() + "");
return result;
}
}
/**
* @Description 密码登录相关校验
* @Description apple用户信息入表
* @Author Chongwen.jiang
* @Date 2020/2/20 22:35
* @ModifyDate 2020/2/20 22:35
* @Params [resp, mobile, password]
* @Date 2020/2/24 11:00
* @ModifyDate 2020/2/24 11:00
* @Params [request]
* @Return void
*/
private void pwdLoginPreValidate(UnifiedVerificationResp resp, String mobile, String password) {
/*if (StringUtils.isNotEmpty(mobile)) {
// 判断手机号是否注册(未注册,提示去找回密码,找回密码页有注册逻辑)
AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(mobile));
if (accountInfo == null) {
// 手机未注册
resp.setBizCode(BizTypeRespEnum.MOBILE_NOT_REGIST.getCode());
resp.setBizMsg(BizTypeRespEnum.MOBILE_NOT_REGIST.getMsg()
.replace("{mobile}", mobile));
} else {
resp.setBizCode(BizTypeRespEnum.MOBILE_REGISTED.getCode());
resp.setBizMsg(BizTypeRespEnum.MOBILE_REGISTED.getMsg());
// 判断手机号是否设置密码
if (StringUtils.isEmpty(accountInfo.getPassword())) {
// 未设置密码
resp.setBizCode(BizTypeRespEnum.MOBILE_NOT_SETED_PASSWORD.getCode());
resp.setBizMsg(BizTypeRespEnum.MOBILE_NOT_SETED_PASSWORD.getMsg()
.replace("{mobile}", mobile));
}else{
resp.setBizCode(BizTypeRespEnum.MOBILE_SETED_PASSWORD.getCode());
resp.setBizMsg(BizTypeRespEnum.MOBILE_SETED_PASSWORD.getMsg());
}
}
}*/
/*if (StringUtils.isNotEmpty(password)) {
// 判断密码是否正确
if (StringUtils.isNotEmpty(mobile)) {
AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(mobile));
if (accountInfo != null) {
if (!password.equals(accountInfo.getPassword())) {
// 从缓存取出当前账号密码错误次数
String key = Constants.PWD_ERROR_NUM_KEY.replace("{mobile}", mobile);
if(redisClient.exists(key)) {
int errorCount = Integer.parseInt(redisClient.get(key));
if (errorCount <= 4) {
resp.setBizCode(BizTypeRespEnum.PWD_MISMATCH_4.getCode());
resp.setBizMsg(BizTypeRespEnum.PWD_MISMATCH_4.getMsg());
} else if (errorCount > 4) {
resp.setBizCode(BizTypeRespEnum.PWD_MISMATCH_5.getCode());
resp.setBizMsg(BizTypeRespEnum.PWD_MISMATCH_5.getMsg());
}
errorCount = errorCount + 1;
redisClient.set(key, errorCount, Constants.PWD_ERROR_NUM_SECONDS);
}else{
redisClient.set(key, 1, Constants.PWD_ERROR_NUM_SECONDS);
}
} else {
// 密码正确
resp.setBizCode(BizTypeRespEnum.PWD_MATCH_DB.getCode());
resp.setBizMsg(BizTypeRespEnum.PWD_MATCH_DB.getMsg());
}
}
}
}*/
private void processAppleInfoUser(BaseRequest request) {
AccountAppleInfo appleInfo = new AccountAppleInfo();
Date currentTime = new Date();
appleInfo.setDeleteFlag(1);
appleInfo.setCreatedId(0);
appleInfo.setCreatedTime(currentTime);
appleInfo.setModifiedId(0);
appleInfo.setModifiedTime(currentTime);
appleInfo.setAppleUserId(request.getAppleUserId());
appleInfo.setAppleId(request.getAppleId());
appleInfo.setInfo(request.getInfo());
accountAppleInfoMapper.insertSelective(appleInfo);
}
/**
* @Description 苹果登录绑定手机号
* @Author Chongwen.jiang
* @Date 2020/2/24 11:40
* @ModifyDate 2020/2/24 11:40
* @Params [request]
* @Return com.pica.cloud.account.account.server.entity.LoginResult
*/
@Override
public LoginResult loginByAppleStep(BaseRequest request) {
// 验证码校验
accountUtils.checkMobilePhoneAndAuthCode(request.getMobile(),
AccountTypeEnum.SYSCODE_TYPE_APPLE.getCode() + "",
request.getAuthCode());
// 判断当前手机号是否注册过: 没有注册过,进行注册操操作, 注册过,直接登录;
AccountInfoEntity accountInfoDb = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
LoginResult result;
if (accountInfoDb == null) {
result = registerService.register(request);
} else {
result = processLogin(request, accountInfoDb.getId(), AccountTypeEnum.LOGIN_APPLE.getCode());
}
result.setMobile(request.getMobile());
AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
Integer acctId = accountInfo.getId();
// insert account_apple_info表数据
processAccountUnionApple(acctId, request.getAppleUserId());
return result;
}
/**
* @Description account_apple_info insert
* @Author Chongwen.jiang
* @Date 2020/2/24 11:34
* @ModifyDate 2020/2/24 11:34
* @Params [acctId, appleUserId]
* @Return void
*/
private void processAccountUnionApple(Integer acctId, String appleUserId) {
AccountUnionEntity accountUnion = accountUnionMapper.selectByUnionId(appleUserId);
if (accountUnion != null) {
throw new PicaException(AccountExceptionEnum.PICA_APPLE_BIND_OTHER.getCode(),
AccountExceptionEnum.PICA_APPLE_BIND_OTHER.getMessage());
}
AccountUnionEntity accountUnionEntityAccount = accountUnionMapper.selectByAcctId(acctId);
if (accountUnionEntityAccount != null) {
throw new PicaException(AccountExceptionEnum.PICA_MOBILE_BIND_OTHER.getCode(),
AccountExceptionEnum.PICA_MOBILE_BIND_OTHER.getMessage());
}
AccountUnionEntity accountUnionEntity = new AccountUnionEntity();
accountUnionEntity.setAcctId(acctId.longValue());
accountUnionEntity.setDeleteFlag(1);
accountUnionEntity.setUnionId(appleUserId);
accountUnionEntity.setCreatedTime(new Date());
accountUnionEntity.setModifiedTime(new Date());
accountUnionEntity.setCreatedId(acctId);
accountUnionEntity.setModifiedId(acctId);
accountUnionEntity.setUnionType(AccountTypeEnum.UNION_LOGIN_APPLE.getCode());
accountUnionMapper.insertSelective(accountUnionEntity);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!-- 数据库驱动:选择你的本地硬盘上面的数据库驱动包-->
<classPathEntry location="D:\programer\reponsitory\maven\mysql\mysql-connector-java\5.1.39\mysql-connector-java-5.1.39.jar"/>
<!--<classPathEntry location="E:\mysql_jar/mysql-connector-java-5.1.39.jar"/>-->
<context id="tableEntity" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressDate" value="true"/>
<!-- 是否去除自动生成的注释 true:是 : false:否 -->
<property name="suppressAllComments" value="true"/>
<property name="addRemarkComments" value="true"/>
<property name="dateFormat" value="false"/>
<property name="suppressDate" value="false"/>
</commentGenerator>
<!--数据库链接URL,用户名、密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://192.168.130.200:3306/pica"
userId="pica" password="Joa5@73&amp;8yAYJ2fe">
</jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成模型的包名和位置-->
<javaModelGenerator targetPackage="com.pica.cloud.account.account.server.entity" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 生成映射文件的包名和位置-->
<sqlMapGenerator targetPackage="mybatis" targetProject="src/main/resources">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成DAO的包名和位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.pica.cloud.account.account.server.mapper" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<table tableName="account_apple_info" domainObjectName="AccountAppleInfo" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pica.cloud.account.account.server.mapper.AccountAppleInfoMapper" >
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.AccountAppleInfo" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="apple_user_id" property="appleUserId" jdbcType="VARCHAR" />
<result column="apple_id" property="appleId" jdbcType="VARCHAR" />
<result column="info" property="info" jdbcType="VARCHAR" />
<result column="delete_flag" property="deleteFlag" jdbcType="INTEGER" />
<result column="created_id" property="createdId" jdbcType="INTEGER" />
<result column="created_time" property="createdTime" jdbcType="TIMESTAMP" />
<result column="modified_id" property="modifiedId" jdbcType="INTEGER" />
<result column="modified_time" property="modifiedTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, apple_user_id, apple_id, info, delete_flag, created_id, created_time, modified_id,
modified_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from account_apple_info
where id = #{id,jdbcType=INTEGER}
</select>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.AccountAppleInfo" >
insert into account_apple_info (id, apple_user_id, apple_id,
info, delete_flag, created_id,
created_time, modified_id, modified_time
)
values (#{id,jdbcType=INTEGER}, #{appleUserId,jdbcType=VARCHAR}, #{appleId,jdbcType=VARCHAR},
#{info,jdbcType=VARCHAR}, #{deleteFlag,jdbcType=INTEGER}, #{createdId,jdbcType=INTEGER},
#{createdTime,jdbcType=TIMESTAMP}, #{modifiedId,jdbcType=INTEGER}, #{modifiedTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.AccountAppleInfo" >
insert into account_apple_info
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="appleUserId != null" >
apple_user_id,
</if>
<if test="appleId != null" >
apple_id,
</if>
<if test="info != null" >
info,
</if>
<if test="deleteFlag != null" >
delete_flag,
</if>
<if test="createdId != null" >
created_id,
</if>
<if test="createdTime != null" >
created_time,
</if>
<if test="modifiedId != null" >
modified_id,
</if>
<if test="modifiedTime != null" >
modified_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="appleUserId != null" >
#{appleUserId,jdbcType=VARCHAR},
</if>
<if test="appleId != null" >
#{appleId,jdbcType=VARCHAR},
</if>
<if test="info != null" >
#{info,jdbcType=VARCHAR},
</if>
<if test="deleteFlag != null" >
#{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createdId != null" >
#{createdId,jdbcType=INTEGER},
</if>
<if test="createdTime != null" >
#{createdTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null" >
#{modifiedId,jdbcType=INTEGER},
</if>
<if test="modifiedTime != null" >
#{modifiedTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.AccountAppleInfo" >
update account_apple_info
<set >
<if test="appleUserId != null" >
apple_user_id = #{appleUserId,jdbcType=VARCHAR},
</if>
<if test="appleId != null" >
apple_id = #{appleId,jdbcType=VARCHAR},
</if>
<if test="info != null" >
info = #{info,jdbcType=VARCHAR},
</if>
<if test="deleteFlag != null" >
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createdId != null" >
created_id = #{createdId,jdbcType=INTEGER},
</if>
<if test="createdTime != null" >
created_time = #{createdTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null" >
modified_id = #{modifiedId,jdbcType=INTEGER},
</if>
<if test="modifiedTime != null" >
modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.AccountAppleInfo" >
update account_apple_info
set apple_user_id = #{appleUserId,jdbcType=VARCHAR},
apple_id = #{appleId,jdbcType=VARCHAR},
info = #{info,jdbcType=VARCHAR},
delete_flag = #{deleteFlag,jdbcType=INTEGER},
created_id = #{createdId,jdbcType=INTEGER},
created_time = #{createdTime,jdbcType=TIMESTAMP},
modified_id = #{modifiedId,jdbcType=INTEGER},
modified_time = #{modifiedTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<!--通过appleUserId获取apple信息-->
<select id="selectByUserId" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List"/>
from account_apple_info
where apple_user_id = #{id} and delete_flag = 1
limit 1
</select>
</mapper>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册