提交 4994b549 编写于 作者: rushui.chen's avatar rushui.chen

20190911 把unionId插入doctor表中,数据双写

上级 2d1ebdc8
流水线 #14382 已失败 于阶段
in 0 second
...@@ -6,7 +6,7 @@ import com.pica.cloud.account.account.server.service.AccountUnionService; ...@@ -6,7 +6,7 @@ import com.pica.cloud.account.account.server.service.AccountUnionService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service("") @Service
public class AccountUnionServiceImpl implements AccountUnionService { public class AccountUnionServiceImpl implements AccountUnionService {
@Autowired @Autowired
......
...@@ -65,6 +65,9 @@ public class LoginServiceImpl implements LoginService { ...@@ -65,6 +65,9 @@ public class LoginServiceImpl implements LoginService {
@Qualifier("cacheMigrateClient") @Qualifier("cacheMigrateClient")
private ICacheClient redisClient; private ICacheClient redisClient;
@Value("${doubleWritingMode}")
private boolean doubleWritingMode;
@Value("${weChatAppID}") @Value("${weChatAppID}")
private String appId; private String appId;
@Value("${weChatAppSecret}") @Value("${weChatAppSecret}")
...@@ -206,6 +209,17 @@ public class LoginServiceImpl implements LoginService { ...@@ -206,6 +209,17 @@ public class LoginServiceImpl implements LoginService {
String json; String json;
if (accountInfoEntity == null) { if (accountInfoEntity == null) {
json = registerService.register(request); json = registerService.register(request);
if (doubleWritingMode) {
//双写模式下,要在doctor表存储unionId
JSONObject jsonObject = JSONObject.parseObject(json);
if (jsonObject.containsKey("userId")) {
Integer userId = jsonObject.getInteger("userId");
Doctor doctor = new Doctor();
doctor.setId(userId);
doctor.setUnionid(request.getUnionId());
doctorInfoMapper.updateByPrimaryKeySelective(doctor);
}
}
} else { } else {
json = processLogin(request, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_WE_CHAT.getCode()); json = processLogin(request, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_WE_CHAT.getCode());
} }
...@@ -236,6 +250,12 @@ public class LoginServiceImpl implements LoginService { ...@@ -236,6 +250,12 @@ public class LoginServiceImpl implements LoginService {
processAccountUnion(request.getAccId(), unionId); processAccountUnion(request.getAccId(), unionId);
} }
/**
* 把unionId存储到联合登录表中
*
* @param acctId
* @param unionId
*/
private void processAccountUnion(Integer acctId, String unionId) { private void processAccountUnion(Integer acctId, String unionId) {
AccountUnionEntity accountUnionEntity = new AccountUnionEntity(); AccountUnionEntity accountUnionEntity = new AccountUnionEntity();
accountUnionEntity.setAcctId(acctId.longValue()); accountUnionEntity.setAcctId(acctId.longValue());
......
...@@ -29,6 +29,9 @@ import org.springframework.beans.factory.annotation.Qualifier; ...@@ -29,6 +29,9 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -122,7 +125,14 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -122,7 +125,14 @@ public class RegisterServiceImpl implements RegisterService {
jsonObject.put(Constants.TOKEN, newToken); jsonObject.put(Constants.TOKEN, newToken);
jsonObject.put(Constants.USER_ID, userId); jsonObject.put(Constants.USER_ID, userId);
//注册成功后发送mq消息,让别的服务初始化数据 //注册成功后发送mq消息,让别的服务初始化数据
queueProducer.send("1".getBytes()); 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(), LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, productType, baseRequest.getSourceType(),
AccountTypeEnum.LOGIN_REGISTER.getCode(), baseRequest.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(), AccountTypeEnum.LOGIN_REGISTER.getCode(), baseRequest.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(),
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册