Commit 80a545ab authored by gaoguangjing's avatar gaoguangjing

校验是否为空,不为空执行

parent 9b7f907d
...@@ -42,58 +42,60 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService { ...@@ -42,58 +42,60 @@ public class OauthLoginInfoServiceImpl implements IOauthLoginInfoService {
public void addLoginInfo(User user, String tenantId) { public void addLoginInfo(User user, String tenantId) {
System.out.println(atomicSequencer.nextId()); System.out.println(atomicSequencer.nextId());
OauthClientDetailsEntity oauthClientDetailsEntity = oauthClientDetailsRepository.findFirstByClientId(tenantId); OauthClientDetailsEntity oauthClientDetailsEntity = oauthClientDetailsRepository.findFirstByClientId(tenantId);
String institutionId = oauthClientDetailsEntity.getInstitutionId(); if (oauthClientDetailsEntity != null) {
String productId = oauthClientDetailsEntity.getProductId(); String institutionId = oauthClientDetailsEntity.getInstitutionId();
String phoneNo = user.getPhoneNo(); String productId = oauthClientDetailsEntity.getProductId();
Long userId = user.getId(); String phoneNo = user.getPhoneNo();
ProductLoginEntity productLoginEntity = productLoginRepository.findFirstByInstitutionIdAndProductIdAndPhoneNo(institutionId, productId, phoneNo); Long userId = user.getId();
long uuid = 0L; ProductLoginEntity productLoginEntity = productLoginRepository.findFirstByInstitutionIdAndProductIdAndPhoneNo(institutionId, productId, phoneNo);
// 如果找不到该用户就创建 long uuid = 0L;
if ("".equals(productLoginEntity) || productLoginEntity == null) { // 如果找不到该用户就创建
// 添加用户到产品登录表 if ("".equals(productLoginEntity) || productLoginEntity == null) {
long customerId = atomicSequencer.nextId(); // 添加用户到产品登录表
long customerId = atomicSequencer.nextId();
// long id = session.nextId(); // long id = session.nextId();
long id = atomicSequencer.nextId(); long id = atomicSequencer.nextId();
String customerName = customerId + ""; String customerName = customerId + "";
uuid = RandomSequencer.randomUUID(customerId); uuid = RandomSequencer.randomUUID(customerId);
ProductLoginEntity entity = new ProductLoginEntity(); ProductLoginEntity entity = new ProductLoginEntity();
Integer partitionKey = atomicSequencer.partitionKey(customerId); Integer partitionKey = atomicSequencer.partitionKey(customerId);
productLoginEntity = EntityBuilder.productLogin(productId, institutionId, phoneNo, customerId, customerName, partitionKey, id); productLoginEntity = EntityBuilder.productLogin(productId, institutionId, phoneNo, customerId, customerName, partitionKey, id);
productLoginEntity.setExtensionAccountId(userId); productLoginEntity.setExtensionAccountId(userId);
productLoginRepository.save(productLoginEntity); productLoginRepository.save(productLoginEntity);
// 根据customerId 获取uuid // 根据customerId 获取uuid
CustomerLoginEntity customerLoginEntity = customerLoginRepository.findFirstByCustomerId(productLoginEntity.getCustomerId()); CustomerLoginEntity customerLoginEntity = customerLoginRepository.findFirstByCustomerId(productLoginEntity.getCustomerId());
if (null != customerLoginEntity) { if (null != customerLoginEntity) {
uuid = customerLoginEntity.getUuid(); uuid = customerLoginEntity.getUuid();
} }
// 添加用户到登录表 // 添加用户到登录表
CustomerLoginEntity customerLogin = new CustomerLoginEntity(); CustomerLoginEntity customerLogin = new CustomerLoginEntity();
customerLogin.setId(atomicSequencer.nextId()); customerLogin.setId(atomicSequencer.nextId());
customerLogin.setInstitutionId(institutionId); customerLogin.setInstitutionId(institutionId);
customerLogin.setProductId(productId); customerLogin.setProductId(productId);
customerLogin.setCustomerId(customerId); customerLogin.setCustomerId(customerId);
customerLogin.setUuid(uuid); customerLogin.setUuid(uuid);
customerLogin.setPartitionKey(partitionKey); customerLogin.setPartitionKey(partitionKey);
customerLogin.setCreatedDate(new Date()); customerLogin.setCreatedDate(new Date());
customerLogin.setModifiedDate(new Date()); customerLogin.setModifiedDate(new Date());
customerLogin.setCreatedBy(""); customerLogin.setCreatedBy("");
customerLogin.setModifiedBy(""); customerLogin.setModifiedBy("");
customerLoginRepository.save(customerLogin); customerLoginRepository.save(customerLogin);
// 添加用户信息表 // 添加用户信息表
CustomerInfoEntity customerInfo = new CustomerInfoEntity(); CustomerInfoEntity customerInfo = new CustomerInfoEntity();
customerInfo.setId(atomicSequencer.nextId()); customerInfo.setId(atomicSequencer.nextId());
customerInfo.setCustomerId(customerId); customerInfo.setCustomerId(customerId);
customerInfo.setInstitutionId(institutionId); customerInfo.setInstitutionId(institutionId);
customerInfo.setProductId(productId); customerInfo.setProductId(productId);
customerInfo.setPartitionKey(partitionKey); customerInfo.setPartitionKey(partitionKey);
customerInfo.setCreatedDate(new Date()); customerInfo.setCreatedDate(new Date());
customerInfo.setModifiedDate(new Date()); customerInfo.setModifiedDate(new Date());
customerInfo.setCreatedBy(""); customerInfo.setCreatedBy("");
customerInfo.setModifiedBy(""); customerInfo.setModifiedBy("");
customerInfoRepository.save(customerInfo); customerInfoRepository.save(customerInfo);
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment