package com.njcn.rdms.module.project.controller.admin.review;

import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.project.controller.admin.review.vo.RequirementReviewRespVO;
import com.njcn.rdms.module.project.controller.admin.review.vo.RequirementReviewSubmitReqVO;
import com.njcn.rdms.module.project.service.review.RequirementReviewService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import static com.njcn.rdms.framework.common.pojo.CommonResult.success;

/**
 * 管理后台 - 需求评审控制器
 */
@Tag(name = "管理后台 - 需求评审")
@RestController
@Validated
public class RequirementReviewController {

    @Resource
    private RequirementReviewService reviewService;

    @PostMapping("/project/product/requirement/review/submit")
    @Operation(summary = "提交产品需求评审")
    public CommonResult<Long> submitProductRequirementReview(@Valid @RequestBody RequirementReviewSubmitReqVO reqVO) {
        return success(reviewService.submitProductRequirementReview(reqVO));
    }

    @GetMapping("/project/product/requirement/review/get")
    @Operation(summary = "获取产品需求评审记录")
    @Parameter(name = "productId", description = "产品编号", required = true, example = "1024")
    @Parameter(name = "requirementId", description = "需求编号", required = true, example = "4096")
    public CommonResult<RequirementReviewRespVO> getProductRequirementReview(@RequestParam("productId") Long productId,
                                                                             @RequestParam("requirementId") Long requirementId) {
        return success(reviewService.getProductRequirementReview(productId, requirementId));
    }

    @PostMapping("/project/project/requirement/review/submit")
    @Operation(summary = "提交项目需求评审")
    public CommonResult<Long> submitProjectRequirementReview(@Valid @RequestBody RequirementReviewSubmitReqVO reqVO) {
        return success(reviewService.submitProjectRequirementReview(reqVO));
    }

    @GetMapping("/project/project/requirement/review/get")
    @Operation(summary = "获取项目需求评审记录")
    @Parameter(name = "projectId", description = "项目编号", required = true, example = "1024")
    @Parameter(name = "requirementId", description = "需求编号", required = true, example = "4096")
    public CommonResult<RequirementReviewRespVO> getProjectRequirementReview(@RequestParam("projectId") Long projectId,
                                                                             @RequestParam("requirementId") Long requirementId) {
        return success(reviewService.getProjectRequirementReview(projectId, requirementId));
    }

}
