package com.yonge.cooleshow.biz.dal.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.dayaedu.cbs.common.enums.music.EDefaultScoreType;
import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetWrapper;
import com.yonge.cooleshow.biz.dal.enums.*;
import com.yonge.cooleshow.common.enums.YesOrNoEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

@Data
@ApiModel(value = "MusicSheetVo对象", description = "音乐曲目表查询视图对象")
public class MusicSheetVoResult implements Serializable {

    @ApiModelProperty("添加人")
    private String addName;

    @ApiModelProperty("添加头像（老师头像）")
    private String addUserAvatar;

    @ApiModelProperty("标签名")
    private String musicTagNames;

    @ApiModelProperty("声部名")
    private String subjectNames;

    @ApiModelProperty("收藏 0：否，1：是")
    private YesOrNoEnum favorite = YesOrNoEnum.NO;

    @ApiModelProperty("是否购买/VIP（0：否，1：是） ")
    private YesOrNoEnum play;

    @ApiModelProperty("专辑中曲目的排序号")
    private Integer albumSortNumber;  //排序号

    @ApiModelProperty("单曲专辑数")
    private Integer albumNums;

    @ApiModelProperty("曲目来源名")
    private String  sourceName;

    @ApiModelProperty("机构专辑ID,逗号隔开")
    private String tenantAlbumId;

    @ApiModelProperty("所属人信息")
    private CbsMusicSheetWrapper.MusicSheetExtend musicSheetExtend;

    @TableId(value = "id_", type = IdType.AUTO)
    @ApiModelProperty(value = "主键id")
    private Long id;  //主键ID

    @TableField(value = "cbs_music_sheet_id_")
    @ApiModelProperty(value = "内容平台曲目ID")
    private String cbsMusicSheetId;  //主键ID

    @NotBlank(message = "曲谱名称不能为空!")
    @Size(max = 64, message = "曲谱名称长度不能超过64位!")
    @TableField("music_sheet_name_")
    @ApiModelProperty(value = "曲谱名称")
    private String musicSheetName;  //曲谱名称


    @NotBlank(message = "曲谱封面图不能为空!")
    @TableField("title_img_")
    @ApiModelProperty(value = "封面图")
    private String titleImg;  //曲谱名称

    @TableField("user_id_")
    @ApiModelProperty(value = "曲谱来源(平台用户ID或者是老师ID)")
    private Long userId;  //曲谱来源(平台用户ID或者是老师ID)

    @TableField("notation_")
    @ApiModelProperty("是否可以转简谱（0:否，1：是）")
    private YesOrNoEnum notation;

    @TableField("music_img_")
    @ApiModelProperty("曲目图片")
    private String musicImg;

    @TableField("source_type_")
    @ApiModelProperty(value = "曲目来源类型 TEACHER 老师 PLATFORM 平台")
    private SourceTypeEnum sourceType;

    @TableField("provider_type_")
    @ApiModelProperty(value = "提供方 TENANT 机构 PLATFORM 平台")
    private SourceTypeEnum providerType;

    @NotBlank(message = "艺术家不能为空!")
    @Size(max = 32, message = "艺术家长度不能超过32位!")
    @TableField("composer_")
    @ApiModelProperty(value = "艺术家")
    private String composer;  //音乐家

    @TableField("music_subject_")
    @ApiModelProperty(value = "曲谱声部(适用的乐器,可能是多个,用逗号分隔)")
    private String musicSubject;  //曲谱声部(适用的乐器,可能是多个,用逗号分隔)

    @NotNull(message = "曲谱音频文件类型不能为空!")
    @TableField("audio_type_")
    @ApiModelProperty(value = "曲目音频类型 MP3：mp3, MIDI:midi,")
    private AudioTypeEnum audioType;

    @TableField("mp3_type_")
    @ApiModelProperty(value = "mp3类型 MP3：mp3, MP3_METRONOME:MP3_METRONOME,")
    private AudioTypeEnum mp3Type;

    @TableField("favorite_count_")
    @ApiModelProperty(value = "收藏数")
    private Integer favoriteCount;

    @ApiModelProperty("虚拟人数 ")
    @TableField(value = "virtual_number_")
    private Integer virtualNumber;

    @NotBlank(message = "曲谱标签不能为空!")
    @ApiModelProperty(value = "曲谱标签(多个标签用逗号分隔)")
    private String musicTag;  //曲谱标签(多个标签用逗号分隔)

    @NotNull(message = "伴奏类型不能为空!")
    @ApiModelProperty(value = "伴奏类型 HOMEMODE:自制伴奏  COMMON:普通伴奏")
    private AccompanimentTypeEnum accompanimentType;

    // @NotNull(message = "默认播放速度不能为空!")
    @ApiModelProperty(value = "默认播放速度")
    private String playSpeed;  //默认播放速度

    @ApiModelProperty(value = "是否可以评测(0:否;1:是)")
    private YesOrNoEnum canEvaluate;  //是否可以评测(0:否;1:是)

    @ApiModelProperty(value = "是否展示指法(0:否;1:是)")
    private YesOrNoEnum showFingering;  //是否展示指法(0:否;1:是)

    // @NotNull(message = "收费类型不能为空!")
    @ApiModelProperty(value = "收费类型(FREE:免费;VIP:会员;CHARGE:单曲收费)")
    private ChargeTypeEnum chargeType;  //收费类型(0:免费;1:会员;2:单曲收费)

    @NotNull(message = "收费类型不能为空!")
    @ApiModelProperty(value = "收费类型(FREE:免费;VIP:会员;CHARGE:单曲收费)")
    private String paymentType;

    @ApiModelProperty(value = "曲目状态(0:停用，1：启用)")
    private YesOrNoEnum state;

    @ApiModelProperty(value = "曲目停用原因")
    private String reason;

    @ApiModelProperty(value = "审核状态(DOING:待审核;PASS:通过;UNPASS:未通过)")
    private AuthStatusEnum auditStatus;

    @ApiModelProperty(value = "提交审核时间")
    private Date submitAuditTime;

    @ApiModelProperty(value = "第一次通过审核时间")
    private Date firstPassAuditTime;

    @ApiModelProperty(value = "排序号")
    private Integer sortNumber;  //排序号

    @ApiModelProperty(value = "是否置顶(0:否;1:是)")
    private YesOrNoEnum topFlag;  //是否置顶(0:否;1:是)

    @ApiModelProperty(value = "是否热门曲谱(0:否;1:是)")
    private YesOrNoEnum hotFlag;  //是否热门曲谱(0:否;1:是)

    @ApiModelProperty(value = "精品标志(0:否;1:是)")
    private YesOrNoEnum exquisiteFlag;

    @ApiModelProperty(value = "曲谱价格")
    private java.math.BigDecimal musicPrice;  //曲谱价格

    @ApiModelProperty(value = "音频文件存储路径")
    private String audioFileUrl;  //音频文件存储路径

    @NotBlank(message = "XML文件存储路径不能为空!")
    @ApiModelProperty(value = "XML文件存储路径")
    private String xmlFileUrl;  //XML文件存储路径

    @ApiModelProperty(value = "midi路径")
    private String midiUrl;  //XML文件存储路径

    @ApiModelProperty(value = "伴奏含节拍器路径")
    private String metronomeUrl;  //XML文件存储路径

    @ApiModelProperty(value = "伴奏（不含节拍器）路径")
    private String url;  //XML文件存储路径

    @ApiModelProperty(value = "是否自带节拍器(0:否;1:是)")
    private YesOrNoEnum hasBeat;  //是否自带节拍器(0:否;1:是)

    @ApiModelProperty(value = "是否审核时可见 （0:否  1：是）")
    private YesOrNoEnum auditVersion;

    @ApiModelProperty(value = "创建时间")
    private java.util.Date createTime;  //创建时间

    @ApiModelProperty(value = "创建人(老师或者是后台平台用户)")
    private Long createBy;  //创建人(老师或者是后台平台用户)

    @ApiModelProperty(value = "更新时间")
    private java.util.Date updateTime;  //更新时间

    @ApiModelProperty(value = "更新人(老师或者是后台平台用户)")
    private Long updateBy;  //更新人(老师或者是后台平台用户)

    @ApiModelProperty(value = "备注")
    private String remark;  //备注，填写未通过审核的原因

    @ApiModelProperty("曲目配置信息")
    private String extConfigJson;

    private String musicJSON;

    private String musicSvg;

    private String musicJianSvg;

    private String musicFirstSvg;

    @ApiModelProperty("首调")
    private String firstTone;

    @ApiModelProperty("固定调")
    private String fixedTone;

    @ApiModelProperty(value = "假删除标识 0：未删除 1：已删除")
    private Boolean delFlag;

    @ApiModelProperty(value = "数据修复时间")
    private Date correctTime;

    //曲谱类型 SINGLE/CONCERT ，使用MusicSheetTypeEnum
    @ApiModelProperty(value = "曲谱类型(SINGLE:单曲，CONCERT:合奏)")
    private MusicSheetTypeEnum musicSheetType;

    @ApiModelProperty("谱面类型")
    private EDefaultScoreType scoreType;


    @ApiModelProperty(value = "客户端状态曲目状态(0:停用，1：启用)")
    private Boolean clientState;

    @ApiModelProperty(value = "内容平台状态曲目状态(0:停用，1：启用)")
    private Boolean  platformState;

    @ApiModelProperty("分类")
    private String categoryName;

    public ChargeTypeEnum getChargeType() {
        if (Objects.isNull(this.chargeType) && StringUtils.isNotEmpty(getPaymentType())) {

            return ChargeTypeEnum.valueOf(getPaymentType().split(",")[0]);
        }
        return chargeType;
    }
}
