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

import com.alibaba.fastjson.JSON;
import com.dayaedu.cbs.common.enums.EClientType;
import com.dayaedu.cbs.common.enums.music.EAudioType;
import com.dayaedu.cbs.common.enums.school.EMusicSheetType;
import com.microsvc.toolkit.common.response.paging.QueryInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;
import java.util.List;
import java.util.Optional;

/**
 * 曲谱表
 * 2022-12-07 10:16:58
 */
@ApiModel(value = "MusicSheetWrapper对象", description = "曲谱表查询对象")
public class MusicSheetWrapper {

    @Data
	@Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @ApiModel(" MusicSheetQuery-曲谱表")
    public static class MusicSheetQuery implements QueryInfo {

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

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

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

        @ApiModelProperty("伴奏类型")
        private EAudioType audioType;

        @ApiModelProperty("标签Id")
        private String musicTag;

        @ApiModelProperty("声部Id")
        private String musicSubject;

        @ApiModelProperty("伴奏类型  HOMEMODE：自制 COMMON：普通")
        private String accompanimentType;

        @ApiModelProperty("曲谱分类编号")
        private Integer musicSheetCategoriesId;

        private List<Integer> musicSheetCategoriesIdList;

        @ApiModelProperty(value = "删除标识", hidden = true)
        private Boolean delFlag;

        @ApiModelProperty(value = "启用停用标识，曲目状态（0：停用，1：启用）")
        private Boolean status;

        @ApiModelProperty("用户类型")
        private EClientType clientType;

        @ApiModelProperty("学校ID集合")
        private List<Long> schoolIds;

        @ApiModelProperty("可用途径 ORG 机构 PLATFORM 平台")
        private String availableType;

        @ApiModelProperty("学校ID")
        private Long schoolId;

        @ApiModelProperty("需要排查的曲谱ID")
        private List<Long> excludeMusicIds;

        @ApiModelProperty("曲谱ID")
        private List<Long> musicIds;

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

        public Boolean getDelFlag() {
            return Optional.ofNullable(delFlag).orElse(false);
        }

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

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

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

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

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

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
	@ApiModel(" MusicSheet-曲谱表")
    public static class MusicSheet {

        @ApiModelProperty("主键")
        private Long id;

        @ApiModelProperty("曲谱分类")
        private Integer musicSheetCategoriesId;

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

        @ApiModelProperty("可用途径 ORG 机构 PLATFORM 平台")
        private String availableType;

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

        @ApiModelProperty("封面图")
        private String titleImg;


        @ApiModelProperty("曲谱来源id")
        private Long userId;


        @ApiModelProperty("曲目来源类型 TEACHER 老师 PLATFORM 平台")
        private String sourceType;


        @ApiModelProperty("作曲人")
        private String composer;


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


        @ApiModelProperty("mp3曲谱类型  MP3;MP3_METRONOME")
        private String mp3Type;


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


        @ApiModelProperty("曲谱音频文件类型(midi;mp3)")
        private String audioType;


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


        @ApiModelProperty("曲谱标签(多个标签用逗号分隔)")
        private String musicTag;


        @ApiModelProperty("默认播放速度")
        private String playSpeed;


        @ApiModelProperty("是否可以评测(0:否;1:是)")
        private Boolean canEvaluate;


        @ApiModelProperty("伴奏类型  HOMEMODE：自制 COMMON：普通")
        private String accompanimentType;


        @ApiModelProperty("是否展示指法(0:否;1:是)")
        private Boolean showFingering;


        @ApiModelProperty("曲目状态（0：停用，1：启用）")
        private Boolean status;


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


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


        @ApiModelProperty("midi路径")
        private String midiUrl;


        @ApiModelProperty("伴奏含节拍器路径")
        private String metronomeUrl;


        @ApiModelProperty("伴奏（不含节拍器）路径")
        private String url;


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


        @ApiModelProperty("XML文件存储路径")
        private String xmlFileUrl;


        @ApiModelProperty("是否自带节拍器(0:否;1:是)")
        private Boolean hasBeat;


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


        @ApiModelProperty("创建时间")
        private Date createTime;

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

        @ApiModelProperty("创建用户")
        private String createUser;

        @ApiModelProperty("更新时间")
        private Date updateTime;

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

        @ApiModelProperty("更新用户")
        private String updateUser;

        @ApiModelProperty("备注")
        private String remark;

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

        @ApiModelProperty("伴奏")
        private List<MusicSheetAccompanimentWrapper.MusicSheetAccompaniment> background;

        @ApiModelProperty("曲目缓存")
        private String musicJSON;

        @ApiModelProperty("曲目缓存svg")
        private String musicSvg;

        @ApiModelProperty("曲目缓存简谱svg")
        private String musicJianSvg;

        @ApiModelProperty("曲目缓存首调svg")
        private String musicFirstSvg;

        @ApiModelProperty("是否节奏音乐")
        private Boolean rhythmFlag;

        @ApiModelProperty("内容平台曲目ID")
        private Long cbsMusicSheetId;

        @ApiModelProperty("内容平台声部ID")
        private String cbsSubjectId;

        @ApiModelProperty("所属学校ID")
        private String schoolIds;

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

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

}
