package thyyxxk.webserver.controller.reports;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.clockin.QueryFromDbParam;
import thyyxxk.webserver.service.reports.ClockinService;

import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
@RequestMapping("/clockin")
public class ClockinController {
    private final ClockinService service;

    @Autowired
    public ClockinController(ClockinService service) {
        this.service = service;
    }

    @PostMapping("/getClockinDataFromDb")
    public ResultVo<Map<String, Object>> getClockinDataFromDb(@RequestBody QueryFromDbParam param) {
        return service.getClockinDataFromDb(param);
    }

    @PostMapping("/exportExcel")
    public void exportExcel(HttpServletResponse response, @RequestBody @Validated QueryFromDbParam param) {
        service.exportExcel(response, param);
    }

}
