package com.izouma.zhirongip.dto;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.metadata.BaseRowModel;
import com.izouma.zhirongip.domain.resource.IntellectualProperty;
import com.izouma.zhirongip.utils.excel.LocalDateConverter;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDate;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel(value = "知产")
public class IntellectualPropertyDTO extends BaseRowModel {

    @ExcelProperty(value = "专利区分")
    private String type;

    @ExcelProperty(value = "专利名称")
    private String name;

    @ExcelProperty(value = "法律状态")
    private String lawStatus;

    @ExcelProperty(value = "行业分类")
    private String industryClassName;

    @ExcelProperty(value = "专利代理机构")
    private String agency;

    @ExcelProperty(value = "代理人")
    private String agent;

    @ExcelProperty(value = "申请主体")
    private String applyMain;

    @ExcelProperty(value = "申请人")
    private String applyName;

    @ExcelProperty(value = "申请日", converter = LocalDateConverter.class)
    private LocalDate applyTime;

    @ExcelProperty(value = "授权公告日", converter = LocalDateConverter.class)
    private LocalDate authTime;

    @ExcelProperty(value = "公开号")
    private String openCode;

    @ExcelProperty(value = "申请号")
    private String code;

    @ExcelProperty(value = "发明人")
    private String inventor;

    @ExcelProperty(value = "IPC分类")
    private String ipc;

    @ExcelProperty(value = "专利权人")
    private String owner;

    @ExcelProperty(value = "专利权人地址")
    private String ownerOneAddr;

    @ExcelProperty(value = "技术分类1")
    private String techOne;

    @ExcelProperty(value = "摘要")
    private String digest;

    @ExcelProperty(value = "摘要附图")
    private String img;

    @ExcelProperty(value = "权利要求书")
    private String manual;

    @ExcelProperty(value = "发布时间", converter = LocalDateConverter.class)
    private LocalDate issue;

    @ExcelProperty(value = "word")
    private String wordUrl;

    @ExcelProperty(value = "pdf")
    private String pdfUrl;

    public IntellectualPropertyDTO(IntellectualProperty ip) {
        BeanUtil.copyProperties(ip, this);
        this.inventor = String.join(",", ip.getInventor());
        this.ipc = String.join(",", ip.getIpc());
    }
}
