org.sagacity.quickvo.entity-lombok.ftl Maven / Gradle / Ivy
/**
*@Generated by sagacity-quickvo 5.0
*/
package ${quickVO.entityPackage};
import java.io.Serializable;
import org.sagacity.sqltoy.config.annotation.Entity;
<#if (quickVO.type=="TABLE")>
import org.sagacity.sqltoy.config.annotation.Id;
#if>
import org.sagacity.sqltoy.config.annotation.Column;
<#if (quickVO.indexModels?exists && quickVO.indexModels?size>0)>
import org.sagacity.sqltoy.config.annotation.Indexes;
import org.sagacity.sqltoy.config.annotation.Index;
#if>
<#if (quickVO.hasVoEntity==false)>
<#if (quickVO.apiDoc=="swagger-v2")>
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
#if>
<#if (quickVO.apiDoc=="swagger-v3")>
import io.swagger.v3.oas.annotations.media.Schema;
#if>
<#if (quickVO.apiDocImports?exists && quickVO.apiDocImports?size>0)>
<#list quickVO.apiDocImports as import>
import ${import};
#list>
#if>
#if>
<#if (quickVO.hasBusinessId==true)>
import org.sagacity.sqltoy.config.annotation.BusinessId;
#if>
<#if (quickVO.lombok)>
import lombok.Data;
<#if (quickVO.lombokChain)>
import lombok.experimental.Accessors;
#if>
#if>
<#if (quickVO.imports?exists && quickVO.imports?size>0)>
<#list quickVO.imports as import>
import ${import};
#list>
#if>
<#if (quickVO.exportTables?exists)>
import org.sagacity.sqltoy.config.annotation.OneToMany;
<#if (quickVO.hasListType==false)>
import java.util.List;
#if>
import java.util.ArrayList;
#if>
<#if (quickVO.entityExtends?exists)>
import ${quickVO.entityExtends};
#if>
/**
<#if (quickVO.projectName?exists)> * @project ${quickVO.projectName}#if>
<#if (quickVO.author?exists)> * @author ${quickVO.author}#if>
<#if (quickVO.version?exists)> * @version ${quickVO.version}#if>
*/
<#if (quickVO.hasVoEntity==false)>
<#if (quickVO.apiDoc=="swagger-v2")>
@ApiModel(value="${quickVO.entityName}"<#if (quickVO.tableRemark?exists && quickVO.tableRemark!='')>,description="${quickVO.tableRemark}"#if>)
#if>
<#if (quickVO.apiDoc=="swagger-v3")>
@Schema(name="${quickVO.entityName}"<#if (quickVO.tableRemark?exists && quickVO.tableRemark!='')>,description="${quickVO.tableRemark}"#if>)
#if>
<#if (quickVO.apiDocContent?exists)>
${quickVO.apiDocContent}
#if>
#if>
<#if (quickVO.lombok)>
@Data
<#if (quickVO.lombokChain)>
@Accessors(chain = true)
#if>
#if>
@Entity(tableName="${quickVO.tableName}",comment="${quickVO.tableRemark!""}"<#if (quickVO.pkConstraint?exists)>,pk_constraint="${quickVO.pkConstraint}"#if><#if (quickVO.schema?exists && quickVO.schema!='')>,schema="${quickVO.schema}"#if>)
<#if (quickVO.indexModels?exists && quickVO.indexModels?size>0)>
<#assign paramCnt=0/>
@Indexes(indexes={<#list quickVO.indexModels as indexModel><#if (paramCnt>0)>,#if>@Index(name="${indexModel.indexName}",columns={${indexModel.columnsAry}},sortTypes={${indexModel.sortTypesAry}}<#if (indexModel.isUnique)>,isUnique=true#if>)
<#assign paramCnt=paramCnt+1/>
#list>})
#if>
<#if (quickVO.entityExtends?exists)>
public class ${quickVO.entityName} extends ${quickVO.entityExtends?substring(quickVO.entityExtends?last_index_of(".")+1)} implements Serializable {
<#else>
public class ${quickVO.entityName} implements Serializable {
#if>
/**
*
*/
private static final long serialVersionUID = ${quickVO.entitySerialUID}L;
/*---begin-auto-generate-don't-update-this-area--*/
<#list quickVO.columns as column>
<#if (column.skipEntity==false)>
<#if (quickVO.hasVoEntity==false)>
<#if (quickVO.apiDoc=="swagger-v2")>
@ApiModelProperty(name="${column.colJavaName?uncap_first}",value="${column.colRemark!""}"<#if (column.nullable=='0')>,allowEmptyValue=false<#else>,allowEmptyValue=true#if>)
#if>
<#if (quickVO.apiDoc=="swagger-v3")>
@Schema(name="${column.colJavaName?uncap_first}",description="${column.colRemark!""}"<#if (column.nullable=='0')>,nullable=false<#else>,nullable=true#if>)
#if>
<#if (column.apiDocContent?exists)>
${column.apiDocContent}
#if>
#if>
<#if (column.pkFlag?exists && column.pkFlag=='1')>
@Id<#if (column.businessIdConfig?exists)><#else><#if (quickVO.singlePk=='1')>(strategy="${column.strategy}"<#if (column.sequence?exists && column.sequence!='')>,sequence="${column.sequence}"#if><#if (column.generator?exists && column.generator!='')>,generator="${column.generator}"#if>)#if>#if>
#if>
<#if (column.businessIdConfig?exists)>
<#assign businessId=column.businessIdConfig/>
@BusinessId(generator="${businessId.generator}"<#if (businessId.signature?exists)>,signature="${businessId.signature}"#if><#if (businessId.relatedColumns?exists)>,relatedColumns={<#list businessId.relatedColumns as relatedCol><#if (relatedCol_index>0)>,#if>"${relatedCol}"#list>}#if><#if (businessId.length?exists)>,length=${businessId.length}#if><#if (businessId.sequenceSize?exists)>,sequenceSize=${businessId.sequenceSize}#if>)
#if>
<#if (column.partitionKey==true)>
@PartitionKey
#if>
<#if (column.fkRefTableName?exists)>
@Foreign(table="${column.fkRefTableName}",field="${column.fkRefTableColName}",deleteRestict=${column.deleteRestict},updateRestict=${column.updateRestict}<#if (column.fkName?exists)>,constraintName="${column.fkName}"#if>)
#if>
@Column(name="${column.colName}",comment="${column.colRemark!""}"<#if (column.precision?exists)>,length=${column.precision?c}L#if><#if (column.scale?exists && column.scale>0)>,scale=${column.scale?c}#if><#if (column.defaultValue?exists)>,defaultValue="${column.defaultValue}"#if>,type=<#if (column.dataType?matches("\\d+"))==false>java.sql.Types.#if><#if (column.dataType?upper_case=='INT')>INTEGER<#else>${column.dataType?upper_case}#if>,nativeType="${column.colType!""}",nullable=<#if (column.nullable=='0')>false<#else>true#if><#if column.autoIncrement=='true'>,autoIncrement=true#if>)
private ${column.resultType} ${column.colJavaName?uncap_first};
#if>
#list>
<#if (quickVO.columnSize==0)>
// 未能获得表字段信息,请检查quickvo.xml 中dataSource的schema 和 catalog配置,可尝试先去除schema\catalog
// 内部原理: conn.getMetaData().getColumns(catalog, schema, tableName, null);
#if>
<#if (quickVO.exportTables?exists)>
<#list quickVO.exportTables as exportTable>
/**
* 主键关联子表信息
*/
@OneToMany(fields={${exportTable.pkColJavaName}},mappedFields={${exportTable.pkRefColJavaName}}<#if (exportTable.load?exists)>,load="${exportTable.load}"#if><#if (exportTable.updateSql?exists)>,update="${exportTable.updateSql}"#if><#if (exportTable.deleteRule==1)>,delete=true#if><#if (exportTable.orderBy?exists)>,orderBy="${exportTable.orderBy}"#if>)
private List<${exportTable.pkRefTableJavaName?cap_first}> ${exportTable.pkRefTableJavaName?uncap_first}<#if exportTable.pkRefTableJavaName?ends_with("s")>e#if>s=new ArrayList<${exportTable.pkRefTableJavaName?cap_first}>();
#list>
#if>
<#if (quickVO.type=='TABLE')>
/** default constructor */
public ${quickVO.entityName}() {
}
<#if (quickVO.singlePk=='1'||quickVO.singlePk=='0')>
<#assign paramCnt="0"/>
/** pk constructor */
public ${quickVO.entityName}(<#list quickVO.columns as column><#if (column.pkFlag=='1')><#if (paramCnt=='1')>,#if><#assign paramCnt='1'/>${column.resultType} ${column.colJavaName?uncap_first}#if>#list>)
{
<#list quickVO.columns as column>
<#if (column.pkFlag=='1')>
this.${column.colJavaName?uncap_first}=${column.colJavaName?uncap_first};
#if>
#list>
}
#if>
#if>
/*---end-auto-generate-don't-update-this-area--*/
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy