|  | @ -0,0 +1,43 @@
 | 
	
		
			
				|  |  | package com.yihu.hos.rest.services.gateway;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Component;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import javax.servlet.http.HttpServletResponse;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * @author HZY
 | 
	
		
			
				|  |  |  * @vsrsion 1.0
 | 
	
		
			
				|  |  |  * Created at 2017/6/13.
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | @Component("errorHandleService")
 | 
	
		
			
				|  |  | public class ErrorHandleService {
 | 
	
		
			
				|  |  |     public static final String BEAN_ID = "errorHandleService";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private final static String PARAM_ERROR = "{\"successFlg\":false,\"pageSize\":10,\"currPage\":0,\"totalPage\":0,\"totalCount\":0,\"detailModelList\":null,\"obj\":null,\"errorMsg\":\"paramError!\",\"errorCode\":0}";
 | 
	
		
			
				|  |  |     private final static String OUTDATE_ERROR = "{\"successFlg\":false,\"pageSize\":10,\"currPage\":0,\"totalPage\":0,\"totalCount\":0,\"detailModelList\":null,\"obj\":null,\"errorMsg\":\"outdateError!\",\"errorCode\":0}";
 | 
	
		
			
				|  |  |     private final static String SIGN_VALID_ERROR = "{\"successFlg\":false,\"pageSize\":10,\"currPage\":0,\"totalPage\":0,\"totalCount\":0,\"detailModelList\":null,\"obj\":null,\"errorMsg\":\"signValidError!\",\"errorCode\":0}";
 | 
	
		
			
				|  |  |     private final static String UNAUTHORISED_ERROR = "{\"successFlg\":false,\"pageSize\":10,\"currPage\":0,\"totalPage\":0,\"totalCount\":0,\"detailModelList\":null,\"obj\":null,\"errorMsg\":\"unauthorizedError!\",\"errorCode\":0}";
 | 
	
		
			
				|  |  |     private final static String OTHER_ERROR = "{\"successFlg\":false,\"pageSize\":10,\"currPage\":0,\"totalPage\":0,\"totalCount\":0,\"detailModelList\":null,\"obj\":null,\"errorMsg\":\"otherError!\",\"errorCode\":0}";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public String getError(HttpServletResponse response,String errorCode) {
 | 
	
		
			
				|  |  |         switch (errorCode){
 | 
	
		
			
				|  |  |             case "paramError":
 | 
	
		
			
				|  |  |                 response.setHeader("errorCode",PARAM_ERROR);
 | 
	
		
			
				|  |  |                 return PARAM_ERROR;
 | 
	
		
			
				|  |  |             case "outdateError":
 | 
	
		
			
				|  |  |                 response.setHeader("errorCode",OUTDATE_ERROR);
 | 
	
		
			
				|  |  |                 return OUTDATE_ERROR;
 | 
	
		
			
				|  |  |             case "signValidError":
 | 
	
		
			
				|  |  |                 response.setHeader("errorCode",SIGN_VALID_ERROR);
 | 
	
		
			
				|  |  |                 return SIGN_VALID_ERROR;
 | 
	
		
			
				|  |  |             case "unauthorizedError":
 | 
	
		
			
				|  |  |                 response.setHeader("errorCode",UNAUTHORISED_ERROR);
 | 
	
		
			
				|  |  |                 return UNAUTHORISED_ERROR;
 | 
	
		
			
				|  |  |             default:
 | 
	
		
			
				|  |  |                 response.setHeader("errorCode",UNAUTHORISED_ERROR);
 | 
	
		
			
				|  |  |                 return UNAUTHORISED_ERROR;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | }
 |