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.ProofDetailDTO;
import cn.cslg.report.common.utils.Response;
import cn.cslg.report.service.business.InvalidReReport.ProofDetailService;
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;

@Tag(name = "无效应对证据详情管理")
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping(Constants.REPORT_API + "/proofDetail")
public class ProofDetailController {
    private final ProofDetailService proofDetailService;
    @Operation(summary = "添加证据详情")
    @PostMapping("/addProofDetail")
    public String addProofDetail(@RequestBody ProofDetailDTO proofDetailDTO) throws IOException {
        if(proofDetailDTO != null){
            proofDetailService.addProofDetail(proofDetailDTO);
            return Response.success("添加成功");
        } else {
            return Response.error("添加失败");
        }
    }

    @Operation(summary = "删除证据详情")
    @PostMapping("/deleteProofDetail")
    public String deleteProofDetail(@RequestBody List<Integer> ids)  {
        if(ids != null && ids.size() != 0){
            proofDetailService.deleteProofDetail(ids);
            return Response.success("删除成功");
        } else {
            return Response.error("删除失败");
        }
    }

    @Operation(summary = "修改证据详情")
    @PostMapping("/updateProofDetail")
    public String updateProofDetail(@RequestBody ProofDetailDTO proofDetailDTO) throws IOException {
        if(proofDetailDTO != null){
            proofDetailService.updateProofDetail(proofDetailDTO);
            return Response.success("更新成功");
        } else {
            return Response.error("更新失败");
        }
    }

    @Operation(summary = "查找证据详情")
    @GetMapping("/queryProofDetail")
    public String queryProofDetail(Integer proofId) throws IOException {
        if(proofId != null && proofId > 0) {
            return Response.success(proofDetailService.queryProofDetail(proofId));
        } else {
            return Response.error("查找失败");
        }
    }
}
