package com.rf.psychological.plan.dao.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.rf.psychological.base.model.BaseEntity;
import lombok.*;
import org.hibernate.Hibernate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;
import java.util.Date;
import java.util.Objects;

/**
 * @author lpf
 * @description:
 * @date 2022/1/6 9:26
 */
@Entity
@ToString
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@Table(name = "t_test_plan", indexes = {
        @Index(columnList = "id", unique = true),
        @Index(columnList = "institution_no")
})
@org.hibernate.annotations.Table(appliesTo = "t_test_plan", comment = "测试计划表")
public class TestPlanEntity extends BaseEntity {

    @Column(name = "name", columnDefinition = "varchar(50) not null comment '测试计划名称'")
    private String name;

    @Column(name = "create_user_id", columnDefinition = "varchar(36) not null comment '创建用户id'")
    private String createUserId;

    @Column(name = "institution_no", columnDefinition = "varchar(20) not null comment '机构编号'")
    private String institutionNo;

    @Column(name = "create_user", columnDefinition = "varchar(50) comment '创建用户名称'")
    private String createUser;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(name = "test_begin_time", columnDefinition = "datetime not null  comment '测试计划起始时间'")
    private Date testBeginTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(name = "test_end_time", columnDefinition = "datetime not null  comment '测试计划结束时间'")
    private Date testEndTime;

    @Column(name = "status", columnDefinition = "int not null comment '测试计划状态  测试状态:0--已关闭,1---手动关闭,2----未开始,3---进行中'")
    private int status;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(name = "create_time", columnDefinition = "datetime not null comment '记录创建时间'")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(name = "update_time", columnDefinition = "timestamp default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP comment '记录修改时间'")
    private Date updateTime;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
        TestPlanEntity that = (TestPlanEntity) o;
        return getId() != null && Objects.equals(getId(), that.getId());
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }


}
