package com.qmth.teachcloud.exchange.common.base;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qmth.teachcloud.exchange.common.contant.SystemConstant;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

/**
 * @Description: 基础entity
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2019/12/6
 */
public class BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "主键")
    @TableId(value = "id")
    private Long id;

    @JsonSerialize(using = ToStringSerializer.class)
    @TableField("create_id")
    @ApiModelProperty(value = "创建人")
    private Long createId;

    @TableField(value = "create_time", fill = FieldFill.INSERT)//新增执行
    @ApiModelProperty(value = "创建时间")
    private Long createTime;

    @JsonSerialize(using = ToStringSerializer.class)
    @TableField("update_id")
    @ApiModelProperty(value = "修改人")
    private Long updateId;

    @TableField(value = "update_Time", fill = FieldFill.INSERT_UPDATE) // 新增和更新执行
    @ApiModelProperty(value = "修改时间")
    private Long updateTime;

    public void insertInfo(Long userId) {
        this.id = SystemConstant.getDbUuid();
        this.createId = userId;
        this.createTime = System.currentTimeMillis();
    }

    public void updateInfo(Long userId) {
        this.updateId = userId;
        this.updateTime = System.currentTimeMillis();
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getCreateId() {
        return createId;
    }

    public void setCreateId(Long createId) {
        this.createId = createId;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public Long getUpdateId() {
        return updateId;
    }

    public void setUpdateId(Long updateId) {
        this.updateId = updateId;
    }

    public Long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Long updateTime) {
        this.updateTime = updateTime;
    }
}
