package cn.reghao.tnb.search.esapp.model.po;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.stream.Collectors;

/**
 * @author reghao
 * @date 2025-03-18 09:50:13
 */
@NoArgsConstructor
@Setter
@Getter
public class Wenshu {
    private String id;
    // 原始链接
    private String originalUrl;
    // 案号
    private String caseId;
    // 案件名称
    private String caseName;
    // 法院
    private String court;
    // 所属地区
    private String region;
    // 案件类型
    private String caseType;
    // 案件类型编码
    private String caseTypeId;
    // 来源
    private String source;
    // 审理程序
    private String procedure;
    // 裁判日期
    private String judgmentDate;
    // 发布日期
    private String publicDate;
    // 当事人
    private String parties;
    // 案由
    private String cause;
    // 法律依据
    private String legalBasis;
    // 全文
    private String fullText;

    public Wenshu(WenshuDoc wenshuDoc, WenshuLucene wenshuLucene) {
        this.id = wenshuDoc.getWenshuId() + "";
        this.originalUrl = wenshuDoc.getOriginalUrl();
        this.caseId = wenshuDoc.getCaseId();
        this.caseName = wenshuLucene.getCaseName();
        this.court = wenshuDoc.getCourt();
        this.region = wenshuDoc.getRegion();
        this.caseType = wenshuDoc.getCaseType();
        this.caseTypeId = wenshuDoc.getCaseTypeId();
        this.source = "";
        this.procedure = wenshuDoc.getProcedures();
        this.judgmentDate = wenshuDoc.getJudgmentDate();
        this.publicDate = wenshuDoc.getPublicDate();
        this.parties = wenshuDoc.getParties();
        this.cause = wenshuDoc.getCause();
        //this.legalBasis = wenshuDoc.getLegalBasis();
        this.legalBasis = wenshuDoc.getLegalBasisList().stream()
                .map(WenshuLegal::getLegalBasis)
                .collect(Collectors.toList())
                .toString().replace("[", "").replace("]", "");
        this.fullText = wenshuLucene.getFullText();
    }

    public Wenshu(WenshuDoc wenshuDoc) {
        this.id = wenshuDoc.getWenshuId() + "";
        this.originalUrl = wenshuDoc.getOriginalUrl();
        this.caseId = wenshuDoc.getCaseId();
        this.caseName = wenshuDoc.getCaseName();
        this.court = wenshuDoc.getCourt();
        this.region = wenshuDoc.getRegion();
        this.caseType = wenshuDoc.getCaseType();
        this.caseTypeId = wenshuDoc.getCaseTypeId();
        this.source = "";
        this.procedure = wenshuDoc.getProcedures();
        this.judgmentDate = wenshuDoc.getJudgmentDate();
        this.publicDate = wenshuDoc.getPublicDate();
        this.parties = wenshuDoc.getParties();
        this.cause = wenshuDoc.getCause();
        //this.legalBasis = wenshuDoc.getLegalBasis();
        this.legalBasis = wenshuDoc.getLegalBasisList().stream()
                .map(WenshuLegal::getLegalBasis)
                .collect(Collectors.toList())
                .toString().replace("[", "").replace("]", "");
        this.fullText = "";
    }
}
