package com.ningdatech.pmapi.expert.controller;


import com.ningdatech.log.annotation.WebLog;
import com.ningdatech.pmapi.expert.manage.ExpertReviewManage;
import com.ningdatech.pmapi.expert.model.req.ExpertReviewDetailReq;
import com.ningdatech.pmapi.expert.model.vo.ExpertReviewDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author WendyYang
 * @since 2023-02-15
 */
@RestController
@AllArgsConstructor
@Api(tags = "专家评审")
@RequestMapping("/api/v1/expertReview")
public class ExpertReviewController {

    private final ExpertReviewManage expertReviewManage;

    @PostMapping("/save")
    @ApiOperation("填写评审意见")
    @WebLog("填写评审意见")
    public void expertReview(@RequestBody @Valid ExpertReviewDetailReq req) {
        expertReviewManage.expertReview(req);
    }

    @GetMapping("/detail/{projectId}/{userId}")
    @ApiOperation("获取专家评审详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "专家ID"),
            @ApiImplicitParam(name = "projectId", value = "项目ID")
    })
    public ExpertReviewDetailVO getExpertReviewDetail(@PathVariable Long userId, @PathVariable Long projectId) {
        return expertReviewManage.getExpertReviewDetail(userId, projectId);
    }

    @GetMapping("/listForGroupLeader/{projectId}/{userId}")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "专家ID"),
            @ApiImplicitParam(name = "projectId", value = "项目ID")
    })
    @ApiOperation("查看组员评审意见")
    public List<ExpertReviewDetailVO> listForGroupLeader(@PathVariable Long userId, @PathVariable Long projectId) {
        return expertReviewManage.listForGroupLeader(projectId, userId);
    }

}
