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

import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.framework.common.pojo.PageResult;
import com.njcn.rdms.module.project.controller.admin.project.task.vo.ProjectTaskBoardPageRespVO;
import com.njcn.rdms.module.project.controller.admin.project.task.vo.ProjectTaskRespVO;
import com.njcn.rdms.module.project.controller.admin.project.task.vo.ProjectTaskStatusBoardRespVO;
import com.njcn.rdms.module.project.controller.admin.project.task.vo.aggregate.ProjectTaskAggregateBoardPageReqVO;
import com.njcn.rdms.module.project.controller.admin.project.task.vo.aggregate.ProjectTaskAggregatePageReqVO;
import com.njcn.rdms.module.project.controller.admin.project.task.vo.aggregate.ProjectTaskAggregateStatusBoardReqVO;
import com.njcn.rdms.module.project.controller.admin.project.task.vo.aggregate.ProjectTaskSummaryReqVO;
import com.njcn.rdms.module.project.controller.admin.project.task.vo.aggregate.ProjectTaskSummaryRespVO;
import com.njcn.rdms.module.project.service.project.task.ProjectTaskAggregateService;
import io.swagger.v3.oas.annotations.Operation;
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.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

@Tag(name = "管理后台 - 项目级跨执行任务查询")
@RestController
@RequestMapping("/project/project/{projectId}/tasks")
@Validated
public class ProjectTaskAggregateController {

    @Resource
    private ProjectTaskAggregateService projectTaskAggregateService;

    @GetMapping("/page")
    @Operation(summary = "获取项目级跨执行任务分页")
    public CommonResult<PageResult<ProjectTaskRespVO>> getTaskPage(
            @PathVariable("projectId") Long projectId,
            @Valid ProjectTaskAggregatePageReqVO reqVO) {
        return success(projectTaskAggregateService.getAggregateTaskPage(projectId, reqVO));
    }

    @GetMapping("/status-board")
    @Operation(summary = "获取项目级跨执行任务状态看板")
    public CommonResult<ProjectTaskStatusBoardRespVO> getTaskStatusBoard(
            @PathVariable("projectId") Long projectId,
            @Valid ProjectTaskAggregateStatusBoardReqVO reqVO) {
        return success(projectTaskAggregateService.getAggregateTaskStatusBoard(projectId, reqVO));
    }

    @GetMapping("/board-page")
    @Operation(summary = "获取项目级跨执行任务看板分页")
    public CommonResult<ProjectTaskBoardPageRespVO> getTaskBoardPage(
            @PathVariable("projectId") Long projectId,
            @Valid ProjectTaskAggregateBoardPageReqVO reqVO) {
        return success(projectTaskAggregateService.getAggregateTaskBoardPage(projectId, reqVO));
    }

    @GetMapping("/summary")
    @Operation(summary = "获取项目任务今日小条（involveUserId 控制是否限定 owner / 活跃协办）")
    public CommonResult<ProjectTaskSummaryRespVO> getTaskSummary(
            @PathVariable("projectId") Long projectId,
            @Valid ProjectTaskSummaryReqVO reqVO) {
        return success(projectTaskAggregateService.getAggregateTaskSummary(projectId, reqVO));
    }
}
