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

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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.joda.time.DateTime;
import org.joda.time.Period;
import org.joda.time.PeriodType;

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

/**
 * @Author: cy
 * @Date: 2022/5/12
 */
@ApiModel("老师粉丝响应信息")
public class MyFens 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;

    public String getSubjectName() {
        return subjectName;
    }

    public void setSubjectName(String subjectName) {
        this.subjectName = subjectName;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public GenderEnum getGender() {
        return gender;
    }

    public void setGender(Object gender) {
        if(gender instanceof GenderEnum ){
            this.gender = (GenderEnum) gender;
        }else if (null != gender) {
            this.gender = GenderEnum.valueOf(Integer.parseInt(gender.toString()));
        }
    }

    public YesOrNoEnum getIsVip() {
        return isVip;
    }

    public void setIsVip(YesOrNoEnum isVip) {
        this.isVip = isVip;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Date getStarTime() {
        return starTime;
    }

    public void setStarTime(Date starTime) {
        this.starTime = starTime;
    }

    public void setGender(GenderEnum gender) {
        this.gender = gender;
    }

    public Date getBirthdate() {
        return birthdate;
    }

    public void setBirthdate(Date birthdate) {
        this.birthdate = birthdate;
    }

    public Integer getAge() {
        if (Objects.nonNull(getBirthdate())) {

            return new Period(new DateTime(getBirthdate()), DateTime.now(), PeriodType.years()).getYears();
        }
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
}
