package cn.cslg.report.controller;

import cn.cslg.report.common.core.base.Constants;
import cn.cslg.report.entity.InvalidRecord;
import cn.cslg.report.entity.LitigationHistory;
import cn.cslg.report.service.business.InvalidRecordService;
import cn.cslg.report.service.business.ReportFileService;
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 + "/InvalidRecord")
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class InvalidRecordController {
    public final InvalidRecordService invalidRecordService;
    @RequestMapping(value = "/addInvalidRecord", method = RequestMethod.POST)
    @Operation(summary = "增加无效记录")
    public  String addInvalidRecord(InvalidRecord invalidRecord, List<MultipartFile> file) throws IOException{

        return invalidRecordService.addInvalidRecord(invalidRecord,file);
    }
    @RequestMapping(value = "/updateInvalidRecord", method = RequestMethod.POST)
    @Operation(summary = "修改无效记录")
    @Transactional(rollbackFor = Exception.class)
    public String updateInvalidRecord(@RequestBody InvalidRecord invalidRecord)throws IOException{
        return invalidRecordService.updateInvalidRecord(invalidRecord);

    }
    @GetMapping(value = "/deleInvalidRecord")
    @Operation(summary = "删除无效记录")
    public String deleInvalidRecord(int id)throws IOException{
        return invalidRecordService.deleteInvalidRecord(id);
    }

    @PostMapping(value = "/queryInvalidRecord")
    @Operation(summary = "查询无效记录")
    @Transactional(rollbackFor = Exception.class)
    public String queryInvalidRecord(@RequestBody InvalidRecord invalidRecord)throws IOException{
        return invalidRecordService.queryInvalidRecord(invalidRecord);
    }


}
