package com.izouma.wenlvju.domain.performance;

import cn.hutool.core.bean.BeanUtil;
import com.izouma.wenlvju.annotations.Searchable;
import com.izouma.wenlvju.annotations.SearchableOne;
import com.izouma.wenlvju.converter.VideoObjectConverter;
import com.izouma.wenlvju.domain.BaseEntity;
import com.izouma.wenlvju.domain.VideoObject;
import com.izouma.wenlvju.dto.ProgrammeDTO;
import com.izouma.wenlvju.enums.SignedIn;
import com.izouma.wenlvju.enums.CompetitionGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.time.LocalDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Entity
@Where(clause = "del = 0")
@ApiModel(value = "节目安排")
public class Programme extends BaseEntity {
    private Long performanceId;

    @Searchable
    @SearchableOne
    @ApiModelProperty(value = "节目名称")
    private String name;

    @ApiModelProperty(value = "参赛专业")
    private Long specialtyId;

    @Enumerated(EnumType.STRING)
    @ApiModelProperty(value = "参赛组别")
    private CompetitionGroup competitionGroup;

    @ApiModelProperty(value = "参赛级别")
    private Long levelSettingId;

    @ApiModelProperty(value = "作品时长")
    private int durationOfWork;

    @SearchableOne
    @ApiModelProperty(value = "指导老师")
    private String instructor;

    @ApiModelProperty(value = "联系人")
    private String contact;

    @ApiModelProperty(value = "联系电话")
    private String phone;

    @ApiModelProperty(value = "考级机构")
    private Long gradingOrganizationId;

    @ApiModelProperty(value = "承办单位")
    private Long organizationId;

    @ApiModelProperty(value = "考级点")
    private String examPoint;

    @Column(columnDefinition = "TEXT")
    @Convert(converter = VideoObjectConverter.class)
    @ApiModelProperty(value = "节目视频")
    private VideoObject video;

    @ApiModelProperty(value = "分组id")
    private Long arrangeId;

    /*
    初始状态为0，已初编排入分组为1，确定分组为2
    */
    private int status;

    @ApiModelProperty(value = "签到管理")
    @Enumerated(EnumType.STRING)
    private SignedIn signedIn;

    @Column(columnDefinition = "TEXT")
    @ApiModelProperty(value = "情况说明")
    private String description;

    @ApiModelProperty(value = "签到时间")
    private LocalDateTime signedAt;

    @ApiModelProperty(value = "参演人数")
    private int quantity;

    private String address;

    /*
    表演时间
     */
    private LocalDateTime showBegin;

    private LocalDateTime showEnd;

    @ApiModelProperty(value = "全部签到")
    private boolean allSigned;

    @ApiModelProperty(value = "评分")
    private Double score;

    @ApiModelProperty(value = "全部评分")
    private boolean allScore;

    public Programme(ProgrammeDTO dto) {
        BeanUtil.copyProperties(dto, this);
    }

}
