package cn.edu.whu.boot.statistics.controller;

import cn.edu.whu.boot.common.domain.ResultMessage;
import cn.edu.whu.boot.statistics.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Li Haoming
 */
@RestController
@RequestMapping("/report")
public class ReportController {

    @Autowired
    ReportService reportService;

    @RequestMapping("/featuresInfo")
    public String getFeaturesInfo(Integer taskId) {
        return reportService.featuresInfo(taskId).toJSONString();
    }

    @RequestMapping("/collectorsInfo")
    public String getCollectorsInfo(Integer taskId) {
        return reportService.collectorsInfo(taskId).toJSONString();
    }

    @RequestMapping("/workloadByUser")
    public String countWorkloadByUser(@RequestParam("taskId") int taskId) {
        return new ResultMessage<>(true, "成功获取统计信息", reportService.countWorkloadByUser(taskId)).toString();
    }
}
