package cn.cslg.report.controller;

import cn.cslg.report.common.core.base.Constants;
import cn.cslg.report.entity.LitigationHistory;
import cn.cslg.report.service.business.LitigationHistoryService;
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.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

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

@Tag(name = "诉讼历史")
@RestController
@RequestMapping(Constants.REPORT_API + "/LitigationHistory")
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class LitigationHistoryController {
    public final LitigationHistoryService litigationHistoryService;
    @GetMapping(value = "/deleteLitigationHistory")
    @Operation(summary = "删除诉讼历史")
    public String deleteLitigationHistory(int id)throws IOException{
        return litigationHistoryService.deleteLitigationHistory(id);
    }
    @PostMapping(value = "/addLitigationHistory")
    @Operation(summary = "增加诉讼历史")
    public String addLitigationHistory( LitigationHistory litigationHistory, List<MultipartFile> file)throws IOException{
        return litigationHistoryService.addLitigationHistory(litigationHistory,file);
    }
    @PostMapping(value = "/updateLitigationHistory")
    @Operation(summary = "修改诉讼历史")
    @Transactional(rollbackFor = Exception.class)
    public String updateLitigationHistory(@RequestBody LitigationHistory litigationHistory)throws IOException{
        return litigationHistoryService.updateLitigationHistory(litigationHistory);
    }

    @PostMapping(value = "/queryLitigationHistory")
    @Operation(summary = "查询诉讼历史")
    @Transactional(rollbackFor = Exception.class)
    public String queryLitigationHistory(@RequestBody LitigationHistory litigationHistory)throws IOException{
        return litigationHistoryService.queryLitigationHistory(litigationHistory);
    }
}
