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

com.kasinf.framework.rest.eneity.BaseEntity Maven / Gradle / Ivy

The newest version!
package com.kasinf.framework.rest.eneity;


import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
import java.util.Date;

/**
 * @param  主键类型
 * @author lkhsh
 * 通用Entity抽象类,提供了常用的4大字段。
 * 提供了2种常用的类型转换器。
 * 1、@Type(value="json")加在实体属性上,将json对象转换成字符串后存储到数据库。默认类型为 Map<String, String>
 * 1.1 @Parameter(name="type",value="全类名")
 * 1.2 @Parameter(name="valueType", value="值的全类名")
 * 1.3 @Parameter(name="keyType", value="键的全类名")
 * 2、@Type(value="collection")加在Collection类型上,将集合转换成字符串后存到数据库,参数有
 * 2.1 @Parameter(name="separator",value=",") 分隔符
 * 2.2 @Parameter(name="collectionType",value="java.util.ArrayList") 集合类型
 * 2.3 @Parameter(name="elementType",value="java.lang.String") 值的类型
 */
@Getter
@Setter
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
public abstract class BaseEntity implements AbstractEntity {

    @CreatedDate
    @Column(updatable = false)
    @JsonFormat
    private Date createTime;

    @LastModifiedDate
    @JsonFormat
    private Date modifyTime;

    @CreatedBy
    @Column(updatable = false, length = 50)
    private String creator;

    @LastModifiedBy
    @Column(length = 50)
    private String modifier;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy