|
|
@@ -2,6 +2,8 @@ package com.uas.platform.b2c.common.account.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.uas.account.entity.UserView;
|
|
|
+import com.uas.platform.b2c.common.account.dao.EnterpriseDao;
|
|
|
+import com.uas.platform.b2c.common.account.dao.UserDao;
|
|
|
import com.uas.platform.b2c.common.account.dao.UserLoginTimeDao;
|
|
|
import com.uas.platform.b2c.common.account.model.Enterprise;
|
|
|
import com.uas.platform.b2c.common.account.model.SigninLog;
|
|
|
@@ -52,6 +54,12 @@ public class SecurityController {
|
|
|
@Autowired
|
|
|
private UserLoginTimeDao userLoginTimeDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private EnterpriseDao enterpriseDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserDao userDao;
|
|
|
+
|
|
|
private final DeviceResolver deviceResolver = new LiteDeviceResolver();
|
|
|
|
|
|
/**
|
|
|
@@ -282,7 +290,18 @@ public class SecurityController {
|
|
|
if (authedUser != null && authedUser.getEnterprises() != null) {
|
|
|
// 企业资料在client系统自己的唯一标识,比如en_uu
|
|
|
if (tokenUser.getSpaceDialectUID() != null) {
|
|
|
- authedUser.setCurrentEnterprise(Long.parseLong(tokenUser.getSpaceDialectUID()));
|
|
|
+ // 如果企业不存在则更新该企业
|
|
|
+ for (Enterprise enterprise : authedUser.getEnterprises()) {
|
|
|
+ if (enterprise.getUu().equals(Long.parseLong(tokenUser.getSpaceDialectUID()))){
|
|
|
+ authedUser.setEnterprise(enterprise);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (null == authedUser.getEnterprise()) {
|
|
|
+ Enterprise newEnterprise = enterpriseDao.findByUu(Long.parseLong(tokenUser.getSpaceDialectUID()));
|
|
|
+ authedUser.getEnterprises().add(newEnterprise);
|
|
|
+ userDao.save(authedUser);
|
|
|
+ authedUser.setEnterprise(newEnterprise);
|
|
|
+ }
|
|
|
} else if (tokenUser.getSpaceUID() != null) {
|
|
|
for (Enterprise enterprise : authedUser.getEnterprises()) {
|
|
|
// 企业资料在所有系统公认的唯一标识,这里使用商业登记证号
|