package com.izouma.wenlvju.dto;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.izouma.wenlvju.annotations.EnumFormat;
import com.izouma.wenlvju.domain.performance.Programme;
import com.izouma.wenlvju.enums.CompetitionGroup;
import com.izouma.wenlvju.enums.ProgrammeStatus;
import com.izouma.wenlvju.utils.excel.EnumExcelConverter;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ProgrammeShowDTO {
    @ExcelProperty(value = "节目编号")
    private Long id;

    @ExcelIgnore
    private String performance;

    @ExcelProperty(value = "节目名称")
    private String name;

    @ExcelProperty(value = "参赛专业")
    private String specialty;

    @EnumFormat(value = CompetitionGroup.class,
            fromExcel = {"个人", "集体"},
            toJavaEnum = {"SINGLE", "COLLECTIVE"})
    @ExcelProperty(value = "参赛组别", converter = EnumExcelConverter.class)
    @Enumerated(EnumType.STRING)
    private CompetitionGroup competitionGroup;

    @ExcelProperty(value = "参赛级别")
    private String level;

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

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

    @ExcelProperty(value = "考级机构")
    private String gradingOrganization;

    @ExcelProperty(value = "承办单位")
    private String organization;

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

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

    @ExcelProperty(value = "参赛人数")
    private int quantity;

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

    @ExcelIgnore
    private String video;

    @ExcelIgnore
    private String annex;

    @ExcelIgnore
    private ProgrammeStatus programmeStatus;

    @ExcelIgnore
    private List<ParticipantDTO> participants;

    public ProgrammeShowDTO(Programme programme) {
        BeanUtil.copyProperties(programme, this);
        if (programme.getVideo() != null) {
            this.video = programme.getVideo().getSrc();
        }
    }

}
