Commit 80a545ab authored by gaoguangjing's avatar gaoguangjing

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

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