package com.zd.exam.domain;

import javax.validation.constraints.NotNull;

import com.zd.common.core.valid.ValidGroup;
import com.zd.exam.util.CourcseUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.zd.common.core.web.domain.BaseEntity;
import org.hibernate.validator.constraints.Length;

import java.util.Date;

/**
 * 学习记录对象 el_chapter_learn_record
 *
 * @author liubo
 * @date 2021-12-07
 */
@ApiModel("学习记录")
public class ElChapterLearnRecord extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    @ApiModelProperty(value = "${comment}")
    private Long id;
    /**
     * 课程id
     */
    @Excel(name = "课程id")
    @NotNull(groups = ValidGroup.Crud.Create.class, message = "课程id不能为空")
    @ApiModelProperty(value = "课程id")
    private Long courseId;
    /**
     * 章节id
     */
    @Excel(name = "章节id")
    @NotNull(groups = ValidGroup.Crud.Create.class, message = "章节id不能为空")
    @ApiModelProperty(value = "章节id")
    private Long chapterId;
    /**
     * 用户id
     */
    @Excel(name = "用户id")
    @ApiModelProperty(value = "用户id")
    private Long joinUserId;
    /**
     * 学习状态
     */
    @Excel(name = "学习状态")
    @ApiModelProperty(value = "学习状态")
    private Integer status;
    /**
     * 学习进度
     */
    @Excel(name = "学习进度")
    @ApiModelProperty(value = "学习进度")
    private Long progress;
    /**
     * 有效学习
     */
    @Excel(name = "有效学习")
    @ApiModelProperty(value = "有效学习")
    private Long duration;

    private String durationStr;

    /**
     * 总学习数
     */
    @Excel(name = "总学习数")
    @ApiModelProperty(value = "总学习数")
    private Integer totalEff;
    /**
     * 当前练习
     */
    @Excel(name = "当前练习")
    @ApiModelProperty(value = "当前练习")
    private Integer currentExer;
    /**
     * 开始时间
     */
    @Excel(name = "开始时间")
    @ApiModelProperty(value = "开始时间")
    private Date startTime;
    /**
     * 完成时间
     */
    @Excel(name = "完成时间")
    @ApiModelProperty(value = "完成时间")
    private Date lastTime;
    /**
     * 观看断点时间
     */
    @Excel(name = "观看断点时间")
    @ApiModelProperty(value = "观看断点时间")
    private Long watchTime;

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

    public Long getId() {
        return id;
    }

    public void setChapterId(Long chapterId) {
        this.chapterId = chapterId;
    }

    public Long getChapterId() {
        return chapterId;
    }

    public void setJoinUserId(Long joinUserId) {
        this.joinUserId = joinUserId;
    }

    public Long getJoinUserId() {
        return joinUserId;
    }

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

    public Integer getStatus() {
        return status;
    }

    public void setProgress(Long progress) {
        this.progress = progress;
    }

    public Long getProgress() {
        return progress;
    }

    public Long getDuration() {
        return duration;
    }

    public void setDuration(Long duration) {
        this.duration = duration;
        if(duration != null){
            this.setDurationStr(duration);
        }
    }

    public void setCurrentExer(Integer currentExer) {
        this.currentExer = currentExer;
    }

    public Integer getCurrentExer() {
        return currentExer;
    }

    public void setWatchTime(Long watchTime) {
        this.watchTime = watchTime;
    }

    public Long getWatchTime() {
        return watchTime;
    }

    public Long getCourseId() {
        return courseId;
    }

    public void setCourseId(Long courseId) {
        this.courseId = courseId;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getLastTime() {
        return lastTime;
    }

    public void setLastTime(Date lastTime) {
        this.lastTime = lastTime;
    }

    public Integer getTotalEff() {
        return totalEff;
    }

    public void setTotalEff(Integer totalEff) {
        this.totalEff = totalEff;
    }

    public String getDurationStr() {
        return durationStr;
    }

    public void setDurationStr(Long duration) {
        this.durationStr = CourcseUtils.getTimeString(Math.toIntExact(duration));
    }
}
