package com.rongwei.bsentity.vo;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * KBResultVo class
 *
 * @author XH
 * @date 2024/01/12
 */
@Data
public class KBResultVo {
    // 业务数据ID
    private String dataId;
    // 菜单ID
    private String menuId;
    // 菜单名称
    private String menuName;
    // 子系统id
    private String systemId;
    // 子系统名称
    private String systemName;
    // 搜索出的内容
    private String searchResult="";
    // 菜单的数据配置ID
    private String pagePartId;

    private String createDate;
    /**
     * 标题
     */
    private List<String> searchTitleList = new ArrayList<>();
    /**
     * 内容
     */
    private List<String> searchContentList =  new ArrayList<>();

    public void setSearchResult(String searchResult) {
        this.searchResult =searchResult;
        if(StringUtils.isBlank(searchResult)){
            return;
        }
        this.searchTitleList = Arrays.stream(searchResult.split("-@-")).filter(info->info.contains("-;-"))
                .flatMap(info-> Stream.of(info.split("\\^_\\^")))
                .map(info->info.split("-;-")[0]).collect(Collectors.toList());
        this.searchContentList = Arrays.stream(searchResult.split("-@-")).filter(info->!info.contains("-;-")).collect(Collectors.toList());
    }
}
