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


import cn.edu.whu.boot.statistics.service.BasicStatService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Li Haoming
 */
@RestController
@RequestMapping("/basicStat")
public class BasicStatController {

    @Autowired
    BasicStatService basicStatService;

    @RequestMapping("/getTasks")
    public String getTasks() {
        return basicStatService.getTasks();
    }


    @RequestMapping("/getTables")
    public String getTaskTables(@Param("tskName") String tskName) {
        return basicStatService.getTables(tskName);
    }

    @RequestMapping("/getFields")
    public String getFields(@Param("tskName") String tskName, @Param("tblName") String tblName) {
        return basicStatService.getFields(tskName, tblName);
    }


    @RequestMapping("/stat")
    public String stat(@Param("tskName") String tskName,
                       @Param("tblName") String tblName,
                       @Param("statField") String statField,
                       @Param("groupField") String groupField) {
        return basicStatService.stat(tskName, tblName, statField, groupField);
    }
}
