package cn.cslg.report.controller;

import cn.cslg.report.common.core.base.Constants;
import cn.cslg.report.common.model.vo.CompareRecordsVO;
import cn.cslg.report.common.utils.Response;
import cn.cslg.report.common.utils.SecurityUtils.LoginUtils;
import cn.cslg.report.entity.CompareRecords;
import cn.cslg.report.service.business.CompareRecordsService;
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 java.io.IOException;

@Tag(name = "对比记录")
@RestController
@RequestMapping(Constants.REPORT_API + "/CompareRecords")
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class CompareRecordsController {
    private final CompareRecordsService compareRecordsService;
    private  final  LoginUtils loginUtils;

    @PostMapping(value = "/addCompareRecords")
    @Operation(summary = "增加对比记录数据")
    public String addCompareRecords(@RequestBody CompareRecords compareRecords)throws IOException{
        return compareRecordsService.addCompareRecord(compareRecords);
    }
    @RequestMapping(value = "/deleCompareRecords", method = RequestMethod.GET)
    @Operation(summary = "删除对比记录数据")
    public String deleCompareRecords(int id) throws IOException{
        return compareRecordsService.deleCompareRecords(id);
    }

    @PostMapping(value = "/updateCompareRecords")
    @Operation(summary = "修改对比记录数据")
    @Transactional(rollbackFor = Exception.class)
    public String updateCompareRecords(@RequestBody CompareRecords compareRecord) throws IOException{
        return compareRecordsService.updateCompareRecords(compareRecord);

    }
    @PostMapping(value = "/selectCompareRecord")
    @Operation(summary ="查询对比记录")
    public String getCompareRecords(@RequestBody CompareRecords compareRecord)throws IOException{
      return compareRecordsService.getCompareRecords(compareRecord);
    }

    }




