MybatisPlus生成模板,修改,set get方法的影响,
手动去掉getset方法加上Lombok注解
@Size读取text类型为-1的长度bug,
去掉id不能为空@NotNull的校验
(增加@lombok注解,@TableField注解自动填充,配合另外一篇mybatis配置使用)
package ${domain.packageName};
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
<#list tableClass.importList as fieldType>${"\n"}import ${fieldType};</#list>
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Length;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
/**
* ${tableClass.remark!}
* @TableName ${tableClass.tableName}
*/
@Data
@TableName("${tableClass.tableName}")
public class ${tableClass.shortClassName} implements Serializable {
<#list tableClass.allFields as field>
/**
* ${field.remark!}
*/<#if !field.nullable || field.jdbcType=="VARCHAR">${"\n "}</#if><#if !field.nullable><#if field.jdbcType=="VARCHAR">@NotBlank(message="[${field.remark!}]不能为空")<#elseif field.fieldName="id"><#else>@NotNull(message="[${field.remark!}]不能为空")</#if></#if><#if field.jdbcType=="VARCHAR" && field.columnLength!=-1><#if !field.nullable>${"\n "}</#if>@Size(max= ${field.columnLength?c},message="编码长度不能超过${field.columnLength?c}")</#if>
@ApiModelProperty("${field.remark!}")<#if field.jdbcType=="VARCHAR" && field.columnLength!=-1>${"\n "}@Length(max= ${field.columnLength},message="编码长度不能超过${field.columnLength}")</#if><#if field.fieldName="createTime" || field.fieldName="createBy">${"\n "}@TableField(fill = FieldFill.INSERT)</#if><#if field.fieldName="updateTime" || field.fieldName="updateBy">${"\n "}@TableField(fill = FieldFill.UPDATE)</#if><#if field.fieldName="deleted" || field.fieldName="delFlag">${"\n "}@TableLogic</#if>
private ${field.shortTypeName} ${field.fieldName};
</#list>
<#--<#list tableClass.allFields as field>-->
<#-- /**-->
<#-- * ${field.remark!}-->
<#-- */-->
<#-- private void set${field.fieldName?cap_first}(${field.shortTypeName} ${field.fieldName}){-->
<#-- this.${field.fieldName} = ${field.fieldName};-->
<#-- }-->
<#--</#list>-->
<#--<#list tableClass.allFields as field>-->
<#-- /**-->
<#-- * ${field.remark!}-->
<#-- */-->
<#-- private ${field.shortTypeName} get${field.fieldName?cap_first}(){-->
<#-- return this.${field.fieldName};-->
<#-- }-->
<#--</#list>-->
}