BladeX/blade-ops/blade-develop/target/classes/templates/entity.java.vm

162 lines
4.1 KiB
Plaintext
Raw Normal View History

2019-01-30 17:06:23 +08:00
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package $!{package.Entity};
#foreach($pkg in $!{table.importPackages})
import $!{pkg};
#end
#if($!{entityLombokModel})
import lombok.Data;
import lombok.EqualsAndHashCode;
#end
#if($!{swagger2})
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
#end
/**
* $!{table.comment}实体类
*
* @author $!{author}
* @since $!{date}
*/
#if($!{entityLombokModel})
@Data
#end
#if($!{table.convert})
@TableName("$!{table.name}")
#end
#if($!{superEntityClass})
@EqualsAndHashCode(callSuper = true)
#end
#if($!{swagger2})
@ApiModel(value = "$!{entity}对象", description = #if ("$!{table.comment}"=="")"$!{entity}对象"#else"$!{table.comment}"#end)
#end
#if($!{superEntityClass})
public class $!{entity} extends $!{superEntityClass}#if($!{activeRecord})<$!{entity}>#end {
#elseif($!{activeRecord})
@Accessors(chain = true)
public class $!{entity} extends Model<$!{entity}> {
#else
public class $!{entity} implements Serializable {
#end
private static final long serialVersionUID = 1L;
## ---------- BEGIN 字段循环遍历 ----------
#foreach($field in $!{table.fields})
#if($!{field.keyFlag})
#set($keyPropertyName=$!{field.propertyName})
#end
#if("$!field.comment" != "")
/**
* $!{field.comment}
*/
#if($!{swagger2})
@ApiModelProperty(value = "$!{field.comment}")
#end
#end
#if($!{field.keyFlag})
## 主键
#if($!{field.keyIdentityFlag})
@TableId(value = "$!{field.name}", type = IdType.AUTO)
#elseif(!$null.isNull($!{idType}) && "$!idType" != "")
@TableId(value = "$!{field.name}", type = IdType.$!{idType})
#elseif($!{field.convert})
@TableId("$!{field.name}")
#end
## 普通字段
#elseif($!{field.fill})
## ----- 存在字段填充设置 -----
#if($!{field.convert})
@TableField(value = "$!{field.name}", fill = FieldFill.$!{field.fill})
#else
@TableField(fill = FieldFill.$!{field.fill})
#end
#elseif($!{field.convert})
@TableField("$!{field.name}")
#end
## 乐观锁注解
#if($!{versionFieldName}==$!{field.name})
@Version
#end
## 逻辑删除注解
#if($!{logicDeleteFieldName}==$!{field.name})
@TableLogic
#end
private $!{field.propertyType} $!{field.propertyName};
#end
## ---------- END 字段循环遍历 ----------
#if(!$!{entityLombokModel})
#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};
}
#if($!{entityBuilderModel})
public $!{entity} set$!{field.capitalName}($!{field.propertyType} $!{field.propertyName}) {
#else
public void set$!{field.capitalName}($!{field.propertyType} $!{field.propertyName}) {
#end
this.$!{field.propertyName} = $!{field.propertyName};
#if($!{entityBuilderModel})
return this;
#end
}
#end
#end
#if($!{entityColumnConstant})
#foreach($field in $!{table.fields})
public static final String $!{field.name.toUpperCase()} = "$!{field.name}";
#end
#end
#if($!{activeRecord})
@Override
protected Serializable pkVal() {
#if($!{keyPropertyName})
return this.$!{keyPropertyName};
#else
return this.id;
#end
}
#end
#if(!$!{entityLombokModel})
@Override
public String toString() {
return "$!{entity}{" +
#foreach($field in $!{table.fields})
#if($!{velocityCount}==1)
"$!{field.propertyName}=" + $!{field.propertyName} +
#else
", $!{field.propertyName}=" + $!{field.propertyName} +
#end
#end
"}";
}
#end
}