All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sagacity.quickvo.entity-lombok.ftl Maven / Gradle / Ivy

The newest version!
/**
 *@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;

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 (quickVO.hasVoEntity==false)>
<#if (quickVO.apiDoc=="swagger-v2")>
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

<#if (quickVO.apiDoc=="swagger-v3")>
import io.swagger.v3.oas.annotations.media.Schema;

<#if (quickVO.apiDocImports?exists && quickVO.apiDocImports?size>0)>
<#list quickVO.apiDocImports as import>
import ${import};



<#if (quickVO.hasBusinessId==true)>
import org.sagacity.sqltoy.config.annotation.BusinessId;

<#if (quickVO.lombok)>
import lombok.Data;
<#if (quickVO.lombokChain)>
import lombok.experimental.Accessors;


<#if (quickVO.imports?exists && quickVO.imports?size>0)>
<#list quickVO.imports as import>
import ${import};


<#if (quickVO.exportTables?exists)>
import org.sagacity.sqltoy.config.annotation.OneToMany;
<#if (quickVO.hasListType==false)>
import java.util.List;

import java.util.ArrayList;

<#if (quickVO.entityExtends?exists)>
import ${quickVO.entityExtends};


/**
<#if (quickVO.projectName?exists)> * @project ${quickVO.projectName}
<#if (quickVO.author?exists)> * @author ${quickVO.author}
<#if (quickVO.version?exists)> * @version ${quickVO.version} 
 */
<#if (quickVO.hasVoEntity==false)>
<#if (quickVO.apiDoc=="swagger-v2")>
@ApiModel(value="${quickVO.entityName}"<#if (quickVO.tableRemark?exists && quickVO.tableRemark!='')>,description="${quickVO.tableRemark}")

<#if (quickVO.apiDoc=="swagger-v3")>
@Schema(name="${quickVO.entityName}"<#if (quickVO.tableRemark?exists && quickVO.tableRemark!='')>,description="${quickVO.tableRemark}")

<#if (quickVO.apiDocContent?exists)>
${quickVO.apiDocContent}


<#if (quickVO.lombok)>
@Data
<#if (quickVO.lombokChain)>
@Accessors(chain = true)


@Entity(tableName="${quickVO.tableName}",comment="${quickVO.tableRemark!""}"<#if (quickVO.pkConstraint?exists)>,pk_constraint="${quickVO.pkConstraint}"<#if (quickVO.schema?exists && quickVO.schema!='')>,schema="${quickVO.schema}")
<#if (quickVO.indexModels?exists && quickVO.indexModels?size>0)>
<#assign paramCnt=0/>
@Indexes(indexes={<#list quickVO.indexModels as indexModel><#if (paramCnt>0)>,@Index(name="${indexModel.indexName}",columns={${indexModel.columnsAry}},sortTypes={${indexModel.sortTypesAry}}<#if (indexModel.isUnique)>,isUnique=true)
<#assign paramCnt=paramCnt+1/>
})

<#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 {

	
	/**
	 * 
	 */
	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 (quickVO.apiDoc=="swagger-v3")>
	@Schema(name="${column.colJavaName?uncap_first}",description="${column.colRemark!""}"<#if (column.nullable=='0')>,nullable=false<#else>,nullable=true)
	
	<#if (column.apiDocContent?exists)>
	${column.apiDocContent}
	
	
	<#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 (column.generator?exists && column.generator!='')>,generator="${column.generator}")
	
	<#if (column.businessIdConfig?exists)>
	<#assign businessId=column.businessIdConfig/>
	@BusinessId(generator="${businessId.generator}"<#if (businessId.signature?exists)>,signature="${businessId.signature}"<#if (businessId.relatedColumns?exists)>,relatedColumns={<#list businessId.relatedColumns as relatedCol><#if (relatedCol_index>0)>,"${relatedCol}"}<#if (businessId.length?exists)>,length=${businessId.length}<#if (businessId.sequenceSize?exists)>,sequenceSize=${businessId.sequenceSize})
	
	<#if (column.partitionKey==true)>
	@PartitionKey
	
	<#if (column.fkRefTableName?exists)>
	@Foreign(table="${column.fkRefTableName}",field="${column.fkRefTableColName}",deleteRestict=${column.deleteRestict},updateRestict=${column.updateRestict}<#if (column.fkName?exists)>,constraintName="${column.fkName}")
	
	@Column(name="${column.colName}",comment="${column.colRemark!""}"<#if (column.precision?exists)>,length=${column.precision?c}L<#if (column.scale?exists && column.scale>0)>,scale=${column.scale?c}<#if (column.defaultValue?exists)>,defaultValue="${column.defaultValue}",type=<#if (column.dataType?matches("\\d+"))==false>java.sql.Types.<#if (column.dataType?upper_case=='INT')>INTEGER<#else>${column.dataType?upper_case},nativeType="${column.colType!""}",nullable=<#if (column.nullable=='0')>false<#else>true<#if column.autoIncrement=='true'>,autoIncrement=true)
	private ${column.resultType} ${column.colJavaName?uncap_first};


<#if (quickVO.columnSize==0)>
   // 未能获得表字段信息,请检查quickvo.xml 中dataSource的schema 和 catalog配置,可尝试先去除schema\catalog
   // 内部原理: conn.getMetaData().getColumns(catalog, schema, tableName, null);

<#if (quickVO.exportTables?exists)>
<#list quickVO.exportTables as exportTable>
	/**
	 * 主键关联子表信息
	 */
	@OneToMany(fields={${exportTable.pkColJavaName}},mappedFields={${exportTable.pkRefColJavaName}}<#if (exportTable.load?exists)>,load="${exportTable.load}"<#if (exportTable.updateSql?exists)>,update="${exportTable.updateSql}"<#if (exportTable.deleteRule==1)>,delete=true<#if (exportTable.orderBy?exists)>,orderBy="${exportTable.orderBy}")
	private List<${exportTable.pkRefTableJavaName?cap_first}> ${exportTable.pkRefTableJavaName?uncap_first}<#if exportTable.pkRefTableJavaName?ends_with("s")>es=new ArrayList<${exportTable.pkRefTableJavaName?cap_first}>();



<#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')>,<#assign paramCnt='1'/>${column.resultType} ${column.colJavaName?uncap_first})
	{
		<#list quickVO.columns as column>
		<#if (column.pkFlag=='1')>
		this.${column.colJavaName?uncap_first}=${column.colJavaName?uncap_first};
		
		
	}


/*---end-auto-generate-don't-update-this-area--*/
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy