package cn.cslg.report.controller.InvalidReReport;

import cn.cslg.report.common.core.base.Constants;
import cn.cslg.report.common.model.dto.ShareReportDTO;
import cn.cslg.report.common.model.dto.invalidReReport.ArgumentsDTO;
import cn.cslg.report.common.model.dto.invalidReReport.ArgumentsDetailsDTO;
import cn.cslg.report.common.model.dto.invalidReReport.ArgumentsListDTO;
import cn.cslg.report.common.utils.Response;
import cn.cslg.report.entity.invalidReReport.AssoFeatureProof;
import cn.cslg.report.service.business.AssoRecordsFeatureService;
import cn.cslg.report.service.business.InvalidReReport.ArgumentsService;
import cn.cslg.report.service.business.InvalidReReport.AssoFeatureProofService;
import cn.cslg.report.service.business.asso.AssoReportPersonService;
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.*;

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

/**
 * 报告分享管理的Controller层
 *
 * @Author lrj
 * @Data 2023/4/1
 */
@Tag(name = "陈述意见管理")
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping(Constants.REPORT_API + "/arguments")
public class ArgumentsController {
    private final AssoReportPersonService assoReportPersonService;
    private final ArgumentsService argumentsService;
    private final AssoFeatureProofService assoFeatureProofService;

    @Operation(summary = "添加陈述意见")
    @PostMapping("/addArguments")
    public String addArguments(@RequestBody ArgumentsDTO argumentsDTO) throws IOException {
        return argumentsService.addArguments(argumentsDTO);
    }

    @Operation(summary = "删除陈述意见")
    @PostMapping("/deleteArguments")
    public String deleteArguments(@RequestBody List<Integer> argumentsIds) {
        argumentsService.deleteArguments(argumentsIds);
        return Response.success("删除成功");
    }

    @Operation(summary = "修改陈述意见")
    @PostMapping("/updateArgument")
    public String updateArgument(@RequestBody ArgumentsDetailsDTO argumentsDTO) throws IOException {
        return argumentsService.updateArgument(argumentsDTO);
    }

    @Operation(summary = "查询陈述意见划词详情")
    @GetMapping("/queryScratchs")
    public String query(Integer proofId) throws IOException {
        return Response.success(argumentsService.queryScratchs(proofId));
    }

    @Operation(summary = "批量添加或更新陈述意见")
    @PostMapping("/addOrUpdatePoofArguments")
    public String addOrUpdatePoofArguments(@RequestBody List<ArgumentsListDTO> argumentsListDTOS) {
        return argumentsService.addOrUpdatePoofArguments(argumentsListDTOS);
    }

    @Operation(summary = "查询陈述意见列表")
    @GetMapping("/queryPoofArguments")
    public String queryPoofArguments(Integer proofId, Integer rightSort, Integer reportId) throws IOException {
        return Response.success(argumentsService.queryPoofArguments(proofId, rightSort, reportId));
    }

    @Operation(summary = "根据特征查询相关证据")
    @GetMapping("/queryProofStr")
    public String queryProofStr(Integer proofId, Integer featureId) throws IOException {
        return Response.success(assoFeatureProofService.queryProofStr(proofId, featureId));
    }

}
