
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.constant.webhook.WebhookType;
import cn.orionsec.ops.entity.domain.WebhookConfigDO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel(value = "webhook导出")
@ExportTitle(title = "webhook导出")
@ExportSheet(name = "webhook", height = 22, freezeHeader = true, filterHeader = true)
public class WebhookExportDTO {

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

    /**
     * @see WebhookType
     */
    @ApiModelProperty(value = "类型")
    @ExportField(index = 1, header = "类型", width = 20, wrapText = true)
    private String type;

    @ApiModelProperty(value = "url")
    @ExportField(index = 2, header = "url", width = 80, wrapText = true)
    private String url;

    static {
        TypeStore.STORE.register(WebhookConfigDO.class, WebhookExportDTO.class, p -> {
            WebhookExportDTO dto = new WebhookExportDTO();
            dto.setName(p.getWebhookName());
            dto.setType(WebhookType.of(p.getWebhookType()).getLabel());
            dto.setUrl(p.getWebhookUrl());
            return dto;
        });
    }

}
