package com.landtool.lanbase.common.utils;
|
|
|
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
import java.util.LinkedHashMap;
|
import java.util.Map;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import com.landtool.lanbase.common.xss.SQLFilter;
|
|
/**
|
* @author lanbase
|
* @Description: TODO(查询参数)
|
* @date 2017-6-23 15:07
|
*/
|
public class Query extends LinkedHashMap<String, Object> {
|
private static final long serialVersionUID = 1L;
|
//当前页码
|
private int page;
|
//每页条数
|
private int limit;
|
|
public Query(Map<String, Object> params){
|
this.putAll(params);
|
|
//分页参数
|
this.page = Integer.parseInt(params.get("page").toString());
|
this.limit = Integer.parseInt(params.get("limit").toString());
|
this.put("page", page);
|
this.put("limit", limit);
|
this.put("lowerOffset", (page - 1) * limit);
|
this.put("upperOffset", page * limit );
|
|
//防止SQL注入(因为sidx、order是通过拼接SQL实现排序的,会有SQL注入风险)
|
String sidx = (String)params.get("sidx");
|
String order = (String)params.get("order");
|
String fkey=(String)params.get("fkey");
|
String cname=(String)params.get("cname");
|
String appid=(String)params.get("appid");
|
String UserName=(String)params.get("userName");
|
String beginDate=(String)params.get("beginDate");
|
String endDate=(String)params.get("endDate");
|
String appfullName=(String)params.get("appfullName");
|
|
|
if(StringUtils.isNotBlank(sidx)){
|
this.put("sidx", SQLFilter.sqlInject(sidx));
|
}
|
if(StringUtils.isNotBlank(order)){
|
this.put("order", SQLFilter.sqlInject(order));
|
}
|
if(StringUtils.isNotBlank(fkey)){
|
this.put("fkey", fkey);
|
}
|
if(StringUtils.isNotBlank(appid)){
|
this.put("appid", appid);
|
}
|
if(StringUtils.isNotBlank(UserName)){
|
this.put("UserName", UserName);
|
}
|
if(StringUtils.isNotBlank(cname)){
|
this.put("cname", cname);
|
}
|
if(StringUtils.isNotBlank(beginDate)){
|
this.put("beginDate", beginDate);
|
}
|
if(StringUtils.isNotBlank(endDate)){
|
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
|
try {
|
Date d=new Date(sdf.parse(endDate).getTime()+24*3600*1000);
|
endDate=sdf.format(d);
|
this.put("endDate", endDate);
|
} catch (ParseException e) {
|
e.printStackTrace();
|
}
|
|
}
|
if(StringUtils.isNotBlank(appfullName)){
|
this.put("appfullName", appfullName);
|
}
|
|
}
|
public int getPage() {
|
return page;
|
}
|
|
public void setPage(int page) {
|
this.page = page;
|
}
|
|
public int getLimit() {
|
return limit;
|
}
|
|
public void setLimit(int limit) {
|
this.limit = limit;
|
}
|
|
|
}
|