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

import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.module.project.constant.PerformanceConstants;
import com.njcn.rdms.module.project.controller.admin.performance.team.vo.TeamPerformanceRemindReqVO;
import com.njcn.rdms.module.project.controller.admin.performance.team.vo.TeamPerformanceRemindRespVO;
import com.njcn.rdms.module.project.controller.admin.performance.team.vo.TeamPerformanceSummaryReqVO;
import com.njcn.rdms.module.project.controller.admin.performance.team.vo.TeamPerformanceSummaryRespVO;
import com.njcn.rdms.module.project.service.performance.team.TeamPerformanceService;
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/performance-sheets/team")
@Validated
public class TeamPerformanceController {

    @Resource
    private TeamPerformanceService teamPerformanceService;

    @GetMapping("/summary")
    @Operation(summary = "获取团队绩效统计")
    @PreAuthorize("@ss.hasPermission('" + PerformanceConstants.PERMISSION_TEAM_DASHBOARD + "')")
    public CommonResult<TeamPerformanceSummaryRespVO> getSummary(@Valid TeamPerformanceSummaryReqVO reqVO) {
        return success(teamPerformanceService.getSummary(reqVO));
    }

    @PostMapping("/remind")
    @Operation(summary = "催办团队绩效")
    @PreAuthorize("@ss.hasPermission('" + PerformanceConstants.PERMISSION_TEAM_DASHBOARD + "')")
    public CommonResult<TeamPerformanceRemindRespVO> remind(@Valid @RequestBody TeamPerformanceRemindReqVO reqVO) {
        return success(teamPerformanceService.remind(reqVO));
    }
}
