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

import com.alibaba.fastjson.JSON;
import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
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 javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.Optional;

/**
 * 用户曲目作品点赞记录
 * 2023-10-30 14:59:53
 */
@ApiModel(value = "UserMusicStarWrapper对象", description = "用户曲目作品点赞记录查询对象")
public class UserMusicStarWrapper {

    @Data
	@Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @ApiModel(" UserMusicStarQuery-用户曲目作品点赞记录")
    public static class UserMusicStarQuery implements QueryInfo {

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

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

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

        @ApiModelProperty("作品ID")
        @NotNull(message = "作品ID不能为空")
        private Long userMusicId;

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

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

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

    @Data
	@ApiModel(" UserMusicStar-用户曲目作品点赞记录")
    public static class UserMusicStar {


        private Long id;

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

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

        @ApiModelProperty("用户名")
        private String userName;

        @ApiModelProperty("用户头像")
        private String userAvatar;

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

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

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

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

        @ApiModelProperty("发布作品ID")
        private Long userMusicId;

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

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

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


    @Data
    @ApiModel(" Star-点赞/取消点赞")
    public static class Star {

        @ApiModelProperty("发布作品ID")
        private Long userMusicId;

        @ApiModelProperty("点赞/取消点赞")
        private Boolean star = true;


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

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


    }

    @Data
    public static class StarCount {

        @ApiModelProperty("发布作品ID")
        private Long userMusicId;

        @ApiModelProperty("点赞数")
        private Integer starCount;

    }
}
