package cn.wisenergy.web.admin.controller.app;

import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.model.app.WorkDept;
import cn.wisenergy.model.dto.StatisticsTableDto;
import cn.wisenergy.service.StatisticsService;
import cn.wisenergy.service.WorkDeptService;
import cn.wisenergy.web.admin.controller.common.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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.RestController;

import java.util.List;

/**
 * @description:
 * @author: nh
 * @create: 2021-01-19 17:13
 **/
@RestController
@RequestMapping(value = "/statistics")
@Slf4j
@Api(tags = "月统计报表")
public class StatisticsController extends BaseController {
    @Autowired
    StatisticsService statisticsService;

    @Autowired
    WorkDeptService workDeptService;

    @ApiOperation(value = "获取部门员工一个月每天的工时", notes = "获取部门员工一个月每天的工时")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "year", value = "年"),
            @ApiImplicitParam(name = "month", value = "月"),
            @ApiImplicitParam(name = "userId", value = "用户主键", required = true),
            @ApiImplicitParam(name = "deptId", value = "部门编号")
    })
    @GetMapping("/getMonthlyCollect")
    public List<StatisticsTableDto> getMonthlyCollect(Integer year, Integer month, Integer userId, Integer deptId) {
        log.info("StatisticsController[]getMonthlyCollect[]input.param" + year + month + userId + deptId);

        List<StatisticsTableDto> statisticsTableDtos = statisticsService.getMonthlyCollect(year, month, userId, deptId);
        return statisticsTableDtos;
    }

    @ApiOperation(value = "")
    @GetMapping("getDeptInfo")
    public List<WorkDept> getDeptInfo(Integer userId, Integer deptId) {
        log.info("StatisticsController[]getDeptInfo[]input.param" + userId + deptId);
        if (userId == null) {
            throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
        }
        List<WorkDept> workDepts = workDeptService.getDeptInfo(userId, deptId);
        return workDepts;
    }

}
