package com.microservices.dss.makerspace.controller;

import com.microservices.common.core.web.controller.BaseController;
import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.dss.annotation.GitlinkAdminAccessRequired;
import com.microservices.dss.makerspace.service.ITasksService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/open/makerSpace")
@Api(tags = "数据统计-创客空间相关接口")
public class MakerSpaceDataController extends BaseController {

    @Autowired
    private ITasksService tasksService;

    @ApiOperation("创客空间全局资源获取")
    @GetMapping(value = "/total")
    @GitlinkAdminAccessRequired
    public AjaxResult getTotalData() {
        return success(tasksService.getTotalStatisticalData());
    }

    @ApiOperation("创客任务新增趋势")
    @GetMapping(value = "/task/trend")
    @GitlinkAdminAccessRequired
    public AjaxResult getTaskTrendData() {
        return success(tasksService.getTaskAdditionTrendData());
    }

    @ApiOperation("创客成果新增趋势")
    @GetMapping(value = "/paper/trend")
    @GitlinkAdminAccessRequired
    public AjaxResult getPaperTrendData() {
        return success(tasksService.getPaperAdditionTrendData());
    }

    @ApiOperation("创客任务最新操作日志")
    @GetMapping(value = "/task/operLog")
    @GitlinkAdminAccessRequired
    public AjaxResult getPaperTrendData(@ApiParam("获取最新操作日志的数量") @RequestParam Integer topNum) {
        return success(tasksService.getTaskOperLogTopN(topNum));
    }

    @ApiOperation("创客任务奖金分布")
    @GetMapping(value = "/task/bountyDistribution")
    @GitlinkAdminAccessRequired
    public AjaxResult getBountyDistribution() {
        return success(tasksService.getBountyDistribution());
    }

    @ApiOperation("创客任务热度排行")
    @GetMapping(value = "/task/heatRank")
    @GitlinkAdminAccessRequired
    public AjaxResult getHeatTopN(@ApiParam("获取热度排行的数量") @RequestParam Integer topNum) {
        return success(tasksService.getTaskHeatTopN(topNum));
    }

    @ApiOperation("创客类型分布统计（统筹/自主)")
    @GetMapping(value = "/task/mode")
    @GitlinkAdminAccessRequired
    public AjaxResult getTaskModeStatisticalData() {
        return success(tasksService.getTaskModeStatisticalData());
    }

    @ApiOperation("创客任务-开启中状态任务数分布")
    @GetMapping(value = "/task/statusDistribution/opening")
    @GitlinkAdminAccessRequired
    public AjaxResult getOpeningTaskStatusDistribution(@ApiParam("获取开启中状态任务分布的数量") @RequestParam Integer topNum) {
        return success(tasksService.getOpeningTaskStatusDistribution(topNum));
    }

    @ApiOperation("创客任务-所有任务类型分布")
    @GetMapping(value = "/task/categoryDistribution")
    @GitlinkAdminAccessRequired
    public AjaxResult getAllTaskCategoryDistribution() {
        return success(tasksService.getAllTaskCategoryDistribution());
    }


}
