package cn.cslg.report.controller;

import cn.cslg.report.common.core.base.Constants;
import cn.cslg.report.entity.InvalidRecord;
import cn.cslg.report.entity.ReviewHistory;
import cn.cslg.report.service.business.InvalidRecordService;
import cn.cslg.report.service.business.ReviewHistoryService;
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 + "/reviewHistory")
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class ReviewHistoryController {
    public final ReviewHistoryService reviewHistoryService;
    @RequestMapping(value = "/addReviewHistory", method = RequestMethod.POST)
    @Operation(summary = "增加审查历史")
    public  String addInvalidRecord(ReviewHistory reviewHistory,List<MultipartFile> files) throws IOException{
        return reviewHistoryService.addReviewHistory(reviewHistory,files);
    }
    @RequestMapping(value = "/updateReviewHistory", method = RequestMethod.POST)
    @Operation(summary = "修改审查历史")
    @Transactional(rollbackFor = Exception.class)
    public String updateInvalidRecord(@RequestBody ReviewHistory reviewHistory)throws IOException{
        return reviewHistoryService.updateReviewHistory(reviewHistory);

    }
    @GetMapping(value = "/deleReviewHistory")
    @Operation(summary = "删除审查历史")
    public String deleInvalidRecord(int id)throws IOException{
        return reviewHistoryService.deleteReviewHistory(id);
    }
    @PostMapping(value = "/queryReviewHistory")
    @Operation(summary = "查询审查历史")
    @Transactional(rollbackFor = Exception.class)
    public String queryInvalidRecord(@RequestBody ReviewHistory reviewHistory)throws IOException{
        return reviewHistoryService.queryReviewHistory(reviewHistory);
    }


}
