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

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableField;
import com.dayaedu.cbs.common.enums.school.ECourseType;
import com.dayaedu.cbs.openfeign.wrapper.music.MusicSheetCategoriesWrapper;
import com.microsvc.toolkit.common.response.paging.QueryInfo;
import com.yonge.cooleshow.biz.dal.entity.MusicSheetAccompaniment;
import com.yonge.cooleshow.biz.dal.entity.MusicTag;
import com.yonge.cooleshow.biz.dal.entity.Subject;
import com.yonge.cooleshow.biz.dal.entity.TenantAlbumCategoryDetail;
import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
import com.yonge.cooleshow.biz.dal.vo.MusicSheetDetailVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * 机构专辑曲目
 * 2023-07-21 17:32:49
 */
@ApiModel(value = "TenantAlbumMusicWrapper对象", description = "机构专辑曲目查询对象")
public class TenantAlbumMusicWrapper {

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @ApiModel(" TenantAlbumMusicQuery-机构专辑曲目")
    public static class TenantAlbumMusicQuery implements QueryInfo {

        @ApiModelProperty("当前页")
        private Integer page;

        @ApiModelProperty("分页行数")
        private Integer rows;

        @ApiModelProperty("关键字匹配")
        private String keyword;

        public String getKeyword() {
            return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
        }

        public String jsonString() {
            return JSON.toJSONString(this);
        }

        public static TenantAlbumMusicQuery from(String json) {
            return JSON.parseObject(json, TenantAlbumMusicQuery.class);
        }
    }

    @ApiModel(" TenantAlbumMusic-机构专辑曲目")
    public static class TenantAlbumMusic {

        public String jsonString() {
            return JSON.toJSONString(this);
        }

        public static TenantAlbumMusic from(String json) {
            return JSON.parseObject(json, TenantAlbumMusic.class);
        }
    }


    @Data
    @ApiModel(" TenantAlbumMusicSelectQuery-机构专辑曲目查询对象")
    public static class TenantAlbumMusicSelect {

        @ApiModelProperty("专辑ID")
        @NotNull(message = "专辑ID不能为空")
        private Long tenantAlbumId;

        @ApiModelProperty("声部分类(ENSEMBLE, MUSIC, SUBJECT)")
        @NotNull(message = "分类不能为空")
        private SubjectTypeEnum subjectType;

//        @ApiModelProperty(value = "用户ID", hidden = true)
//        private Long userId;

        @ApiModelProperty("声部id")
        private Long subjectId;
        public String jsonString() {
            return JSON.toJSONString(this);
        }

        public static TenantAlbumMusic from(String json) {
            return JSON.parseObject(json, TenantAlbumMusic.class);
        }
    }

    @Data
    @ApiModel(" TenantAlbumMusicSelectData-机构专辑曲目查询结果")
    public static class TenantAlbumMusicSelectData {

        @ApiModelProperty("声部集合")
        private List<Subject> subjects;

        @ApiModelProperty("级别集合")
        private List<String> levels;

        @ApiModelProperty("级别集合")
        private List<TenantAlbumCategoryDetail> levelList = new ArrayList<>();

        @ApiModelProperty("类型集合")
        private List<String> types;

        @ApiModelProperty("类型集合")
        private List<TenantAlbumCategoryDetail> typeList = new ArrayList<>();


        @ApiModelProperty("标签集合")
        private List<MusicTag> tags = new ArrayList<>();

        @ApiModelProperty("课件教材分类集合")
        private List<String> courseTypeList = new ArrayList<>();

        @ApiModelProperty("分类集合")
        private List<MusicSheetCategoriesWrapper.MusicSheetCategories> categoyList = new ArrayList<>();

        public String jsonString() {
            return JSON.toJSONString(this);
        }

        public static TenantAlbumMusic from(String json) {
            return JSON.parseObject(json, TenantAlbumMusic.class);
        }

    }


    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @ApiModel(" TenantAlbumMusicQuery-学生端专辑曲目分页查询")
    public static class StudentTenantAlbumMusicQuery implements QueryInfo {

        @ApiModelProperty(value = "详情专辑id")
        @NotNull(message = "专辑id不能为空")
        private Long albumId;

        @ApiModelProperty("当前页")
        private Integer page;

        @ApiModelProperty("分页行数")
        private Integer rows;

        @ApiModelProperty("关键字匹配")
        private String keyword;

        @ApiModelProperty("声部分类(ENSEMBLE, MUSIC, SUBJECT)")
        private SubjectTypeEnum subjectType;

        @ApiModelProperty("声部id")
        private Long subjectId;

        @ApiModelProperty("分类id")
        private Long categoryId;

        @ApiModelProperty(value = "分类id",hidden = true)
        private List<Long> categoryIds;

        @ApiModelProperty("级别")
        private String level;

        @ApiModelProperty("类型")
        private String type;

        @ApiModelProperty("标签")
        private Long musicTagId;

        @ApiModelProperty(value = "端类型",hidden = true)
        private ClientEnum clientType;

        @ApiModelProperty(value = "用户ID",hidden = true)
        private Long userId;

        @ApiModelProperty("课程类型编码")
        private String courseTypeCode;

        public String getKeyword() {
            return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
        }

        public String jsonString() {
            return JSON.toJSONString(this);
        }

        public static TenantAlbumMusicQuery from(String json) {
            return JSON.parseObject(json, TenantAlbumMusicQuery.class);
        }


    }

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @ApiModel(" TenantAlbumMusic-学生端专辑曲目返回")
    public static class StudentTenantAlbumMusic implements QueryInfo {
        @ApiModelProperty(value = "曲目表id")
        private Long id;

        @ApiModelProperty(value = "曲目表id")
        private Long cbsMusicSheetId;

        @ApiModelProperty("机构专辑ID")
        private Long tenantAlbumId;

        @ApiModelProperty(value = "精品标志")
        private String exquisiteFlag;

        @ApiModelProperty(value = "xml")
        private String xmlFileUrl;

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

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

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

        @ApiModelProperty(value = "曲谱名称")
        private String musicSheetName;

        @ApiModelProperty(value = "封面图")
        private String titleImg;  //曲谱名称

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

        @ApiModelProperty(value = "艺术家")
        private String composer;  //音乐家

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

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

        @ApiModelProperty(value = "上传人")
        private String userName;

        @ApiModelProperty("曲目收藏数")
        private Integer musicSheetLikeCounts;

        @ApiModelProperty("1:收藏 0:未收藏")
        private boolean favorite;

        @ApiModelProperty("声谱类型，SINGLE:单曲，CONCERT:合奏")
        private String musicSheetType;

        @ApiModelProperty("课时数")
        private Integer courseNum;

        @ApiModelProperty("单元测验数量")
        private Integer unitTestNum;

        @ApiModelProperty("是否支持混音节拍器")
        private Boolean isMixBeat;

        @ApiModelProperty("总谱五线谱PDF文件")
        private String musicPdfUrl;

        @ApiModelProperty("总谱首调PDF文件")
        private String firstPdfUrl;

        @ApiModelProperty("总谱固定调PDF文件")
        private String jianPdfUrl;

        @ApiModelProperty("曲谱伴奏")
        private List<MusicSheetAccompaniment> background;

        public String jsonString() {
            return JSON.toJSONString(this);
        }

        public static TenantAlbumMusic from(String json) {
            return JSON.parseObject(json, TenantAlbumMusic.class);
        }

        public StudentTenantAlbumMusic unitTestNum(Integer unitTestNum) {
            this.unitTestNum = unitTestNum;
            return this;
        }

        public StudentTenantAlbumMusic courseNum(Integer courseNum) {
            this.courseNum = courseNum;
            return this;
        }
    }

}
