Przeglądaj źródła

修复LoginContext的bug。

yangzhijie 5 lat temu
rodzic
commit
cc9ffb99ed

+ 0 - 84
src/main/java/com/leanwo/gateway/util/LoginContext.java

@@ -8,22 +8,10 @@ public class LoginContext {
 
 	/** 账套ID. */
 	private Long accountId;
-
-	/** 账套日期. */
-	private Date accountDate;
 	
 	/** 登陆人员ID. */
 	private Long userId;
 
-	/** 登陆角色. */
-	private Long roleId;
-
-	/** 登陆公司. */
-	private Long clientId;
-
-	/** 登陆部门. */
-	private Long orgId;
-
 	/**
 	 * Gets the 登陆人员ID.
 	 *
@@ -42,60 +30,6 @@ public class LoginContext {
 		this.userId = userId;
 	}
 
-	/**
-	 * Gets the 登陆角色.
-	 *
-	 * @return the 登陆角色
-	 */
-	public Long getRoleId() {
-		return roleId;
-	}
-
-	/**
-	 * Sets the 登陆角色.
-	 *
-	 * @param roleId the new 登陆角色
-	 */
-	public void setRoleId(Long roleId) {
-		this.roleId = roleId;
-	}
-
-	/**
-	 * Gets the 登陆公司.
-	 *
-	 * @return the 登陆公司
-	 */
-	public Long getClientId() {
-		return clientId;
-	}
-
-	/**
-	 * Sets the 登陆公司.
-	 *
-	 * @param clientId the new 登陆公司
-	 */
-	public void setClientId(Long clientId) {
-		this.clientId = clientId;
-	}
-
-	/**
-	 * Gets the 登陆部门.
-	 *
-	 * @return the 登陆部门
-	 */
-	public Long getOrgId() {
-		return orgId;
-	}
-
-	/**
-	 * Sets the 登陆部门.
-	 *
-	 * @param orgId the new 登陆部门
-	 */
-	public void setOrgId(Long orgId) {
-		this.orgId = orgId;
-	}
-
 
 	/**
 	 * Gets the 账套ID.
@@ -114,22 +48,4 @@ public class LoginContext {
 	public void setAccountId(Long accountId) {
 		this.accountId = accountId;
 	}
-
-	/**
-	 * Gets the 账套日期.
-	 *
-	 * @return the 账套日期
-	 */
-	public Date getAccountDate() {
-		return accountDate;
-	}
-
-	/**
-	 * Sets the 账套日期.
-	 *
-	 * @param accountDate the new 账套日期
-	 */
-	public void setAccountDate(Date accountDate) {
-		this.accountDate = accountDate;
-	}
 }

+ 70 - 106
src/main/java/com/leanwo/gateway/util/LoginContextUtil.java

@@ -1,106 +1,70 @@
-package com.leanwo.gateway.util;
-
-/**
- * 线程变量
- * @author YangZhiJie
- *
- */
-public class LoginContextUtil {
-	
-private static ThreadLocal<LoginContext> loginContextHolder = new ThreadLocal<LoginContext>();
-	
-	private static ThreadLocal<String> uuidHolder = new ThreadLocal<String>();
-	
-	/**
-	 * 从线程获取LoginContext
-	 * @return
-	 */
-	public static LoginContext getLoginContext(){
-		LoginContext loginContext = loginContextHolder.get();
-		return loginContext;
-	}
-	
-	/**
-	 * 设置线程的LoginContext
-	 * @param loginContext
-	 */
-	public static void setLoginContext(LoginContext loginContext){
-		loginContextHolder.set(loginContext);
-	}
-	
-	/**
-	 * 从线程获取UUID
-	 * @return
-	 */
-	public static String getUuid(){
-		String uuid = uuidHolder.get();
-		return uuid;
-	}
-	
-	/**
-	 * 设置线程的UUID
-	 * @param loginContext
-	 */
-	public static void setUuid(String uuid){
-		uuidHolder.set(uuid);
-	}
-	
-	/**
-	 * 设置线程的环境变量
-	 * @param clientId
-	 * @param orgnizationId
-	 * @param userId
-	 * @param accountId
-	 */
-	public static void setLoginContext(Long clientId, Long orgnizationId, Long userId, Long accountId){
-		LoginContext loginContext = getLoginContext();
-		if(loginContext == null){
-			loginContext = new LoginContext();
-			LoginContextUtil.setLoginContext(loginContext);
-		}
-		loginContext.setClientId(clientId);
-		loginContext.setOrgId(orgnizationId);
-		loginContext.setUserId(userId);
-		loginContext.setAccountId(accountId);
-	}
-
-	/**
-	 * 设置线程的环境变量
-	 * @param clientId
-	 * @param orgnizationId
-	 * @param userId
-	 * @param accountId
-	 */
-	public static void setLoginContext(Long clientId, Long orgnizationId){
-		LoginContext loginContext = getLoginContext();
-		if(loginContext == null){
-			loginContext = new LoginContext();
-			LoginContextUtil.setLoginContext(loginContext);
-		}
-		loginContext.setClientId(clientId);
-		loginContext.setOrgId(orgnizationId);
-	}
-	
-	/**
-	 * 设置使用 accoutId 账户<br>
-	 * 一般用在工作流中
-	 * Add by jack 20151010
-	 */
-	public static void setUseApplicationAccount(Long accountId){
-		LoginContext loginContext = getLoginContext();
-		if(loginContext == null){
-			loginContext = new LoginContext();
-			LoginContextUtil.setLoginContext(loginContext);
-		}
-		loginContext.setAccountId(accountId);
-	}
-
-	
-	
-	/**
-	 * 清空LoginContext
-	 */
-	public static void clear(){
-		loginContextHolder.set(null);
-	}
-}
+package com.leanwo.gateway.util;
+
+/**
+ * 线程变量
+ * @author YangZhiJie
+ *
+ */
+public class LoginContextUtil {
+	
+private static ThreadLocal<LoginContext> loginContextHolder = new ThreadLocal<LoginContext>();
+	
+	private static ThreadLocal<String> uuidHolder = new ThreadLocal<String>();
+	
+	/**
+	 * 从线程获取LoginContext
+	 * @return
+	 */
+	public static LoginContext getLoginContext(){
+		LoginContext loginContext = loginContextHolder.get();
+		return loginContext;
+	}
+	
+	/**
+	 * 设置线程的LoginContext
+	 * @param loginContext
+	 */
+	public static void setLoginContext(LoginContext loginContext){
+		loginContextHolder.set(loginContext);
+	}
+	
+	/**
+	 * 从线程获取UUID
+	 * @return
+	 */
+	public static String getUuid(){
+		String uuid = uuidHolder.get();
+		return uuid;
+	}
+	
+	/**
+	 * 设置线程的UUID
+	 * @param loginContext
+	 */
+	public static void setUuid(String uuid){
+		uuidHolder.set(uuid);
+	}
+	
+	/**
+	 * 设置使用 accoutId 账户<br>
+	 * 一般用在工作流中
+	 * Add by jack 20151010
+	 */
+	public static void setUseApplicationAccount(Long accountId){
+		LoginContext loginContext = getLoginContext();
+		if(loginContext == null){
+			loginContext = new LoginContext();
+			LoginContextUtil.setLoginContext(loginContext);
+		}
+		loginContext.setAccountId(accountId);
+	}
+
+	
+	
+	/**
+	 * 清空LoginContext
+	 */
+	public static void clear(){
+		loginContextHolder.set(null);
+	}
+}