package com.common.entity;

import com.Modules.etl.handler.ArrayIntegerTypeHandler;
import com.Modules.etl.handler.ArrayStringTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.TypeHandler;
import org.apache.ibatis.type.ArrayTypeHandler;

import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.List;

/**
 * 封禁指令表实体类
 * 对应表: device_interlocking_cmd
 */
public class DeviceInterlockingCmd {
    private Long id;
    private Long probeId;                      // 探针ID
    private String probeIp;                    // 探针IP
    private Integer[] deviceInterlockingId;    // 联动设备ID（数组）
    private String[] deviceInterlockingIp;      // 联动设备IP（数组）
    private String[] banIps;                    // 封禁IP（数组）
    private String banMethod;                   // 封禁方式（0:手工、1:自动）
    private String banType;                    // 封禁类型（1:白名单、0:黑名单）
    private String cmdStatus;                  // 指令状态（0:未执行、1:已完成、2:执行中）
    private Integer banDuration;              // 封禁时长（秒，-1表示永久）
    private OffsetDateTime createTime;
    private OffsetDateTime updateTime;
    private String tenantId;
    private Long createDept;
    private Long createBy;
    private Long updateBy;
    private String remark;
    private Integer banOperationType;         // 封禁操作类型（0:新增、1:删除）

    // Getter and Setter
    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }

    public Long getProbeId() { return probeId; }
    public void setProbeId(Long probeId) { this.probeId = probeId; }

    public String getProbeIp() { return probeIp; }
    public void setProbeIp(String probeIp) { this.probeIp = probeIp; }

    public Integer[] getDeviceInterlockingId() { return deviceInterlockingId; }
    public void setDeviceInterlockingId(Integer[] deviceInterlockingId) { this.deviceInterlockingId = deviceInterlockingId; }

    public String[] getDeviceInterlockingIp() { return deviceInterlockingIp; }
    public void setDeviceInterlockingIp(String[] deviceInterlockingIp) { this.deviceInterlockingIp = deviceInterlockingIp; }

    public String[] getBanIps() { return banIps; }
    public void setBanIps(String[] banIps) { this.banIps = banIps; }

    public String getBanMethod() { return banMethod; }
    public void setBanMethod(String banMethod) { this.banMethod = banMethod; }

    public String getBanType() { return banType; }
    public void setBanType(String banType) { this.banType = banType; }

    public String getCmdStatus() { return cmdStatus; }
    public void setCmdStatus(String cmdStatus) { this.cmdStatus = cmdStatus; }

    public Integer getBanDuration() { return banDuration; }
    public void setBanDuration(Integer banDuration) { this.banDuration = banDuration; }

    public OffsetDateTime getCreateTime() { return createTime; }
    public void setCreateTime(OffsetDateTime createTime) { this.createTime = createTime; }

    public OffsetDateTime getUpdateTime() { return updateTime; }
    public void setUpdateTime(OffsetDateTime updateTime) { this.updateTime = updateTime; }

    public String getTenantId() { return tenantId; }
    public void setTenantId(String tenantId) { this.tenantId = tenantId; }

    public Long getCreateDept() { return createDept; }
    public void setCreateDept(Long createDept) { this.createDept = createDept; }

    public Long getCreateBy() { return createBy; }
    public void setCreateBy(Long createBy) { this.createBy = createBy; }

    public Long getUpdateBy() { return updateBy; }
    public void setUpdateBy(Long updateBy) { this.updateBy = updateBy; }

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

    public Integer getBanOperationType() { return banOperationType; }
    public void setBanOperationType(Integer banOperationType) { this.banOperationType = banOperationType; }

    // ========== 便利方法：数组与List互转 ==========

    /**
     * 获取设备联动ID列表
     */
    public List<Integer> getDeviceInterlockingIdList() {
        return deviceInterlockingId != null ? Arrays.asList(deviceInterlockingId) : null;
    }

    /**
     * 设置设备联动ID列表
     */
    public void setDeviceInterlockingIdList(List<Integer> list) {
        this.deviceInterlockingId = list != null ? list.toArray(new Integer[0]) : null;
    }

    /**
     * 获取设备联动IP列表
     */
    public List<String> getDeviceInterlockingIpList() {
        return deviceInterlockingIp != null ? Arrays.asList(deviceInterlockingIp) : null;
    }

    /**
     * 设置设备联动IP列表
     */
    public void setDeviceInterlockingIpList(List<String> list) {
        this.deviceInterlockingIp = list != null ? list.toArray(new String[0]) : null;
    }

    /**
     * 获取封禁IP列表
     */
    public List<String> getBanIpsList() {
        return banIps != null ? Arrays.asList(banIps) : null;
    }

    /**
     * 设置封禁IP列表
     */
    public void setBanIpsList(List<String> list) {
        this.banIps = list != null ? list.toArray(new String[0]) : null;
    }

    @Override
    public String toString() {
        return "DeviceInterlockingCmd{" +
                "id=" + id +
                ", probeId=" + probeId +
                ", probeIp='" + probeIp + '\'' +
                ", banType='" + banType + '\'' +
                ", cmdStatus='" + cmdStatus + '\'' +
                ", banOperationType=" + banOperationType +
                '}';
    }
}
