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

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableField;
import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
import com.yonge.cooleshow.biz.dal.enums.EVipType;
import com.yonge.cooleshow.common.enums.EUserMusicType;
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.Optional;

/**
 * 用户曲目作品
 * 2023-09-05 15:27:10
 */
@ApiModel(value = "UserMusicWrapper对象", description = "用户曲目作品查询对象")
public class UserMusicWrapper {

    @Data
	@Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @ApiModel(" UserMusicQuery-用户曲目作品")
    public static class UserMusicQuery implements QueryInfo {

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

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

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

        @ApiModelProperty("草稿 DRAFT 作品FORMAL")
        private EUserMusicType type;

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

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

        @ApiModelProperty(value = "id",hidden = true)
        private Long id;


        @ApiModelProperty("文件类型 音频 AUDIO,视频：VIDEO")
        private String fileType;


        @ApiModelProperty("关联练习数据ID")
        private Long musicPracticeRecordId;


        @ApiModelProperty(value = "去除的ID,推荐作品列表需要去除原本作品")
        private Long exclusionId;


        @ApiModelProperty(value = "排序 1:推荐")
        private Integer sort = 0;



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

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

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

    @Data
	@ApiModel(" UserMusic-用户曲目作品")
    public static class UserMusic {


        private Long id;

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

        @ApiModelProperty(value = "用户类型")
        private ClientEnum clientType;

        @ApiModelProperty(value = "用户名称")
        private String username;

        @ApiModelProperty(value = "用户头像")
        private String avatar;

        @ApiModelProperty(value = "用户声部ID")
        private String subjectId;

        @ApiModelProperty(value = "用户声部名称")
        private String subjectName;


        @ApiModelProperty("年级")
        private Integer currentGradeNum;

        @ApiModelProperty("班级")
        private String currentClass;

        @ApiModelProperty(value = "是否会员")
        private Boolean vipFlag;


        @ApiModelProperty(value = "vip类型 VIP:会员 SVIP:SVIP，NOT_VIP:不是vip")
        private EVipType vipType;

        @ApiModelProperty("关联练习数据ID")
        private Long musicPracticeRecordId;

        @ApiModelProperty(value = "曲目ID")
        private Long musicSheetId;


        @ApiModelProperty("原伴奏")
        private String accompanyUrl;

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

        @ApiModelProperty("曲目声部ID")
        private String musicSheetSubjectId;

        @ApiModelProperty("曲目声部名称")
        private String musicSheetSubjectName;

        @ApiModelProperty("草稿 DRAFT 作品FORMAL")
        private EUserMusicType type;

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

        @ApiModelProperty("视频地址")
        private String videoUrl;

        @ApiModelProperty("文件类型") // .mp4 视频，其他为音频
        private String fileType;


        @ApiModelProperty("视频封面图")
        private String videoImg;

        @ApiModelProperty("录音文件地址")
        private String recordFilePath;

        @ApiModelProperty("录像文件地址")
        private String videoFilePath;

        @ApiModelProperty("json配置")
        private String jsonConfig;

        @ApiModelProperty("点赞数")
        private Integer likeNum = 0;

        @ApiModelProperty("发布描述")
        private String desc;

        @ApiModelProperty("是否点赞")
        private Boolean starFlag =false;


        @ApiModelProperty("发布作品时间")
        private Date submitTime;
        @ApiModelProperty("是否能被看到评级、评分字段")
        private Boolean selectFlag;


        @ApiModelProperty("录制上传时间")
        private Date createTime;

        @ApiModelProperty("过期时间")
        private Date expireTime;
        public String jsonString() {
            return JSON.toJSONString(this);
        }

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


    @Data
    @ApiModel(" UserMusic-用户曲目作品")
    public static class AddUserMusic {


        private Long id;

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

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

        @ApiModelProperty("关联练习数据ID")
        private Long musicPracticeRecordId;

        @ApiModelProperty(value = "曲目ID",hidden = true)
        private Long musicSheetId;

        @ApiModelProperty("原伴奏")
        private String accompanyUrl;


        @ApiModelProperty("草稿 DRAFT 作品FORMAL")
        private EUserMusicType type;

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

        @ApiModelProperty("视频封面图")
        private String videoImg;


        @ApiModelProperty("发布描述")
        private String desc;


        @ApiModelProperty("视频地址")
        private String videoUrl;

        @ApiModelProperty("json配置")
        private String jsonConfig;

        @ApiModelProperty("是否能被看到评级、评分字段")
        private Boolean selectFlag;
    }

}
