package com.ningdatech.pmapi.projectdeclared.controller;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.projectdeclared.model.dto.DefaultDeclaredDTO;
import com.ningdatech.pmapi.projectdeclared.model.req.AdjustmentListReq;
import com.ningdatech.pmapi.projectdeclared.manage.ProjectAdjustmentManage;
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage;
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * @Classname ConstructionPlanController
 * @Description 建设方案申报
 * @Date 2023/2/13 9:53
 * @Author PoffyZhang
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/api/v1/project/adjustment")
@Api(value = "ProjectAdjustment", tags = "申报管理-项目内容调整")
@RequiredArgsConstructor
public class ProjectAdjustmentController {

    private final ProjectAdjustmentManage projectAdjustmentManage;

    @ApiOperation(value = "可做项目内容调整的列表", notes = "可做项目内容调整的列表")
    @GetMapping("/list")
    public PageVo<ProjectLibListItemVO> list(@Validated @ModelAttribute AdjustmentListReq preReq) {
        return projectAdjustmentManage.projectLibList(preReq);
    }

    @ApiOperation(value = "项目内容调整", notes = "项目内容调整")
    @PostMapping
    public String startTheProcess(@Validated @RequestBody DefaultDeclaredDTO dto) {
        String instanceId = projectAdjustmentManage.adjustment(dto);
        return "项目内容调整并且重新申报 【" + instanceId + "】 成功";
    }
}
