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 ClassesDataVo {
    /**
     * 数据ID
     */
    private Integer id;

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

    /**
     * 师傅名称
     */
    private String userName;

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

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

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

    public List<ShiftSettingDataVo> getShifts() {
        List<String> ids = shiftId == null ? new ArrayList<>() : Arrays.asList(shiftId.split(","));
        List<String> names = shiftName == null ? new ArrayList<>() : Arrays.asList(shiftName.split(","));
        List<ShiftSettingDataVo> shiftList = new ArrayList<>();
        for (int i = 0;i< names.size();i++) {
            ShiftSettingDataVo s = new ShiftSettingDataVo();
            s.setId(ids.get(i) == null ? 0 : Integer.valueOf(ids.get(i)));
            s.setName(names.get(i) == null ? "" : names.get(i));
            shiftList.add(s);
        }
        return shiftList;
    }

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