package thyyxxk.webserver.entity.archive;

import java.io.Serializable;
import java.util.List;

import com.baomidou.mybatisplus.annotation.TableId;
import lombok.*;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import thyyxxk.webserver.service.archive.TaskPatient;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "patient_archive")
public class PatientArchive implements Serializable {


    private static final long serialVersionUID = 5110111070376944721L;

    /**
     * id
     */
    @TableId
    private String id;

    /**
     * patNo
     */
    @TableField(value = "pat_no")
    private String patNo;

    /**
     * times
     */
    @TableField(value = "times")
    private Integer times;

    @TableField(value = "create_id")
    private String createId;
    /**
     * 第三方的唯一id
     */
    @TableField(value = "document_id")
    private String documentId;


    /**
     * 文件名字
     */
    @TableField(value = "name")
    private String name;

    /**
     * 是否文件夹
     */
    @TableField(value = "is_dir")
    @Builder.Default
    private Boolean isDir = Boolean.FALSE;

    /**
     * parentId
     */
    @TableField(value = "parent_id")
    private String parentId;

    /**
     * 文件路径，如果是空的就说明生成错误
     */
    @TableField(value = "path")
    private String path;

    /**
     * 1-电子病历  2-病案首页  3-检验
     */
    @TableField(value = "type")
    private Integer type;

    /**
     * sort
     */
    @TableField(value = "sort")
    private Integer sort;

    /**
     * 一些其他信息
     */
    @TableField(value = "info")
    private String info;

    @TableField(exist = false)
    private List<PatientArchive> children;

    public static LambdaQueryWrapper<PatientArchive> lambdaQueryWrapper() {
        return new LambdaQueryWrapper<>();
    }

    public static QueryWrapper<PatientArchive> queryWrapper() {
        return new QueryWrapper<>();
    }

    public static PatientArchiveBuilder defaultData(TaskPatient data) {
        return PatientArchive.builder()
                .patNo(data.getPatNo())
                .times(data.getTimes())
                .createId(data.getSubmitCode());
    }

}
