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

template.query.vm Maven / Gradle / Ivy

Go to download

自动生成增删改查代码插件,通过Maven插件配置,一键生成单表的所有CRUD操作

There is a newer version: 3.0.4
Show newest version
package ${package.QueryBo};

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import ${package.Entity}.${entity};
#if(${table.hasDate})
import java.util.Date;
#end
##添加了List功能
import java.util.List;

##BigDecimal导入
#foreach($field in ${table.fields})
	#if(${field.propertyType.equals('BigDecimal')})
	import java.math.BigDecimal;
		#break
	#end
#end


/**
 * 

* ${table.comment} * 查询条件类 *

* * @author ${author} * @since ${date} */ public class ${table.queryName}{ private QueryBoExt queryBoExt; #foreach($field in ${table.fields}) /** * ${field.comment} */ private ${field.propertyType} ${field.propertyName}; #end /** * 构建查询 * @return */ public QueryWrapper<${entity}> buildQuery() { QueryWrapper<${entity}> query = new QueryWrapper<>(); #foreach($field in ${table.fields}) if(${field.propertyName}!=null){ query.eq(${entity}.${field.nameUp},${field.propertyName}); } #end if(queryBoExt!=null){ //设置排序 if(queryBoExt.getOrderColumn()!=null && queryBoExt.getOrderColumn().trim().length()>0 ){ if(queryBoExt.isAsc()){ query.orderByAsc(queryBoExt.getOrderColumn()); }else{ query.orderByDesc(queryBoExt.getOrderColumn()); } } //批量的查询条件进行查询 #foreach($field in ${table.fields}) if(queryBoExt.get${field.capitalName}List()!=null && queryBoExt.get${field.capitalName}List().size()>0){ query.in(${entity}.${field.nameUp},queryBoExt.get${field.capitalName}List()); } #end } return query; } #foreach($field in ${table.fields}) #if(${field.propertyType.equals("Boolean")}) #set($getprefix="is") #else #set($getprefix="get") #end public ${field.propertyType} ${getprefix}${field.capitalName}() { return ${field.propertyName}; } public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) { this.${field.propertyName} = ${field.propertyName}; } #end public QueryBoExt getQueryBoExt() { return queryBoExt; } public void setQueryBoExt(QueryBoExt queryBoExt) { this.queryBoExt = queryBoExt; } /** * 用于排序,和批量的查询 */ public static class QueryBoExt { /** * 一般情况下只需要单个列的排序 */ private String orderColumn; /** * 默认正序 */ private boolean asc = true; #foreach($field in ${table.fields}) /** * ${field.comment} * 集合 */ private List<${field.propertyType}> ${field.propertyName}List; #end #foreach($field in ${table.fields}) public List<${field.propertyType}> get${field.capitalName}List() { return ${field.propertyName}List; } public void set${field.capitalName}List(List<${field.propertyType}> ${field.propertyName}List) { this.${field.propertyName}List = ${field.propertyName}List; } #end public String getOrderColumn() { return orderColumn; } public void setOrderColumn(String orderColumn) { this.orderColumn = orderColumn; } public boolean isAsc() { return asc; } public void setAsc(boolean asc) { this.asc = asc; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy