package com.zzsn.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * 系统封装参数实现
 * @author 李东亮
 * @date 2014-5-29 上午10:34:38
 * @company 郑州怡晟电子商务有限公司
 */
public class SystemContext {
	    private static ThreadLocal<Long> offSet = new ThreadLocal<Long>();  
	    private static ThreadLocal<Long> pageSize = new ThreadLocal<Long>();
	    private static ThreadLocal<Long> orgId = new ThreadLocal<Long>();
	    private static ThreadLocal<String> sort = new ThreadLocal<String>();
		private static ThreadLocal<String> order = new ThreadLocal<String>();
	    HttpServletRequest request;
	    HttpSession session =  request.getSession();
	    /* 
	     * offset ：get、set、remove 
	     */  
	    public static Long getOffSet() {  
	    	Long os =offSet.get();  
	        if (os == null) {  
	            return 0L;  
	        }  
	        return os;  
	    }  
	    public static void setOffSet(Long offSetValue) {  
	        offSet.set(offSetValue);  
	    }  
	    public static void removeOffSet(){  
	        offSet.remove();  
	    }   
	    
	    public static String getSort() {
			String st = sort.get(); 
			return st;
		}

		public static void setSort(String sortValue) {
			sort.set(sortValue);
		}

		public static void removeOrderBymethod() {
			sort.remove();
		}

		/*
		 * offset ：get、set、remove
		 */
		public static String getOrder() {
			String obc = order.get();
			return obc;
		}

		public static void setOrder(String orderValue) {
			order.set(orderValue);
		}

		public static void removeOrder() {
			order.remove();
		}

	    /* 
	     * orgId ：get、set、remove 
	     */  
	    public static Long getOrgId() {  
	        return orgId.get();
	    }  
	    public static void setOrgId(Long id) {  
	    	orgId.set(id);
	    }  
	    public static void removeOrgId(){  
	    	orgId.remove();  
	    }   
	    public static HttpSession session() {
	       return session();
	    }  
	    

	    
	    /* 
	     * pageSize ：get、set、remove 
	     */  
	    public static Long getPageSize() {  
	        Long ps = pageSize.get();  
	        if (ps == null) {  
	            return 10L;  
	        }  
	        return ps;  
	    }  
	    public static void setPageSize(Long pageSizeValue) {  
	        pageSize.set(pageSizeValue);  
	    }  
	    public static void removePageSize(){  
	        pageSize.remove();  
	    }

}
