package cn.cslg.report.controller.InvalidReReport;

import cn.cslg.report.common.core.base.Constants;
import cn.cslg.report.common.model.dto.ShareReportDTO;
import cn.cslg.report.common.utils.Response;
import cn.cslg.report.service.business.asso.AssoReportPersonService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * 报告分享管理的Controller层
 *
 * @Author lrj
 * @Data 2023/4/1
 */
@Tag(name = "陈述意见管理")
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping(Constants.REPORT_API + "/arguments")
public class ArgumentsController {
    private final AssoReportPersonService assoReportPersonService;

    @Operation(summary = "添加陈述意见")
    @PostMapping("/add")
    public String add(@RequestBody ShareReportDTO shareReportDTO) {
        Integer flag = assoReportPersonService.shareReport(shareReportDTO);
        return Response.success(flag);
    }

    @Operation(summary = "删除陈述意见")
    @PostMapping("/delete")
    public String delete(@RequestBody ShareReportDTO shareReportDTO) {
        assoReportPersonService.removeShare(shareReportDTO);
        return Response.success();
    }

    @Operation(summary = "修改陈述意见")
    @PostMapping("/update")
    public String update(@RequestBody ShareReportDTO shareReportDTO) throws IOException {
        return Response.success(assoReportPersonService.showShare(shareReportDTO));
    }

    @Operation(summary = "查询陈述意见")
    @PostMapping("/query")
    public String query(@RequestBody ShareReportDTO shareReportDTO) throws IOException {
        return Response.success(assoReportPersonService.showShare(shareReportDTO));
    }
}
