package cn.cslg.report.controller;

import cn.cslg.report.common.core.base.Constants;
import cn.cslg.report.common.model.vo.PatentRightVo;
import cn.cslg.report.common.model.vo.PatentVO;
import cn.cslg.report.common.utils.Response;
import cn.cslg.report.entity.Features;
import cn.cslg.report.entity.Report;
import cn.cslg.report.service.business.FeatureService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@Tag(name = "特征管理")
@RestController
@RequestMapping(Constants.REPORT_API + "/feature")
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class FeatureController {
    private final FeatureService featureService;

    @RequestMapping(value = "/splitPatentRight", method = RequestMethod.GET)
    @Operation(summary = "拆分权要")
    @Parameters(value = {
            @Parameter(name = "patentNo",description = "专利号",required = true),
            @Parameter(name = "splitType",description = "拆分类型（0仅拆主权要，1全部拆分）"),
            @Parameter(name = "splitBy",description = "拆分符号（0  ','，1';',2','和';'）"),
            @Parameter(name = "ReportId",description = "报告Id"),
    })
    public String splitPatentRight(String patentNo,Integer splitType ,Integer splitBy,Integer ReportId) throws IOException {
     String res =   featureService.splitPatentRight(patentNo,splitType,splitBy,ReportId);
        return res;
    }
    @RequestMapping(value = "/getFeatures", method = RequestMethod.GET)
    @Operation(summary = "获得报告创建人查询的特征")
    @Parameters(value = {
            @Parameter(name = "patentNo",description = "专利号",required = true),
            @Parameter(name = "ReportId",description = "报告Id"),
    })
    public String getFeatures(String patentNo,Integer reportId) throws IOException {
        String res =   featureService.getFeatures(patentNo,reportId);
        return res;
    }
    @RequestMapping(value = "/addPatentRight", method = RequestMethod.POST)
    @Operation(summary = "保存权要")
    public String addPatentRight(@RequestBody List<PatentRightVo>  patentRightVos) throws IOException {
        String res =  featureService.addFeatures(patentRightVos);
        return res;
    }

    @RequestMapping(value = "/querySimFeaturePatent", method = RequestMethod.POST)
    @Operation(summary = "获得相似特征的专利号")
    public String querySimFeaturePatent(@RequestBody PatentVO patentVO) throws IOException {
        String res =  featureService.querySimFeaturePatent(patentVO);
        return res;
    }

}