package com.yonge.cooleshow.admin.io.request.teacher;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yonge.cooleshow.biz.dal.enums.GenderEnum;
import com.yonge.cooleshow.biz.dal.enums.MK;
import com.yonge.cooleshow.common.enums.YesOrNoEnum;
import com.yonge.toolset.base.page.QueryInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * 老师端统计信息
 * Created by Eric.Shang on 2022/10/8.
 */
public class TeacherVO {

    /**
     * 老师统计指标信息
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @ApiModel("老师统计响应信息")
    public static class TeacherStat implements Serializable {

        @ApiModelProperty("星级")
        private Integer starGrade;
        @ApiModelProperty("粉丝数")
        private Integer fansNum;
        @ApiModelProperty("已上课时")
        private Integer expTime;
        @ApiModelProperty("未上课时")
        private Integer unExpTime;
        @ApiModelProperty("专辑数 ")
        private Integer musicAlbumNum;
        @ApiModelProperty("曲谱数 ")
        private Integer musicSheetNum;
        @ApiModelProperty("学生数")
        private Integer studentNums;

        public static TeacherStat from(String recv) {

            return JSON.parseObject(recv, TeacherStat.class);
        }
    }

    /**
     * 老师粉丝数
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class TeacherFansQuery extends QueryInfo {

        @ApiModelProperty("搜索条件：昵称/编号/手机号")
        private String search;

        @ApiModelProperty("老师ID")
        private Long teacherId;

        @ApiModelProperty("开始时间")
        @JsonFormat(pattern = MK.TIME_PATTERN, timezone = MK.TIME_ZONE)
        private Date startTime;

        @ApiModelProperty("结束时间")
        @JsonFormat(pattern = MK.TIME_PATTERN, timezone = MK.TIME_ZONE)
        private Date endTime;

        private String nickname;
        private Long userId;
        private String phone;

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

        public void setSearch(String search) {
            if (StringUtils.isNotEmpty(search)) {

                if (search.matches(MK.EXP_INT)) {

                    if (search.matches(MK.EXP_MOBILE_NUMBER)) {

                        setPhone(search);
                    } else {
                        setUserId(Long.parseLong(search));
                    }

                } else {
                    // 昵称
                    setNickname(search);
                }
            }
            this.search = search;
        }
    }

    /**
     * 老师粉丝
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class TeacherFans implements Serializable {

        @ApiModelProperty("用户编号")
        private String userId;
        @ApiModelProperty("昵称")
        private String userName;
        @ApiModelProperty(value = "真实姓名")
        private String realName;
        @ApiModelProperty("头像地址")
        private String avatar;
        @ApiModelProperty("声部")
        private String subjectName;
        @ApiModelProperty(value = "性别 0女 1男")
        private GenderEnum gender;
        @ApiModelProperty(value = "是否会员 0否 1是")
        private YesOrNoEnum isVip;

        @ApiModelProperty("手机号")
        private String phone;

        @ApiModelProperty("关注时间")
        @JsonFormat(pattern = MK.TIME_PATTERN, timezone = MK.TIME_ZONE)
        private Date starTime;

        @ApiModelProperty("出生日期")
        private Date birthdate;

        @ApiModelProperty("出生日期")
        private Integer age;
    }
}
