package com.playlet.system.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.playlet.common.core.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.playlet.common.annotation.Excel;

import java.util.Date;

/**
 * @Date: 2024-03-22 11:56
 * @Author: 但星霖
 * @Version: v1.0
 * @Description: 短剧用户任务对象 playlet_user_task
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName(value = "playlet_user_task")
public class PlayletUserTask extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 短剧用户任务主键id
     */
    @ApiModelProperty(value = "短剧用户任务主键id")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 任务id
     */
    @ApiModelProperty(value = "任务id")
    @Excel(name = "任务id")
    private Long taskId;

    @ApiModelProperty(value = "任务详情")
    @TableField(exist = false)
    private PlayletTask playletTask;

    /**
     * 用户Id
     */
    @ApiModelProperty(value = "用户Id")
    @Excel(name = "用户Id")
    private String userId;

    /**
     * 用户任务状态
     */
    @ApiModelProperty(value = "用户任务状态 0 未开始 1 已开始 2 已结束 3 已失效 4 已完成")
    @Excel(name = "用户任务状态 0 未开始 1 已开始 2 已结束 3 已失效 4 已完成")
    private Integer userTaskState;

    /**
     * 任务开始时间
     */
    @ApiModelProperty(value = "任务开始时间")
    @Excel(name = "任务开始时间")
    private Date taskStartTime;

    /**
     * 任务结束时间
     */
    @ApiModelProperty(value = "任务结束时间")
    @Excel(name = "任务结束时间")
    private Date taskEndTime;

    public static PlayletUserTask dataSupplement(PlayletTask task){
        PlayletUserTask userTask = new PlayletUserTask();
        userTask.setTaskId(task.getId());
        userTask.setUserId(task.getUserId());
        userTask.setUserTaskState(0);
        userTask.setCreateBy(task.getUserId());
        userTask.setUpdateBy(task.getUserId());
        userTask.setTaskStartTime(task.getStartTime());
        userTask.setTaskEndTime(task.getEndTime());
        userTask.setCreateTime(new Date());
        userTask.setUpdateTime(new Date());
        return userTask;
    }
}
