package cn.minbb.iot.model;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

@Entity
@Table(name = "device")
@NoArgsConstructor
public class Device implements Serializable {

    @Getter
    @Setter
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false, columnDefinition = "INT COMMENT '设备实体ID'")
    private Long id;

    @Getter
    @Setter
    @Column(name = "name", nullable = false, columnDefinition = "VARCHAR(64) COMMENT '名称'")
    private String name;

    @Getter
    @Setter
    @Column(name = "serial_number", nullable = false, columnDefinition = "VARCHAR(64) COMMENT '序列号'")
    private String serialNumber;

    @Getter
    @Setter
    @Column(name = "user_id", nullable = false, columnDefinition = "BIGINT COMMENT '关联用户'")
    private Long userId;

    @Getter
    @Setter
    @Column(name = "created_at", columnDefinition = "DATETIME COMMENT '创建时间'")
    @CreationTimestamp
    private Date createdAt;

    @Getter
    @Setter
    @Column(name = "updated_at", columnDefinition = "DATETIME COMMENT '更新时间'")
    @UpdateTimestamp
    private Date updatedAt;

    @Version
    @Column(name = "version", columnDefinition = "BIGINT COMMENT '版本号'")
    public Long version;
}
