package com.cool.store.entity;

import com.cool.store.enums.InterviewTypeEnum;
import lombok.Data;

import java.util.Date;
import javax.persistence.*;

@Data
@Table(name = "xfsg_line_calendars_event")
public class LineCalendarsEventDO {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 区域ID
     */
    @Column(name = "region_id")
    private Long regionId;

    /**
     * line_info.id
     */
    @Column(name = "line_id")
    private Long lineId;

    /**
     * partner_user_info.partner_id
     */
    @Column(name = "partner_id")
    private String partnerId;

    /**
     * 事件标题
     */
    @Column(name = "event_title")
    private String eventTitle;

    /**
     * 面试类型:0面谈;1一审;2二审
     */
    @Column(name = "interview_type")
    private Integer interviewType;

    /**
     * 面试日期
     */
    @Column(name = "interview_date")
    private Date interviewDate;

    /**
     * 面试开始时间
     */
    @Column(name = "start_time")
    private Date startTime;

    /**
     * 面试结束时间
     */
    @Column(name = "end_time")
    private Date endTime;

    /**
     * 面试官
     */
    @Column(name = "interviewer_user_id")
    private String interviewerUserId;

    /**
     * 删除标识
     */
    private Boolean deleted;

    /**
     * 创建时间
     */
    @Column(name = "create_time")
    private Date createTime;

    /**
     * 更新时间
     */
    @Column(name = "update_time")
    private Date updateTime;

    public static LineCalendarsEventDO convertDO(LineInfoDO lineInfo, Integer interviewType, Date startTime, Date endTime, String interviewerUserId){
        LineCalendarsEventDO calendarsEvent = new LineCalendarsEventDO();
        calendarsEvent.setRegionId(lineInfo.getRegionId());
        calendarsEvent.setLineId(lineInfo.getId());
        calendarsEvent.setPartnerId(lineInfo.getPartnerId());
        calendarsEvent.setEventTitle(lineInfo.getUsername() + " " + (InterviewTypeEnum.MEET.equals(interviewType) ? "面谈" :"面审"));
        calendarsEvent.setInterviewType(interviewType);
        calendarsEvent.setInterviewDate(startTime);
        calendarsEvent.setStartTime(startTime);
        calendarsEvent.setEndTime(endTime);
        calendarsEvent.setInterviewerUserId(interviewerUserId);
        return calendarsEvent;
    }

}