2025-04-23 11:03:01 +08:00
|
|
|
##导入宏定义
|
|
|
|
$!{define.vm}
|
|
|
|
$!{mybatisCodehelper.vm}
|
|
|
|
|
|
|
|
#set($entitySavePath = $tool.append(${javamodelSrcFolder},"/",${modelPackageName.replace(".","/")}))
|
|
|
|
|
|
|
|
$!callback.setSavePath($entitySavePath)
|
|
|
|
$!callback.setFileName($tool.append($tableInfo.name, ".java"))
|
|
|
|
|
|
|
|
##自动导入包(全局变量)
|
|
|
|
package ${modelPackageName};
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
|
|
import com.baomidou.mybatisplus.annotation.TableField;
|
|
|
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
|
|
import com.baomidou.mybatisplus.annotation.Version;
|
|
|
|
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
|
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
|
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
|
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
|
import org.locationtech.jts.geom.Geometry;
|
|
|
|
import ltd.llvy.postgis.handler.GeometryDeserializer;
|
|
|
|
import ltd.llvy.postgis.handler.GeometrySerializer;
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
$!autoImport
|
|
|
|
import java.time.OffsetDateTime;
|
|
|
|
|
|
|
|
import org.apache.ibatis.type.JdbcType;
|
|
|
|
|
|
|
|
import lombok.Data;
|
|
|
|
import lombok.EqualsAndHashCode;
|
|
|
|
|
|
|
|
##表注释(宏定义)
|
|
|
|
#tableComment("表实体类.")
|
|
|
|
#if(${tableInfo.comment})
|
|
|
|
@Schema(description = "${tableInfo.comment}")
|
|
|
|
#end
|
|
|
|
@EqualsAndHashCode(callSuper = true)
|
|
|
|
@Data
|
|
|
|
public class $!{tableInfo.name} extends Model<$!{tableInfo.name}> {
|
|
|
|
#foreach($column in $tableInfo.fullColumn)
|
|
|
|
#if(${column.comment})
|
|
|
|
//${column.comment}
|
|
|
|
#end
|
|
|
|
#if($!{column.name} == "id" || $!{column.name.indexOf("Id")} != -1)
|
|
|
|
@Schema(description = "${column.comment}", type = "string")
|
|
|
|
@JsonSerialize(using = ToStringSerializer.class)
|
|
|
|
#else
|
|
|
|
@Schema(description = "${column.comment}")
|
|
|
|
#end
|
|
|
|
#if("password" == $!{column.name})
|
|
|
|
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
|
|
|
#end
|
|
|
|
#if("version" == $!{column.name})
|
|
|
|
@Version
|
|
|
|
#end
|
|
|
|
#if("deleteTime" == $!{column.name})
|
|
|
|
@TableLogic
|
|
|
|
#end
|
|
|
|
#if("createTime" == $!{column.name})
|
|
|
|
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
|
|
|
{% if cookiecutter.platform == "postgis" -%}
|
2025-06-05 15:42:41 +08:00
|
|
|
@TableField(fill = FieldFill.INSERT, jdbcType = JdbcType.OTHER)
|
2025-04-23 11:03:01 +08:00
|
|
|
{% else %}
|
2025-06-05 15:42:41 +08:00
|
|
|
@TableField(fill = FieldFill.INSERT, jdbcType = JdbcType.DATETIMEOFFSET)
|
2025-04-23 11:03:01 +08:00
|
|
|
{% endif %}
|
|
|
|
#end
|
|
|
|
#if("updateTime" == $!{column.name})
|
|
|
|
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
|
|
|
{% if cookiecutter.platform == "postgis" -%}
|
|
|
|
@TableField(fill = FieldFill.INSERT_UPDATE, jdbcType = JdbcType.OTHER)
|
|
|
|
{% else %}
|
|
|
|
@TableField(fill = FieldFill.INSERT_UPDATE, jdbcType = JdbcType.DATETIMEOFFSET)
|
|
|
|
{% endif %}
|
|
|
|
#end
|
|
|
|
#if("createBy" == $!{column.name})
|
|
|
|
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
|
|
|
@TableField(fill = FieldFill.INSERT)
|
|
|
|
#end
|
|
|
|
#if("updateBy" == $!{column.name})
|
|
|
|
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
|
|
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
|
|
#end
|
|
|
|
#if("geom" == $!{column.name})
|
|
|
|
@JsonSerialize(using = GeometrySerializer.class)
|
|
|
|
@JsonDeserialize(using = GeometryDeserializer.class)
|
|
|
|
#end
|
|
|
|
private $!{tool.getClsNameByFullName($column.type)} $!{column.name};
|
|
|
|
#end
|
|
|
|
#foreach($column in $tableInfo.pkColumn)
|
|
|
|
/**
|
|
|
|
* 获取主键值.
|
|
|
|
*
|
|
|
|
* @return 主键值
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public Serializable pkVal () {
|
|
|
|
return this.$!column.name;
|
|
|
|
}
|
|
|
|
#break
|
|
|
|
#end
|
|
|
|
}
|