package com.zd.exam.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zd.common.core.annotation.Excel;
import com.zd.common.core.domain.qc.QCInterface;
import com.zd.common.core.valid.ValidGroup;
import com.zd.common.core.web.domain.BaseEntity;
import com.zd.exam.util.CourcseUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 学习资源对象 el_course
 *
 * @author liubo
 * @date 2021-12-07
 */
@ApiModel("学习资源")
public class ElCourse extends BaseEntity{//  implements QCInterface
    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    @ApiModelProperty(value = "${comment}")
    private Long id;
    /**
     * 分类ID
     */
    @Excel(name = "分类ID")
    @ApiModelProperty(value = "分类ID")
    private Long cateId;

    @ApiModelProperty(value = "父分类标题")
    private String cateTitle;

    @ApiModelProperty(value = "所有分类标题")
    private String allCateTitle;

    /**
     * 标题
     */
    @Excel(name = "标题")
    @NotBlank(groups = ValidGroup.Crud.Create.class, message = "标题不能为空")
    @Length(message = "标题长度不能超过256")
    @ApiModelProperty(value = "标题")
    private String title;

    /** 是否公开 */
    @Excel(name = "是否公开")
    @ApiModelProperty(value = "是否公开")
    private Integer pri;
    /**
     * 等级
     */
    @Excel(name = "等级")
    @Length(message = "等级长度不能超过8")
    @ApiModelProperty(value = "等级")
    private String level;
    /**
     * 是否限制顺序
     */
    @Excel(name = "是否限制顺序")
    @ApiModelProperty(value = "是否限制顺序")
    private Integer orderRest;
    /**
     * 课程时长
     */
    @Excel(name = "课程时长")
    @ApiModelProperty(value = "课程时长")
    private Long duration;
    /**
     * 课程标签
     */
    @Excel(name = "课程标签")
    @Length(message = "课程标签长度不能超过128")
    @ApiModelProperty(value = "课程标签")
    private String label;
    /**
     * PDF翻页有效时间
     */
    @Excel(name = "PDF翻页有效时间")
    @ApiModelProperty(value = "PDF翻页有效时间")
    private Long effectiveTime;
    /**
     * 课程有效时间类型（默认 0 永久，1 设置过期时间）
     */
    @Excel(name = "课程有效时间类型", readConverterExp = "默=认,0=,永=久，1,设=置过期时间")
    @ApiModelProperty(value = "课程有效时间类型")
    private Integer ceType;
    /**
     * 课程有效时间（过期类型1 时有效）
     */
    @Excel(name = "课程有效时间", readConverterExp = "过=期类型1,时=有效")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "课程有效时间")
    private Date ceTime;
    /**
     * 课程关键字
     */
    @Excel(name = "课程关键字")
    @Length(message = "课程关键字长度不能超过256")
    @ApiModelProperty(value = "课程关键字")
    private String keywords;
    /**
     * 封面图片
     */
    @Excel(name = "封面图片")
    @Length(message = "封面图片长度不能超过256")
    @ApiModelProperty(value = "封面图片")
    private String img;
    /**
     * 课程简介
     */
    @ApiModelProperty(value = "课程简介")
    private String description;
    /**
     * 课程状态 0 下架，1 上架
     */
    @Excel(name = "课程状态 0 下架，1 上架")
    @ApiModelProperty(value = "课程状态 0 下架，1 上架")
    private Integer status;
    /**
     * 是否显示课程拖拽进度
     */
    @Excel(name = "是否显示课程拖拽进度")
    @ApiModelProperty(value = "是否显示课程拖拽进度")
    private Integer videoDraggable;
    /**
     * 积分值
     */
    @Excel(name = "积分值")
    @ApiModelProperty(value = "积分值")
    private BigDecimal points;
    /**
     * 积分值
     */
    @Excel(name = "积分值")
    @ApiModelProperty(value = "学习机积分值")
    private BigDecimal machinePoints;
    /**
     * 设置选项（课程配置项 json 方便拓展）
     */
    @Excel(name = "设置选项", readConverterExp = "课=程配置项 json,方=便拓展")
    @Length(message = "设置选项长度不能超过1024")
    @ApiModelProperty(value = "设置选项")
    private String settings;
    /**
     * 课程类型 0 学习课程， 1 二维码课程
     */
    @Excel(name = "课程类型")
    @ApiModelProperty(value = "课程类型")
    private Integer type;

    /**
     * 课程总时长
     */
    @ApiModelProperty(value = "课程总时长")
    private Long durations = 0L;

    private String durationsStr;

    /**
     * 用户学习总时长
     */
    @ApiModelProperty(value = "用户学习总时长")
    private Long learnDurations = 0L;

    private String learnDurationStr;

    /**
     * 章节数
     */
    @ApiModelProperty(value = "章节数")
    private Integer chapters = 0;

    /**
     * 学习人数
     */
    @ApiModelProperty(value = "学习人数")
    private Integer learns = 0;

    /**
     * 访问人数
     */
    @ApiModelProperty(value = "访问人数")
    private Integer accessNum = 0;

    /**
     * 适用范围(1. 安全准入考试，2. 负面清单考试，3. 黑名单考试)
     */
    @ApiModelProperty(value = "适用范围")
    private String scopeType;

    /**
     * 适用院系
     */
    @ApiModelProperty(value = "适用院系")
    private String deptIds;

    private String deptNames;

    private List<ElCourseChapter> chapterList;

    private String beginTime;

    private String endTime;

    /**
     * V2.6 增加 0 学习中，2 未学习，3 待考核，1 已完成
     */
    @ApiModelProperty(value = "0 学习中，2 未学习，3 待考核，1 已完成")
    private Integer learnStatus;

    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setCateId(Long cateId) {
        this.cateId = cateId;
    }

    public Long getCateId() {
        return cateId;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public void setLevel(String level) {
        this.level = level;
    }

    public String getLevel() {
        return level;
    }

    public void setOrderRest(Integer orderRest) {
        this.orderRest = orderRest;
    }

    public Integer getOrderRest() {
        return orderRest;
    }

    public void setDuration(Long duration) {
        this.duration = duration;
    }

    public Long getDuration() {
        return duration;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getLabel() {
        return label;
    }

    public void setEffectiveTime(Long effectiveTime) {
        this.effectiveTime = effectiveTime;
    }

    public Long getEffectiveTime() {
        return effectiveTime;
    }

    public void setCeType(Integer ceType) {
        this.ceType = ceType;
    }

    public Integer getCeType() {
        return ceType;
    }

    public Date getCeTime() {
        return ceTime;
    }

    public void setCeTime(Date ceTime) {
        this.ceTime = ceTime;
    }

    public void setKeywords(String keywords) {
        this.keywords = keywords;
    }

    public String getKeywords() {
        return keywords;
    }

    public void setImg(String img) {
        this.img = img;
    }

    public String getImg() {
        return img;
    }

    public String getBeginTime() {
        return beginTime;
    }

    public void setBeginTime(String beginTime) {
        this.beginTime = beginTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getStatus() {
        return status;
    }

    public void setVideoDraggable(Integer videoDraggable) {
        this.videoDraggable = videoDraggable;
    }

    public Integer getVideoDraggable() {
        return videoDraggable;
    }

    public void setPoints(BigDecimal points) {
        this.points = points;
    }

    public BigDecimal getPoints() {
        return points;
    }

    public void setSettings(String settings) {
        this.settings = settings;
    }

    public String getSettings() {
        return settings;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getType() {
        return type;
    }

    public Integer getPri() {
        return pri;
    }

    public void setPri(Integer pri) {
        this.pri = pri;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getChapters() {
        return chapters;
    }

    public void setChapters(Integer chapters) {
        this.chapters = chapters;
    }

    public Integer getLearns() {
        return learns;
    }

    public void setLearns(Integer learns) {
        this.learns = learns;
    }

    public Integer getAccessNum() {
        return accessNum;
    }

    public void setAccessNum(Integer accessNum) {
        this.accessNum = accessNum;
    }

    public Long getDurations() {
        return durations;
    }

    public void setDurations(Long durations) {
        this.durations = durations;
        this.setDurationsStr(durations);
    }

    public List<ElCourseChapter> getChapterList() {
        return chapterList;
    }

    public void setChapterList(List<ElCourseChapter> chapterList) {
        this.chapterList = chapterList;
    }

    public String getCateTitle() {
        return cateTitle;
    }

    public void setCateTitle(String cateTitle) {
        this.cateTitle = cateTitle;
    }

    public BigDecimal getMachinePoints() {
        return machinePoints;
    }

    public void setMachinePoints(BigDecimal machinePoints) {
        this.machinePoints = machinePoints;
    }

    public Long getLearnDurations() {
        return learnDurations;
    }

    public void setLearnDurations(Long learnDurations) {
        this.learnDurations = learnDurations;
        if(learnDurations != null){
            this.setLearnDurationStr(learnDurations);
        }
    }

    public String getDurationsStr() {
        return durationsStr;
    }

    public void setDurationsStr(Long durations) {
        this.durationsStr =  CourcseUtils.getTimeString(Math.toIntExact(durations));
    }

    public String getLearnDurationStr() {
        return learnDurationStr;
    }

    public void setLearnDurationStr(Long learnDurations) {
        this.learnDurationStr = CourcseUtils.getTimeString(Math.toIntExact(learnDurations));
    }

    public String getAllCateTitle() {
        return allCateTitle;
    }

    public void setAllCateTitle(String allCateTitle) {
        this.allCateTitle = allCateTitle;
    }

//    @Override
    public String getQrCodeUrl() {
        return "";
        // TODO 二维码 下个版本做
//        return StrUtil.format(SysProperties.getQrcodeFormat(),id, 4) ;
    }

    public String getScopeType() {
        return scopeType;
    }

    public void setScopeType(String scopeType) {
        this.scopeType = scopeType;
    }

    public String getDeptIds() {
        return deptIds;
    }

    public void setDeptIds(String deptIds) {
        this.deptIds = deptIds;
    }

    public String getDeptNames() {
        return deptNames;
    }

    public void setDeptNames(String deptNames) {
        this.deptNames = deptNames;
    }

    public Integer getLearnStatus() {
        return learnStatus;
    }

    public void setLearnStatus(Integer learnStatus) {
        this.learnStatus = learnStatus;
    }
}
