package cn.cslg.report.controller;

import cn.cslg.report.common.core.base.Constants;
import cn.cslg.report.common.model.dto.AvoidDesignDirectionDTO;
import cn.cslg.report.common.model.dto.ShareReportDTO;
import cn.cslg.report.common.model.vo.AvoidDesignWholeVO;
import cn.cslg.report.common.utils.Response;
import cn.cslg.report.exception.XiaoShiException;
import cn.cslg.report.service.IAvoidDesignDirectionService;
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.*;

import java.io.IOException;

/**
 * 报告分享管理的Controller层
 *
 * @Author lrj
 * @Data 2023/4/1
 */
@Tag(name = "报告分享管理")
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping(Constants.REPORT_API + "/shareReport")
public class AssoReportPersonController {
    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("/remove")
    public String remove(@RequestBody ShareReportDTO shareReportDTO) {
        assoReportPersonService.removeShare(shareReportDTO);
        return Response.success();
    }

    @Operation(summary = "展示分享人")
    @PostMapping("/showShare")
    public String showShare(@RequestBody ShareReportDTO shareReportDTO) throws IOException {

        return Response.success(assoReportPersonService.showShare(shareReportDTO));
    }

}
