package org.springblade.common.base;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.simpleframework.xml.Transient;

import java.io.Serializable;
import java.util.Date;

/**
 * 基础实体 需要时间的实体类继承该实体
 *
 */
@Data
public abstract class BaseEntity<T extends BaseEntity> implements Serializable {

    private static final long serialVersionUID = -6518544111015038849L;


	@JsonSerialize(using = ToStringSerializer.class)
	@TableId(value = "id", type = IdType.ASSIGN_ID)
	@ApiModelProperty(value = "主键")
	protected Long id;

    @TableField(value = "create_user_id", fill = FieldFill.INSERT)
	@JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "创建人", hidden = true)
    private Long createUserId;

    @TableField(value = "update_user_id", fill = FieldFill.INSERT_UPDATE)
	@JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "修改人", hidden = true)
    private Long updateUserId;

    @TableField(value = "create_time", fill = FieldFill.INSERT)
    @ApiModelProperty(value = "创建时间", hidden = true)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    protected Date createTime;

    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    @ApiModelProperty(value = "更新时间", hidden = true)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

	@TableLogic
    @TableField("is_delete")
    @ApiModelProperty(value = "0为未删除，1为已删除", hidden = true)
    private Integer isDelete = 0;

}
