package com.aegis.resource.equipment.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * 装备操作日志实体类 resource_equipment_log
 * 
 * @author aegis
 */
public class EquipmentLog implements Serializable {
    
    private static final long serialVersionUID = 1L;

    /** 日志ID */
    private Long id;

    /** 装备ID */
    private Long equipmentId;

    /** 操作类型 */
    private String action;

    /** 原状态 */
    private String fromStatus;

    /** 新状态 */
    private String toStatus;

    /** 调度ID（操作调度时） */
    private Long dispatchId;

    /** 事件ID（操作事件时） */
    private Long eventId;

    /** 变更内容（JSON格式） */
    private String diff;

    /** 备注 */
    private String remark;

    /** 操作人ID */
    private Long operatorId;

    /** 操作人姓名 */
    private String operatorName;

    /** 请求ID（用于追踪） */
    private String requestId;

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

    /** 请求参数 */
    @JsonIgnore
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Map<String, Object> params;

    public Long getId() {
        return id;
    }

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

    @NotNull(message = "装备ID不能为空")
    public Long getEquipmentId() {
        return equipmentId;
    }

    public void setEquipmentId(Long equipmentId) {
        this.equipmentId = equipmentId;
    }

    @NotNull(message = "操作类型不能为空")
    @Size(min = 0, max = 32, message = "操作类型长度不能超过32个字符")
    public String getAction() {
        return action;
    }

    public void setAction(String action) {
        this.action = action;
    }

    @Size(min = 0, max = 16, message = "原状态长度不能超过16个字符")
    public String getFromStatus() {
        return fromStatus;
    }

    public void setFromStatus(String fromStatus) {
        this.fromStatus = fromStatus;
    }

    @Size(min = 0, max = 16, message = "新状态长度不能超过16个字符")
    public String getToStatus() {
        return toStatus;
    }

    public void setToStatus(String toStatus) {
        this.toStatus = toStatus;
    }

    public Long getDispatchId() {
        return dispatchId;
    }

    public void setDispatchId(Long dispatchId) {
        this.dispatchId = dispatchId;
    }

    public Long getEventId() {
        return eventId;
    }

    public void setEventId(Long eventId) {
        this.eventId = eventId;
    }

    public String getDiff() {
        return diff;
    }

    public void setDiff(String diff) {
        this.diff = diff;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Long getOperatorId() {
        return operatorId;
    }

    public void setOperatorId(Long operatorId) {
        this.operatorId = operatorId;
    }

    @Size(min = 0, max = 64, message = "操作人姓名长度不能超过64个字符")
    public String getOperatorName() {
        return operatorName;
    }

    public void setOperatorName(String operatorName) {
        this.operatorName = operatorName;
    }

    @Size(min = 0, max = 64, message = "请求ID长度不能超过64个字符")
    public String getRequestId() {
        return requestId;
    }

    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    public Date getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    public Map<String, Object> getParams() {
        if (params == null) {
            params = new HashMap<>();
        }
        return params;
    }

    public void setParams(Map<String, Object> params) {
        this.params = params;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("equipmentId", getEquipmentId())
            .append("action", getAction())
            .append("fromStatus", getFromStatus())
            .append("toStatus", getToStatus())
            .append("dispatchId", getDispatchId())
            .append("eventId", getEventId())
            .append("diff", getDiff())
            .append("remark", getRemark())
            .append("operatorId", getOperatorId())
            .append("operatorName", getOperatorName())
            .append("requestId", getRequestId())
            .append("createdAt", getCreatedAt())
            .toString();
    }
}