package com.njcn.rdms.module.project.controller.admin.workreport.team;

import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.project.constant.WorkReportConstants;
import com.njcn.rdms.module.project.controller.admin.workreport.team.vo.TeamReportRemindReqVO;
import com.njcn.rdms.module.project.controller.admin.workreport.team.vo.TeamReportRemindRespVO;
import com.njcn.rdms.module.project.controller.admin.workreport.team.vo.TeamReportSummaryReqVO;
import com.njcn.rdms.module.project.controller.admin.workreport.team.vo.TeamReportSummaryRespVO;
import com.njcn.rdms.module.project.service.workreport.team.TeamWorkReportService;
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.security.access.prepost.PreAuthorize;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

@Tag(name = "管理后台 - 团队工作报告")
@RestController
@RequestMapping("/project/work-reports/team")
@Validated
public class TeamWorkReportController {

    @Resource
    private TeamWorkReportService teamWorkReportService;

    @GetMapping("/summary")
    @Operation(summary = "获取团队工作报告统计")
    @PreAuthorize("@ss.hasPermission('" + WorkReportConstants.PERMISSION_TEAM_DASHBOARD + "')")
    public CommonResult<TeamReportSummaryRespVO> getSummary(@Valid TeamReportSummaryReqVO reqVO) {
        return success(teamWorkReportService.getSummary(reqVO));
    }

    @PostMapping("/remind")
    @Operation(summary = "催办团队工作报告")
    @PreAuthorize("@ss.hasPermission('" + WorkReportConstants.PERMISSION_TEAM_DASHBOARD + "')")
    public CommonResult<TeamReportRemindRespVO> remind(@Valid @RequestBody TeamReportRemindReqVO reqVO) {
        return success(teamWorkReportService.remind(reqVO));
    }
}
