package cn.cslg.report.controller;

import cn.cslg.report.common.core.base.Constants;
import cn.cslg.report.common.model.vo.CompareScenariosVO;
import cn.cslg.report.common.utils.Response;
import cn.cslg.report.service.business.CompareScenariosService;

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.web.bind.annotation.*;

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


@Tag(name = "对比方案")
@RestController
@RequestMapping(Constants.REPORT_API + "/CompareScenariosController")
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
public class CompareScenariosController {
    private final CompareScenariosService compareScenariosService;

    @PostMapping("/addCompareScenarios")
    @Operation(summary = "增加对比方案")
    public String add(@RequestBody CompareScenariosVO compareScenariosVO) throws IOException {
        return compareScenariosService.add(compareScenariosVO);
    }

    @GetMapping("/select")
    @Operation(summary = "查询对比方案")
    public String select(int reportID) throws IOException {
        return compareScenariosService.select(reportID);
    }

    @PostMapping(value = "/delete", produces = "application/json")
    @Operation(summary = "删除对比方案")
    public String delete(@RequestBody List<Integer> scenIds) throws IOException {
        Boolean flag = compareScenariosService.deleteById(scenIds);
        if (flag) {
            return Response.success("删除成功");
        } else {
            return Response.error("删除失败");
        }

    }
}