cn.easyproject.easymybatis.pagination.EasyCriteria Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of easymybatis-pagination Show documentation
Show all versions of easymybatis-pagination Show documentation
EasyMyBatis Pagination is a generic paging plugin for the MyBaits framework. Provides the PageBean automatic paging data encapsulation, the EasyCriteria paging condition object, and the automated paging SQL that supports common databases.
package cn.easyproject.easymybatis.pagination;
import java.util.HashMap;
import java.util.Map;
/**
* 按条件查询抽象父类(可以结合分页PageBean使用)
*
* SysUserCriteria Demo:
*
*
* public class SysUserCriteria extends EasyCriteria implements java.io.Serializable {
* // 1. Criteria field
* private String name;
* private String realName;
* private Integer status; // 0 is ON; 1 is OFF; 2 is REMOVED
*
* // 2. Constructor
* public SysUserCriteria() {
* }
*
* public SysUserCriteria(String name, String realName, Integer status) {
* super();
* this.name = name;
* this.realName = realName;
* this.status = status;
* }
*
* // 3. Condition genertator abstract method implements
* public String getCondition() {
* values.clear(); // **Must clear old values**
* StringBuffer condition = new StringBuffer();
* if (StringUtils.isNotNullAndEmpty(this.getName())) {
* condition.append(" and name like #{name}");
* values.put("name", "%" + this.getName() + "%");
* }
* if (StringUtils.isNotNullAndEmpty(this.getRealName())) {
* condition.append(" and realName like #{realName}");
* values.put("realName", "%" + this.getRealName() + "%");
* }
* if (StringUtils.isNotNullAndEmpty(this.getStatus())) {
* condition.append(" and status=#{status}");
* values.put("status" ,this.getStatus());
* }
* return condition.toString();
* }
*
* // 4. Setters&Getters...
*
* }
*
*
* @author Ray
* @author [email protected]
* @author easyproject.cn
* @since 1.0.0
* @see https://github.com/ushelp/EasyMyBatisPagination
*
*/
public abstract class EasyCriteria {
protected Map values = new HashMap();
public abstract String getCondition();
public Map getValues() {
return values;
}
public void setValues(Map values) {
this.values = values;
}
}