提交 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;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service("")
@Service
public class AccountUnionServiceImpl implements AccountUnionService {
@Autowired
......
......@@ -65,6 +65,9 @@ public class LoginServiceImpl implements LoginService {
@Qualifier("cacheMigrateClient")
private ICacheClient redisClient;
@Value("${doubleWritingMode}")
private boolean doubleWritingMode;
@Value("${weChatAppID}")
private String appId;
@Value("${weChatAppSecret}")
......@@ -206,6 +209,17 @@ public class LoginServiceImpl implements LoginService {
String json;
if (accountInfoEntity == null) {
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 {
json = processLogin(request, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_WE_CHAT.getCode());
}
......@@ -236,6 +250,12 @@ public class LoginServiceImpl implements LoginService {
processAccountUnion(request.getAccId(), unionId);
}
/**
* 把unionId存储到联合登录表中
*
* @param acctId
* @param unionId
*/
private void processAccountUnion(Integer acctId, String unionId) {
AccountUnionEntity accountUnionEntity = new AccountUnionEntity();
accountUnionEntity.setAcctId(acctId.longValue());
......
......@@ -29,6 +29,9 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
......@@ -122,7 +125,14 @@ public class RegisterServiceImpl implements RegisterService {
jsonObject.put(Constants.TOKEN, newToken);
jsonObject.put(Constants.USER_ID, userId);
//注册成功后发送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(),
AccountTypeEnum.LOGIN_REGISTER.getCode(), baseRequest.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(),
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册