You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					
					
						
							59 lines
						
					
					
						
							1.7 KiB
						
					
					
				
			
		
		
	
	
							59 lines
						
					
					
						
							1.7 KiB
						
					
					
				| package com.ynxbd.common.service.params;
 | |
| 
 | |
| import org.apache.commons.lang3.StringUtils;
 | |
| 
 | |
| import javax.servlet.http.HttpServletRequest;
 | |
| import java.math.BigDecimal;
 | |
| 
 | |
| public class RequestParams {
 | |
|     private final HttpServletRequest request;
 | |
| 
 | |
|     public RequestParams(HttpServletRequest request) {
 | |
|         this.request = request;
 | |
|     }
 | |
| 
 | |
|     protected String getString(String param) {
 | |
|         String parameter = this.request.getParameter(param);
 | |
|         if ("".equals(parameter)) {
 | |
|             return null;
 | |
|         }
 | |
|         return parameter;
 | |
|     }
 | |
| 
 | |
|     protected Integer getInteger(String param) {
 | |
|         try {
 | |
|             String val = this.request.getParameter(param);
 | |
|             return StringUtils.isEmpty(val) ? null : Integer.valueOf(val);
 | |
|         } catch (Exception e) {
 | |
|             return null;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     protected Double getDouble(String param) {
 | |
|         try {
 | |
|             String val = this.request.getParameter(param);
 | |
|             return StringUtils.isEmpty(val) ? null : Double.valueOf(val);
 | |
|         } catch (Exception e) {
 | |
|             return null;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     protected BigDecimal getBigDecimal(String param) {
 | |
|         try {
 | |
|             String val = this.request.getParameter(param);
 | |
|             return StringUtils.isEmpty(val) ? null : new BigDecimal(val);
 | |
|         } catch (Exception e) {
 | |
|             return null;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     protected Boolean getBoolean(String param) {
 | |
|         try {
 | |
|             String val = this.request.getParameter(param);
 | |
|             return StringUtils.isEmpty(val) ? null : Boolean.valueOf(val);
 | |
|         } catch (Exception e) {
 | |
|             return null;
 | |
|         }
 | |
|     }
 | |
| 
 | |
| }
 | |
| 
 |