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.ConstrctionPlanListReq;
import com.ningdatech.pmapi.projectdeclared.manage.ConstructionPlanManage;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage;
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
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.beans.BeanUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @Classname ConstructionPlanController
 * @Description 建设方案申报
 * @Date 2023/2/13 9:53
 * @Author PoffyZhang
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/api/v1/construction")
@Api(value = "ConstructionPlan", tags = "申报管理-建设方案申报")
@RequiredArgsConstructor
public class ConstructionPlanController {

    private final ConstructionPlanManage constructionPlanManage;

    @ApiOperation(value = "可申报建设方案项目列表", notes = "可申报建设方案项目列表")
    @GetMapping("/list")
    public PageVo<ProjectLibListItemVO> list(@Validated @ModelAttribute ConstrctionPlanListReq planReq) {
        return constructionPlanManage.projectLibList(planReq);
    }

    @ApiOperation(value = "建设方案申报", notes = "建设方案申报")
    @PostMapping("/start")
    public String startTheProcess(@Validated @RequestBody DefaultDeclaredDTO dto) {
        String instanceId = constructionPlanManage.startTheProcess(dto);
        return "建设方案申报 【" + instanceId + "】 成功";
    }
}
