package com.zhongshu.card.client.model.devices.permiss;

import com.zhongshu.card.client.model.base.SuperModel;
import com.zhongshu.card.client.type.DataState;
import com.zhongshu.card.client.type.device.PermissSettingType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author TRX
 * @date 2024/12/19
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PermissSettingModel extends SuperModel {

    @Schema(description = "名称")
    private String name;

    @Schema(description = "关联的时间段")
    private PermissTimeSlotSimpleModel timeSlot;

    private String timeSlotId;

    private String timeSlotName;

    public String getTimeSlotName() {
        if (ObjectUtils.isNotEmpty(timeSlot)) {
            return timeSlot.getName();
        }
        return "";
    }

    public String getTimeSlotId() {
        if (timeSlot != null) {
            return timeSlot.getId();
        }
        return "";
    }

    @Schema(description = "关联的数据ID集合")
    private List<PermissSettingConfigModel> list = new ArrayList<>();

    @Schema(description = "数据状态")
    private DataState state;

    private String stateStr;

    public String getStateStr() {
        if (state != null) {
            return state.getRemark();
        }
        return "";
    }
}
