|
|
@@ -26,8 +26,10 @@ import org.hibernate.annotations.Cache;
|
|
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
|
|
import org.hibernate.annotations.NotFound;
|
|
|
import org.hibernate.annotations.NotFoundAction;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import com.alibaba.fastjson.annotation.JSONField;
|
|
|
+import com.uas.platform.b2b.support.SystemSession;
|
|
|
import com.uas.platform.core.model.Constant;
|
|
|
|
|
|
@Entity
|
|
|
@@ -241,6 +243,20 @@ public class User implements Serializable {
|
|
|
if (this.enterprise == null)
|
|
|
setCurrentEnterprise();
|
|
|
}
|
|
|
+
|
|
|
+ public void setCurrentEnterprise(Enterprise enterprise) {
|
|
|
+ if(!CollectionUtils.isEmpty(SystemSession.getUser().getEnterprises())) {
|
|
|
+ Set<Enterprise> enterprises = new HashSet<Enterprise>();
|
|
|
+ for (Enterprise en : SystemSession.getUser().getEnterprises()) {
|
|
|
+ if (en.equals(enterprise)) {
|
|
|
+ enterprises.add(enterprise);
|
|
|
+ }
|
|
|
+ enterprises.add(en);
|
|
|
+ }
|
|
|
+ SystemSession.getUser().setEnterprises(enterprises);
|
|
|
+ SystemSession.getUser().setCurrentEnterprise(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
public Set<Role> getRoles() {
|
|
|
return roles;
|
|
|
@@ -268,8 +284,6 @@ public class User implements Serializable {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @JsonIgnore
|
|
|
- @JSONField(serialize = false)
|
|
|
public boolean isSys() {
|
|
|
return getIssys() != null && getIssys() == Constant.YES;
|
|
|
}
|