
package cn.orionsec.ops.entity.exporter;

import cn.orionsec.kit.lang.utils.convert.TypeStore;
import cn.orionsec.kit.office.excel.annotation.ExportField;
import cn.orionsec.kit.office.excel.annotation.ExportSheet;
import cn.orionsec.kit.office.excel.annotation.ExportTitle;
import cn.orionsec.ops.entity.domain.FileTailListDO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel(value = "日志文件导出")
@ExportTitle(title = "日志文件导出")
@ExportSheet(name = "日志文件", titleHeight = 22, headerHeight = 22, freezeHeader = true, filterHeader = true)
public class MachineTailFileExportDTO {

    @ApiModelProperty(value = "机器名称")
    @ExportField(index = 0, header = "机器名称", width = 20, wrapText = true)
    private String machineName;

    @ApiModelProperty(value = "机器标识")
    @ExportField(index = 1, header = "机器标识", width = 20, wrapText = true)
    private String machineTag;

    @ApiModelProperty(value = "文件别名")
    @ExportField(index = 2, header = "文件别名", width = 20, wrapText = true)
    private String name;

    @ApiModelProperty(value = "文件路径")
    @ExportField(index = 3, header = "文件路径", width = 50, wrapText = true)
    private String path;

    @ApiModelProperty(value = "文件编码")
    @ExportField(index = 4, header = "文件编码", width = 12)
    private String charset;

    @ApiModelProperty(value = "尾部偏移行")
    @ExportField(index = 5, header = "尾部偏移行", width = 12)
    private Integer offset;

    @ApiModelProperty(value = "执行命令")
    @ExportField(index = 6, header = "执行命令", width = 35, wrapText = true)
    private String command;

    @ApiModelProperty(value = "机器id", hidden = true)
    private Long machineId;

    static {
        TypeStore.STORE.register(FileTailListDO.class, MachineTailFileExportDTO.class, p -> {
            MachineTailFileExportDTO dto = new MachineTailFileExportDTO();
            dto.setMachineId(p.getMachineId());
            dto.setName(p.getAliasName());
            dto.setPath(p.getFilePath());
            dto.setCharset(p.getFileCharset());
            dto.setOffset(p.getFileOffset());
            dto.setCommand(p.getTailCommand());
            return dto;
        });
    }

}
