package com.ningdatech.pmapi.projectlib.controller;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.projectlib.manage.ProjectLibManage;
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq;
import com.ningdatech.pmapi.projectlib.model.vo.ProcessDetailVO;
import com.ningdatech.pmapi.projectlib.model.vo.ProjectDetailVO;
import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * ProjectLibController
 * </p>
 *
 * @author WendyYang
 * @since 17:30 2023/2/1
 */
@RestController
@RequestMapping("/api/v1/project/lib")
@AllArgsConstructor
@Api(tags = "项目库")
public class ProjectLibController {

    private final ProjectLibManage projectLibManage;

    @GetMapping("/list")
    @ApiOperation("项目库列表")
    public PageVo<ProjectLibListItemVO> projectLibList(ProjectListReq req) {
        return projectLibManage.projectLibList(req);
    }

    @GetMapping("/{id}")
    @ApiOperation("获取项目详情")
    private ProjectDetailVO detail (@PathVariable Long id){
        return projectLibManage.getProjectDetail(id);
    }

    @GetMapping("/processSchedule/{projectId}")
    @ApiOperation("项目库申报项目当前进度详情")
    private List<ProcessDetailVO> processScheduleDetail(@PathVariable("projectId") Long projectId){
        return projectLibManage.processScheduleDetail(projectId);
    }

    @PostMapping("/exportList")
    @ApiOperation("项目库列表导出")
    private void exportList(@Valid @RequestBody ProjectListReq param, HttpServletResponse response){
        projectLibManage.exportList(param,response);
    }
}
