package com.gameplatform.server.model.entity.history;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.time.LocalDateTime;

@TableName("device_status_transition")
public class DeviceStatusTransition {
    @TableId(type = IdType.AUTO)
    private Long id;

    private String deviceId;
    private String prevStatus;   // 例如 RUNNING/USING/IDLE_COOLDOWN/IDLE_FREE
    private String newStatus;    // 同上
    private String reason;       // 变更原因（来源数据）
    private String snapshotVal;  // 当次脚本原始值
    private String series;       // 设备系列
    private Integer indexNo;     // 设备序号

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime occurredAt; // 发生时间

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdAt;  // 记录创建时间

    public DeviceStatusTransition() {}

    public DeviceStatusTransition(String deviceId, String prevStatus, String newStatus, String reason,
                                  String snapshotVal, String series, Integer indexNo,
                                  LocalDateTime occurredAt) {
        this.deviceId = deviceId;
        this.prevStatus = prevStatus;
        this.newStatus = newStatus;
        this.reason = reason;
        this.snapshotVal = snapshotVal;
        this.series = series;
        this.indexNo = indexNo;
        this.occurredAt = occurredAt;
        this.createdAt = LocalDateTime.now();
    }

    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }
    public String getDeviceId() { return deviceId; }
    public void setDeviceId(String deviceId) { this.deviceId = deviceId; }
    public String getPrevStatus() { return prevStatus; }
    public void setPrevStatus(String prevStatus) { this.prevStatus = prevStatus; }
    public String getNewStatus() { return newStatus; }
    public void setNewStatus(String newStatus) { this.newStatus = newStatus; }
    public String getReason() { return reason; }
    public void setReason(String reason) { this.reason = reason; }
    public String getSnapshotVal() { return snapshotVal; }
    public void setSnapshotVal(String snapshotVal) { this.snapshotVal = snapshotVal; }
    public String getSeries() { return series; }
    public void setSeries(String series) { this.series = series; }
    public Integer getIndexNo() { return indexNo; }
    public void setIndexNo(Integer indexNo) { this.indexNo = indexNo; }
    public LocalDateTime getOccurredAt() { return occurredAt; }
    public void setOccurredAt(LocalDateTime occurredAt) { this.occurredAt = occurredAt; }
    public LocalDateTime getCreatedAt() { return createdAt; }
    public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
}


