package com.repair.model.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

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

/**
 * @Author: binguo
 * @Date: 2023/7/28 星期五 14:35
 * @Description: com.repair.model.vo
 * @Version: 1.0
 */
@Data
public class ClassesSettingVo {
    /**
     * 数据ID
     */
    private Integer id;

    /**
     * 用户ID
     */
    private int userId;

    /**
     * 日期
     */
    private String startDate;

    /**
     * 班次ID
     */
    @JsonIgnore
    private String shiftId;

    /**
     * 班次集合ID
     */

    private List<String> shiftIds;

    public List<String> getShiftIds() {
        return shiftId == null ? new ArrayList<>() : Arrays.asList(shiftId.split(","));
    }

    public void setShiftIds(List<String> shiftIds) {
        this.shiftIds = shiftIds;
    }

    /**
     * 班次名称
     */
    @JsonIgnore
    private String shiftName;

    /**
     * 班次颜色
     */
    @JsonIgnore
    private String shiftColor;

    /**
     * 班次集合
     */
    private List<shiftSettingVo> shifts;

    public List<shiftSettingVo> getShifts() {
        List<String> names = shiftName == null ? new ArrayList<>() : Arrays.asList(shiftName.split(","));
        List<String> colors = shiftColor == null ? new ArrayList<>() : Arrays.asList(shiftColor.split(","));
        List<shiftSettingVo> shiftList = new ArrayList<>();
        for (int i = 0;i< names.size();i++) {
            shiftSettingVo s = new shiftSettingVo();
            s.setName(names.get(i) == null ? "" : names.get(i));
            s.setColor(colors.get(i) == null ? "" : colors.get(i));
            shiftList.add(s);
        }
        return shiftList;
    }

    public void setShifts(List<shiftSettingVo> shifts) {
        this.shifts = shifts;
    }
}
