通用优化

This commit is contained in:
zhujunjieit 2018-12-07 23:00:42 +08:00
parent 0e4943de0e
commit a0346043f6
1 changed files with 34 additions and 29 deletions

View File

@ -4,11 +4,11 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.base.BaseEntity; import com.ruoyi.common.base.BaseEntity;
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.attrType == 'Date') #if($column.attrType == 'Date')
import javax.persistence.Id; import javax.persistence.Id;
import java.util.Date; import java.util.Date;
#break #break
#end #end
#end #end
/** /**
@ -19,14 +19,19 @@ import java.util.Date;
*/ */
public class ${className} public class ${className}
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
#foreach ($column in $columns) #foreach ($column in $columns)
/** $column.columnComment */ /** $column.columnComment */
#if($column.columnName == $primaryKey.columnName)
@Id
private $column.attrType $column.attrname; private $column.attrType $column.attrname;
#else
private $column.attrType $column.attrname;
#end
#end #end
#foreach ($column in $columns) #foreach ($column in $columns)
/** 设置$column.columnComment */ /** 设置$column.columnComment */
public void set${column.attrName}($column.attrType $column.attrname) public void set${column.attrName}($column.attrType $column.attrname)
{ {
@ -38,13 +43,13 @@ public class ${className}
{ {
return $column.attrname; return $column.attrname;
} }
#end #end
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
#foreach ($column in $columns) #foreach ($column in $columns)
.append("${column.attrname}", get${column.attrName}()) .append("${column.attrname}", get${column.attrName}())
#end #end
.toString(); .toString();
} }
} }