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.GetMonthlyCollectParam;
import cn.wisenergy.service.StatisticsService;
import cn.wisenergy.service.WorkDeptService;
import cn.wisenergy.web.admin.controller.common.BaseController;
import com.github.pagehelper.PageInfo;
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.HashMap;
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 = "获取部门员工一个月每天的工时")
    @GetMapping("/getMonthlyCollect")
    public PageInfo getMonthlyCollect(GetMonthlyCollectParam param) {
        log.info("StatisticsController[]getMonthlyCollect[]input.param" + param);
        PageInfo monthlyCollect = statisticsService.getMonthlyCollect(param);
        return monthlyCollect;
    }

    @ApiOperation(value = "获取部门信息", notes = "获取部门信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户主键", required = true),
            @ApiImplicitParam(name = "deptId", value = "部门主键", required = true)
    })
    @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;
    }

}
