package cn.cslg.report.controller;

import cn.cslg.report.common.core.base.Constants;

import cn.cslg.report.common.model.dto.CompareOrderDTO;
import cn.cslg.report.common.model.vo.PatentIndexSettingVO;

import cn.cslg.report.common.utils.Response;

import cn.cslg.report.service.business.CompareFilesService;


import cn.cslg.report.service.business.ReportFieldPatentLinkService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;



@Tag(name = "初选")
@RestController
@RequestMapping(Constants.REPORT_API + "/CompareFiles")
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class CompareFilesController {
    private final CompareFilesService compareFilesService;
    private final ReportFieldPatentLinkService fieldPatentLinkService;

    @GetMapping("/index/setting/all")
    @Operation(summary ="获取当前所有的,传过来报告（int）id，和（String）专利号")
    public String settingAll(Integer reportId, String patentNos)throws IOException{
         return Response.success(compareFilesService.setAll(reportId,patentNos));
    }
    @PostMapping("/index/setting")
    @Operation(summary = "获取专利标引情况")
    public String getPatentIndexSetting(@RequestBody PatentIndexSettingVO params) throws IOException {
            compareFilesService.getPatentIndexSetting(params);
       return Response.success();
    }
    @PostMapping("/index/setting/update")
    @Operation(summary = "获取专利标引情况")
    public String getPatentIndexSetting2(@RequestBody PatentIndexSettingVO params) throws IOException {
        fieldPatentLinkService.updatePatentIndexSetting2(params);
        return Response.success();
    }

@PostMapping("/order/add")
@Operation(summary = "给对比专利添加顺序")
public String addOrder(@RequestBody CompareOrderDTO compareOrderDTO) throws IOException {
    compareFilesService.addOrder(compareOrderDTO);
    return Response.success();
}
    @GetMapping("/order/query")
    @Operation(summary = "查找顺序列表")
    public String getOrder(Integer reportId) throws IOException {
        return Response.success(compareFilesService.getOrder(reportId));
    }


}
