package thyyxxk.webserver.entity.schedulingClass.data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;


import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.format.annotation.DateTimeFormat;
import thyyxxk.webserver.entity.dictionary.SimpleCodeName;
import thyyxxk.webserver.utils.SnowFlakeId;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "scheduling_class")
public class SchedulingClass implements Serializable {

    private static final long serialVersionUID = 5734810717512894614L;

    /**
     * 主键
     */
    @TableId
    private String id;

    /**
     * 值班的人的id
     */
    @TableField(value = "code")
    private String code;

    /**
     * 排班时间
     */
    @TableField(value = "scheduling_date")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private Date schedulingDate;

    /**
     * 和别人换班的人，为什么不直接改变 code是因为如果有人换班了的话下次计算就会有问题
     */
    @TableField(value = "change_class")
    private String changeClass;

    /**
     * 次要的排班， 最多 10 个人可选
     */
    @TableField(value = "false_code")
    private String falseCode;


    public static LambdaQueryWrapper<SchedulingClass> lambdaQueryWrapper() {
        return new LambdaQueryWrapper<>();
    }

    public static QueryWrapper<SchedulingClass> queryWrapper() {
        return new QueryWrapper<>();
    }

    public SchedulingClass cloneData(Date schedulingTime) {
        return SchedulingClass.builder()
                .id(SnowFlakeId.instance().nextId())
                .code(this.code).schedulingDate(schedulingTime).build();
    }


    @EqualsAndHashCode(callSuper = true)
    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class SchedulingClassVo extends SchedulingClass {
        private String name;
        private String changeClassName;
        private List<SimpleCodeName> falseCodeList;
    }


}
