package com.ruoyi.project.business.domain.vo.train;

import com.ruoyi.project.business.domain.train.TtFileDatabase;
import com.ruoyi.project.business.domain.train.TtTrain;
import com.ruoyi.project.business.domain.train.TtTrainFile;
import com.ruoyi.project.business.domain.train.TtTrainTarget;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @author : fangk
 * @date : 2024/7/5 13:53
 * @desc : TODO
 */

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Accessors(chain = true)
public class TrainFileDetailRes {
    /**
     * ID
     */
    private Long id;

    /**
     * 资料ID
     */
    private Long fileId;

    /**
     * 培训ID
     */
    private Long trainId;

    private TtFileDatabase file;

    private TtTrain train;

    /**
     * tt_train_target 表更新时间 用于checkData
     */
    private Date updateTime;

    public static TrainFileDetailRes from(TtTrainFile ttTrainFile, TtFileDatabase file, TtTrain train, TtTrainTarget ttTrainTarget) {
        return TrainFileDetailRes.builder()
                .id(ttTrainFile.getId())
                .fileId(ttTrainFile.getFileId())
                .trainId(ttTrainFile.getTrainId())
                .file(file)
                .train(train)
                .updateTime(ttTrainTarget.getUpdateTime())
                .build();
    }

    public static TrainFileDetailRes from( TtTrainTarget ttTrainTarget) {
        return TrainFileDetailRes.builder()
                .updateTime(ttTrainTarget.getUpdateTime())
                .build();
    }
}
