All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.sm.criteria.tpl Maven / Gradle / Ivy

package ${pkgName}.criteria;

import ${easyCriteriaImport};
import ${stringUtilsImport};

<#if Imports??>
<#list Imports as item>
import ${item};



/**
 * ${ClassName} Criteria, generated by EasyAuto
 * @author easyproject.cn
 * @version 1.0
 *
 */
public class ${ClassName}Criteria extends EasyCriteria implements java.io.Serializable {
	// Fields
	private static final long serialVersionUID = 1L;
	/*
 	 * 1. Criteria property
 	 */
 	<#if Propertys??>
	<#list Propertys as item>
	<#assign info=item?split("#")>
	private ${info[0]} ${info[1]};
	
	
	/*
 	 * 2. Constructor
 	 */
	 public ${ClassName}Criteria() {
		super();
	}



	/*
 	 * 3. 条件生成抽象方法实现
 	 */
	@Override
	public String getCondition() {
		values.clear(); //清除条件数据
		StringBuffer condition = new StringBuffer();
		
		// Your conditions
		
		/*
		if (StringUtils.isNotNullAndEmpty(this.getName())) {
			condition.append(" and name like ${r"#{"}name}");
			values.put("name", "%" + this.getName() + "%");
		}
		*/
		
		<#if Propertys??>
		<#list Propertys as item>
		<#assign info=item?split("#")>
		<#if info[3]=="like">
		if(StringUtils.isNotNullAndEmpty(this.get${info[1]?cap_first}())){
			condition.append(" and ${info[2]} like ${r"#{"}${info[1]}}");
			values.put("${info[1]}", "%"+this.get${info[1]?cap_first}()+"%");
		}
		<#else>
		if(StringUtils.isNotNullAndEmpty(this.get${info[1]?cap_first}())){
			condition.append(" and ${info[2]}=${r"#{"}${info[1]}}");
			values.put("${info[1]}", this.get${info[1]?cap_first}());
		}
		
		
		
		
		return condition.toString();
	}
	
	 /*
 	 * 4. Setters & Getters...
 	 */ 
	<#if Propertys??>
	<#list Propertys as item>
	<#assign info=item?split("#")>
  	public ${info[0]} get${info[1]?cap_first}() {
		return ${info[1]};
	}
	public void set${info[1]?cap_first}(${info[0]} ${info[1]}) {
		this.${info[1]} = ${info[1]};
	}
	
	
	


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy