package cn.cslg.report.controller.InvalidReReport;

import cn.cslg.report.common.core.base.Constants;
import cn.cslg.report.common.model.dto.ProofAddNewDTO;
import cn.cslg.report.common.model.dto.ReportDTO;
import cn.cslg.report.common.model.dto.ShareReportDTO;
import cn.cslg.report.common.model.dto.invalidReReport.ProofQueryDTO;
import cn.cslg.report.common.utils.Response;
import cn.cslg.report.service.business.InvalidReReport.ProofService;
import cn.cslg.report.service.business.asso.AssoReportPersonService;
import com.alibaba.fastjson.JSONObject;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.mail.Multipart;
import java.io.IOException;
import java.util.List;

/**
 * 文献证据的Controller层
 *
 * @Author lrj
 * @Data 2023/4/1
 */
@Tag(name = "文献证据管理")
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping(Constants.REPORT_API + "/proof")
public class ProofController {
    private final ProofService proofService;

//    @Operation(summary = "上传专利文献证据（文件）")
//    @PostMapping("/addPatentProofByFile")
//    public String addPatentProofByFile(@RequestBody ShareReportDTO shareReportDTO) {
//        proofService.addPatentProofByFile()
//        return Response.success(flag);
//    }


    @Operation(summary = "上传非专利文献证据")
    @PostMapping("/addProofByFile")
    public String addProofByFile(String proofAddNewDTOStr, List<MultipartFile> files) {
        ProofAddNewDTO proofAddNewDTO = JSONObject.parseObject(proofAddNewDTOStr, ProofAddNewDTO.class);
        log.info("开始处理【上传非专利文献证据】的请求，请求参数为：{}, {}", proofAddNewDTO, files);
        proofService.addProofByFile(proofAddNewDTO, files);
        return Response.success();
    }


    //    @Operation(summary = "上传专利文献证据（专利号）")
//    @PostMapping("/addPatentFile")
//    public String addPatentFile(@RequestBody ShareReportDTO shareReportDTO) throws IOException {
//        return Response.success(assoReportPersonService.showShare(shareReportDTO));
//    }
    @Operation(summary = "查询专利文献列表")
    @PostMapping("/queryProof")
    public String queryProof(@RequestBody ProofQueryDTO proofAddNewDTO) {
        return proofService.queryProof(proofAddNewDTO);
    }

}
