package cn.cslg.pas.controller.outApi;

import cn.cslg.pas.common.core.base.Constants;
import cn.cslg.pas.common.model.outApi.PatentStarListDto;
import cn.cslg.pas.common.utils.Response;
import cn.cslg.pas.service.OAuth2Service;
import cn.cslg.pas.service.outApi.PatentStarApiService;
import cn.dev33.satoken.stp.StpUtil;
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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

@Tag(name = "专利之星接口服务类")
@RestController
@RequestMapping(Constants.API_VERSION_V2 + "/patentStar")
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class PatentStarController {
    private final PatentStarApiService patentStarApiService;

    @PostMapping("/select")
    @Operation(summary = "一般检索接口")
    public String getAreaList(@RequestBody @Validated PatentStarListDto patentStarListDto) throws IOException {
        Map<String, Object> map = patentStarApiService.patentStarSearchLocal(patentStarListDto);
        return Response.success(map);
//        patentStarApiService.test(patentStarListDto);
//        return Response.success();
    }

    @GetMapping("/getCnBib")
    @Operation(summary = "获得中国专利著录")
    public String getCnBib(String appNo) {
        return patentStarApiService.getCnBibApi(appNo);
    }

    @GetMapping("/getPicture")
    @Operation(summary = "获得中国专利摘要附图")
    public String getPicture(String appNo) {
        return patentStarApiService.getPictureApi(appNo);
    }

    @GetMapping("/getWGPicture")
    @Operation(summary = "获得中国专利外观图")
    public String getWGPicture(String appNo) throws IOException {
        return patentStarApiService.getWGPictureApi(appNo);
    }

    @GetMapping("/getCnLegal")
    @Operation(summary = "获得中国专利法律状态")
    public String getCnLegal(String appNo) {
        return patentStarApiService.getCnLegalApi(appNo);
    }

    @GetMapping("/getCnPdf")
    @Operation(summary = "获得中国专利pdf全文")
    public String getCnPdf(String appNo) throws IOException {
        return patentStarApiService.getCnPdfApi(appNo);
    }

    @GetMapping("/getCnFullXml")
    @Operation(summary = "获得中国专利全文文本")
    public String getCnFullXml(String appNo) throws IOException {
        return patentStarApiService.getCnFullXmlApi(appNo);
    }

    @GetMapping("/getEnPdf")
    @Operation(summary = "获得世界专利pdf")
    public String getEnPdf(String patentNo) throws IOException {
        return patentStarApiService.getEnPdfApi(patentNo);
    }

    @GetMapping("/getENBib")
    @Operation(summary = "获得世界专利著录信息")
    public String getENBib(String patentNo) throws IOException {
        return Response.success(patentStarApiService.getENBibApi(patentNo));
    }

    @GetMapping("/getFamilyByPubNo")
    @Operation(summary = "获得同族专利")
    public String getFamilyByPubNo(String patentNo) {
        return patentStarApiService.getFamilyByPubNoApi(patentNo);
    }

    @GetMapping("/getCitedNumByPubNo")
    @Operation(summary = "获得被引用次数")
    public String getCitedNumByPubNo(String patentNo) throws IOException {
        return patentStarApiService.getCitedNumByPubNoApi(patentNo);
    }
}
