crud.entitySelectDTO.vm Maven / Gradle / Ivy
The newest version!
package ${basePackage}.${DTOPackage};
#foreach($pkg in ${table.importPackages})
import ${pkg};
#end
#foreach($field in ${table.fields})
#if(${field.propertyType}=="String")
import ${javaApiPackage}.validation.constraints.Size;
#break
#end
#end
#if(${springdoc})
import io.swagger.v3.oas.annotations.media.Schema;
#elseif(${swagger})
##import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
#end
#if(${entityLombokModel})
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.Data;
#if(${chainModel})
import lombok.experimental.Accessors;
#end
#end
import java.util.List;
#if(!$table.importPackages.contains("java.io.Serializable"))
import java.io.Serializable;
#end
/**
* $!{table.comment}查询DTO
*
* @author ${author}
* @since ${date}
*/
#if(${entityLombokModel})
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
#if(${chainModel})
@Accessors(chain = true)
#end
#end
###if(${springdoc})
##@Schema(name = "${entity}SelectDTO", description = "$!{table.comment}查询DTO")
###elseif(${swagger})
##@ApiModel(value = "${entity}SelectDTO对象", description = "$!{table.comment}查询DTO")
###end
public class ${entity}SelectDTO {
###if(${entitySerialVersionUID})
##
## private static final long serialVersionUID = 1L;
##
###end
#if(${springdoc})
@Schema(description = "主键id")
#elseif(${swagger})
@ApiModelProperty("主键id")
#else
/**
* 主键id
*/
#end
private Serializable primaryKey;
##
## ---------- BEGIN 字段循环遍历 ----------
#foreach($field in ${table.fields})
#if($selectExcludeFields.contains(${field.propertyName}))
#elseif(${field.logicDeleteField})
#else
#if("$!field.comment" != "")
#if(${springdoc})
@Schema(description = "${field.comment}")
#elseif(${swagger})
@ApiModelProperty("${field.comment}")
#else
/**
* ${field.comment}
*/
#end
#end
#if(${field.propertyType} == "String")
@Size(message = "${field.comment}长度不能超过${field.metaInfo.length}", max = ${field.metaInfo.length})
#end
private ${field.propertyType} ${field.propertyName};
#if(${field.keyFlag})
#if(${springdoc})
@Schema(description = "${field.comment}批量查询")
#elseif(${swagger})
@ApiModelProperty("${field.comment}批量查询")
#else
/**
* ${field.comment}批量查询
*/
#end
private List<${field.propertyType}> ${field.propertyName}List;
## String类型追加模糊查询
#elseif(${field.propertyType} == "String")
#if(${springdoc})
@Schema(description = "${field.comment}模糊查询")
#elseif(${swagger})
@ApiModelProperty("${field.comment}模糊查询")
#else
/**
* ${field.comment}模糊查询
*/
#end
@Size(message = "${field.comment}长度不能超过${field.metaInfo.length}", max = ${field.metaInfo.length})
private ${field.propertyType} ${field.propertyName}Like;
## 时间类型追加时间段查询
#elseif($jdbcTimeTypes.contains(${field.metaInfo.jdbcType}))
#if(${springdoc})
@Schema(description = "${field.comment}时间段查询(开始)")
#elseif(${swagger})
@ApiModelProperty("${field.comment}时间段查询(开始)")
#else
/**
* ${field.comment}时间段查询(开始)
*/
#end
private ${field.propertyType} ${field.propertyName}Start;
#if(${springdoc})
@Schema(description = "${field.comment}时间段查询(结束)")
#elseif(${swagger})
@ApiModelProperty("${field.comment}时间段查询(结束)")
#else
/**
* ${field.comment}时间段查询(结束)
*/
#end
private ${field.propertyType} ${field.propertyName}End;
## 追加in查询
#elseif(${field.propertyType} == "Integer" || ${field.propertyType} == "Long")
#if(${springdoc})
@Schema(description = "${field.comment}批量查询")
#elseif(${swagger})
@ApiModelProperty("${field.comment}批量查询")
#else
/**
* ${field.comment}批量查询
*/
#end
private List<${field.propertyType}> ${field.propertyName}List;
#end
#end
#end
## ---------- END 字段循环遍历 ----------
#if(!${entityLombokModel})
#if(${chainModel})
public Serializable getPrimaryKey() {
return this.primaryKey;
}
public ${entity}SelectDto setPrimaryKey(Serializable primaryKey) {
this.primaryKey = primaryKey;
return this;
}
#else
public Serializable getPrimaryKey() {
return this.primaryKey;
}
public void setPrimaryKey(Serializable primaryKey) {
this.primaryKey = primaryKey;
}
#end
#foreach($field in ${table.fields})
#if($selectExcludeFields.contains(${field.propertyName}))
#elseif(${field.logicDeleteField})
#else
#if(${field.propertyType.equals("boolean")})
#set($getprefix="is")
#else
#set($getprefix="get")
#end
public ${field.propertyType} ${getprefix}${field.capitalName}() {
return ${field.propertyName};
}
#if(${chainModel})
public ${entity}SelectDTO set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
#else
public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
#end
this.${field.propertyName} = ${field.propertyName};
#if(${chainModel})
return this;
#end
}
#if(${field.keyFlag})
## 主键批量查询getter and setter
public List<${field.propertyType}> ${getprefix}${field.capitalName}List() {
return ${field.propertyName}List;
}
#if(${chainModel})
public ${entity}SelectDTO set${field.capitalName}List(List<${field.propertyType}> ${field.propertyName}) {
#else
public void set${field.capitalName}List(List<${field.propertyType}> ${field.propertyName}) {
#end
this.${field.propertyName}List = ${field.propertyName};
#if(${chainModel})
return this;
#end
}
#elseif(${field.propertyType} == "String")
## 模糊字段getter and setter
public ${field.propertyType} ${getprefix}${field.capitalName}Like() {
return ${field.propertyName}Like;
}
#if(${chainModel})
public ${entity}SelectDTO set${field.capitalName}Like(${field.propertyType} ${field.propertyName}) {
#else
public void set${field.capitalName}Like(${field.propertyType} ${field.propertyName}) {
#end
this.${field.propertyName}Like = ${field.propertyName};
#if(${chainModel})
return this;
#end
}
#elseif($jdbcTimeTypes.contains(${field.metaInfo.jdbcType}))
## 日期开始getter and setter
public ${field.propertyType} ${getprefix}${field.capitalName}Start() {
return ${field.propertyName}Start;
}
#if(${chainModel})
public ${entity}SelectDTO set${field.capitalName}Start(${field.propertyType} ${field.propertyName}) {
#else
public void set${field.capitalName}Start(${field.propertyType} ${field.propertyName}) {
#end
this.${field.propertyName}Start = ${field.propertyName};
#if(${chainModel})
return this;
#end
}
## 日期结束getter and setter
public ${field.propertyType} ${getprefix}${field.capitalName}End() {
return ${field.propertyName}End;
}
#if(${chainModel})
public ${entity}SelectDTO set${field.capitalName}End(${field.propertyType} ${field.propertyName}) {
#else
public void set${field.capitalName}End(${field.propertyType} ${field.propertyName}) {
#end
this.${field.propertyName}End = ${field.propertyName};
#if(${chainModel})
return this;
#end
}
#elseif(${field.propertyType} == "Integer" || ${field.propertyType} == "Long")
## in批量查询getter and setter
public List<${field.propertyType}> ${getprefix}${field.capitalName}List() {
return ${field.propertyName}List;
}
#if(${chainModel})
public ${entity}SelectDTO set${field.capitalName}List(List<${field.propertyType}> ${field.propertyName}) {
#else
public void set${field.capitalName}List(List<${field.propertyType}> ${field.propertyName}) {
#end
this.${field.propertyName}List = ${field.propertyName};
#if(${chainModel})
return this;
#end
}
#end
#end
#end
## --foreach end---
#end
## --end of #if(!${entityLombokModel})--
#if(${entityColumnConstant})
#foreach($field in ${table.fields})
#if($selectExcludeFields.contains(${field.propertyName}))
#elseif(${field.logicDeleteField})
#else
public static final String ${field.name.toUpperCase()} = "${field.name}";
#end
#end
#end
#if(!${entityLombokModel})
@Override
public String toString() {
return "${entity}{" +
#foreach($field in ${table.fields})
#if($selectExcludeFields.contains(${field.propertyName}))
#elseif(${field.logicDeleteField})
#else
#if($!{foreach.index}==0)
"${field.propertyName} = " + ${field.propertyName} +
#else
", ${field.propertyName} = " + ${field.propertyName} +
#end
#end
#end
"}";
}
#end
}