package com.hz.pm.sync.open.controller;

import com.hz.pm.sync.open.manage.IrsManage;
import com.hz.pm.sync.open.manage.ProjectReceiveManage;
import com.hz.pm.sync.scheduler.model.dto.ForwardDTO;
import com.hz.pm.sync.scheduler.model.dto.ProjectBaseInfoDTO;
import com.hz.pm.sync.scheduler.model.dto.ProjectSaveDTO;
import com.ningdatech.basic.model.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Classname ProjectCollectionController
 * @Description
 * @Date 2023/6/25 9:11
 * @Author PoffyZhang
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "项目归集控制器")
@RequestMapping("/open/api/v1/project-receive")
public class ProjectReceiveController {

    private final ProjectReceiveManage receiveManage;

    private final IrsManage irsManage;

    @PostMapping("/save")
    @ApiOperation("项目归集接收")
    public ApiResponse<String> save(@Valid @RequestBody ProjectSaveDTO dto) {
        return ApiResponse.ofSuccess(receiveManage.save(dto));
    }

    @PostMapping("/not-effective")
    @ApiOperation("项目归集置为无效")
    public ApiResponse<String> notEffective(@Valid @RequestBody ProjectBaseInfoDTO baseinfo) {
        return ApiResponse.ofSuccess(receiveManage.notEffective(baseinfo));
    }

    @PostMapping("/delete-all")
    @ApiOperation("清空当前表数据")
    public ApiResponse<String> deleteAll() {
        return ApiResponse.ofSuccess(receiveManage.deleteAll());
    }

    @ApiOperation(value = "转发IRS请求", notes = "转发IRS请求 用于")
    @PostMapping("/forward")
    public String forward(@Valid @RequestBody ForwardDTO dto) {
        return irsManage.forward(dto);
    }
}
