package com.nisum.myteam.controller;


import com.nisum.myteam.service.IEffectiveLoginTimeService;
import com.nisum.myteam.service.IEmployeeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.Date;
import java.util.Map;

@RestController
@Slf4j
public class EffectiveLoginTimeController {

    @Autowired
    IEffectiveLoginTimeService effectiveLoginTimeService;

    @Autowired
    private IEmployeeService employeeService;

//    @GetMapping("/effecitveLoginTime")
//    public EffectiveLoginData getLoginData(@RequestParam("loginId") String loginEmpId) throws MyTeamException {
////        List<Employee> allEmployees = employeeService.getActiveEmployees();
////        for(Employee employee:allEmployees){
////            EffectiveLoginData effectiveLoginData =
////                    effectiveLoginTimeService.calculateEffectiveLoginTimeForEmpAndSave(employee.getEmployeeId());
////        }
//        return effectiveLoginTimeService.calculateEffectiveLoginTimeForEmpAndSave(loginEmpId);
//    }
    @GetMapping("/effectiveLogin")
    public Map<String,Object> getAllEmployeesLoginData(
            @RequestParam("employeeId") long employeeId,
            @RequestParam("fromDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date fromDate,
            @RequestParam("toDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date toDate) throws ParseException {

        return effectiveLoginTimeService.getEmployeesEffLoginData(employeeId,fromDate,toDate);
    }
}
