package com.ym.mec.education.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.ym.mec.common.enums.BaseEnum;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Time;
import java.util.Arrays;
import java.util.Date;

/**
 * <p>
 * 课程计划表
 * </p>
 *
 * @author lemeng
 * @since 2019-09-25
 */
@TableName("course_schedule")
@Data
public class CourseSchedule extends Model<CourseSchedule> {

    private static final long serialVersionUID = 1L;

    public enum CourseScheduleType implements BaseEnum<String, CourseScheduleType> {

        SINGLE("SINGLE", "单技课"), MIX("MIX", "合奏课"), HIGH("HIGH", "小班课"), VIP("VIP", "vip课"), DEMO("demo", "试听课"), COMPREHENSIVE("comprehensive", "综合课"), PRACTICE(
                "PRACTICE", "练习课"), ENLIGHTENMENT("ENLIGHTENMENT", "启蒙课"), TRAINING("TRAINING", "集训课");

        private String code;

        private String msg;

        CourseScheduleType(String code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        @Override
        public String getCode() {
            return code;
        }

        public String getMsg() {
            return msg;
        }

        /**
         * 根据枚举值获取枚举信息
         *
         * @param code 枚举值
         * @return 枚举信息
         */
        public static String getMsgByCode(String code) {
            return Arrays.stream(CourseScheduleType.values())
                    .filter(StudentAttendanceStatusEnum -> StudentAttendanceStatusEnum.getCode().equals(code))
                    .findFirst()
                    .map(CourseScheduleType::getMsg).orElse(null);
        }
    }

    @TableId(value = "id_", type = IdType.AUTO)
    private Long id;
    /**
     * 班级编号
     */
    @TableField("class_group_id_")
    private Integer classGroupId;
    /**
     * 课程状态
     */
    @TableField("status_")
    private String status;
    /**
     * 补贴
     */
    @TableField("subsidy_")
    private BigDecimal subsidy;
    /**
     * 上课日期
     */
    @TableField("class_date_")
    private Date classDate;
    @TableField(exist = false)
    private String classDateStr;
    /**
     * 上课时间
     */
    @TableField("start_class_time_")
    private Time startClassTime;
    /**
     * 结束时间
     */
    @TableField("end_class_time_")
    private Time endClassTime;
    /**
     * 上课教师
     */
    @TableField("teacher_id_")
    private Integer teacherId;
    /**
     * 实际上课教师
     */
    @TableField("actual_teacher_id_")
    private Integer actualTeacherId;
    @TableField("create_time_")
    private Date createTime;
    @TableField("update_time_")
    private Date updateTime;
    /**
     * 教学形式（线上、线下）
     */
    @TableField("teach_mode_")
    private String teachMode;

    /**
     * 课程类型(单技课、小班课、合奏课、综合课、练习课、启蒙课、集训课、VIP课、试听课)
     */
    @TableField("type_")
    private String type;
    /**
     * 课程名
     */
    @TableField("name_")
    private String name;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    @Override
    public String toString() {
        return "CourseSchedule{" +
                "id=" + id +
                ", classGroupId=" + classGroupId +
                ", status='" + status + '\'' +
                ", subsidy=" + subsidy +
                ", classDate=" + classDate +
                ", startClassTime=" + startClassTime +
                ", endClassTime=" + endClassTime +
                ", teacherId=" + teacherId +
                ", actualTeacherId=" + actualTeacherId +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", teachMode='" + teachMode + '\'' +
                ", type='" + type + '\'' +
                ", name='" + name + '\'' +
                '}';
    }
}
