package com.purui.prims.common.pojo;

import com.google.common.base.Objects;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;

import java.util.Date;

@Data
@ToString
public class RecordInfo {

    @ApiModelProperty(value = "创建人")
    private String createdBy;

    @ApiModelProperty(value = "更新人")
    private String updatedBy;

    @ApiModelProperty(value = "创建时间")
    private Date createdAt;

    @ApiModelProperty(value = "更新时间")
    private Date updatedAt;

    public RecordInfo createdBy(String userName) {
        this.createdBy = userName;
        this.createdAt = new Date();
        this.updatedBy = userName;
        this.updatedAt = new Date();
        return this;
    }

    public RecordInfo updatedBy(String userName) {
        this.updatedBy = userName;
        this.updatedAt = new Date();
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        RecordInfo that = (RecordInfo) o;
        return Objects.equal(createdBy, that.createdBy) && Objects.equal(
                updatedBy, that.updatedBy);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(createdBy, updatedBy, createdAt, updatedAt);
    }
}
