Commit fcfa5577 authored by Rajeshekar's avatar Rajeshekar

[Rajeshekar]: If mysql connection not there,the UI screens popups

closing as the exception is thown back to UI
parent 874acacd
package com.nisum.mytime.controller; package com.nisum.mytime.controller;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -23,50 +24,74 @@ import com.nisum.mytime.service.UserService; ...@@ -23,50 +24,74 @@ import com.nisum.mytime.service.UserService;
@RequestMapping("/attendance") @RequestMapping("/attendance")
public class AttendanceController { public class AttendanceController {
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired @Autowired
private AttendanceService attendanceService; private AttendanceService attendanceService;
@RequestMapping(value = "employeeLoginsBasedOnDate", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "employeeLoginsBasedOnDate",
public ResponseEntity<List<EmpLoginData>> employeeLoginsBasedOnDate(@RequestParam("empId") long id, method = RequestMethod.GET,
@RequestParam("fromDate") String fromDate, @RequestParam("toDate") String toDate) throws MyTimeException { produces = MediaType.APPLICATION_JSON_VALUE)
List<EmpLoginData> message = userService.employeeLoginsBasedOnDate(id, fromDate, toDate); public ResponseEntity<List<EmpLoginData>> employeeLoginsBasedOnDate(
return new ResponseEntity<>(message, HttpStatus.OK); @RequestParam("empId") long id,
} @RequestParam("fromDate") String fromDate,
@RequestParam("toDate") String toDate) throws MyTimeException {
List<EmpLoginData> message = new ArrayList<>();
try {
message = userService.employeeLoginsBasedOnDate(id, fromDate,
toDate);
} catch (Exception e) {
e.printStackTrace();
}
return new ResponseEntity<>(message, HttpStatus.OK);
}
@RequestMapping(value = "generatePdfReport/{id}/{fromDate}/{toDate}", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE) @RequestMapping(value = "generatePdfReport/{id}/{fromDate}/{toDate}",
public ResponseEntity<String> generatePdfReport(@PathVariable("id") long id, method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
@PathVariable("fromDate") String fromDate, @PathVariable("toDate") String toDate) throws MyTimeException { public ResponseEntity<String> generatePdfReport(@PathVariable("id") long id,
String result = userService.generatePdfReport(id, fromDate, toDate); @PathVariable("fromDate") String fromDate,
return new ResponseEntity<>(result, HttpStatus.OK); @PathVariable("toDate") String toDate) throws MyTimeException {
} String result = userService.generatePdfReport(id, fromDate, toDate);
return new ResponseEntity<>(result, HttpStatus.OK);
}
@RequestMapping(value = "attendanciesReport/{reportDate}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "attendanciesReport/{reportDate}",
public ResponseEntity<List<AttendenceData>> attendanciesReport(@PathVariable("reportDate") String reportDate) method = RequestMethod.GET,
throws MyTimeException, SQLException { produces = MediaType.APPLICATION_JSON_VALUE)
List<AttendenceData> lisOfAttendenceData = attendanceService.getAttendanciesReport(reportDate); public ResponseEntity<List<AttendenceData>> attendanciesReport(
return new ResponseEntity<>(lisOfAttendenceData, HttpStatus.OK); @PathVariable("reportDate") String reportDate)
} throws MyTimeException, SQLException {
List<AttendenceData> lisOfAttendenceData = attendanceService
.getAttendanciesReport(reportDate);
return new ResponseEntity<>(lisOfAttendenceData, HttpStatus.OK);
}
@RequestMapping(value = "employeesDataSave/{searchDate}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "employeesDataSave/{searchDate}",
public ResponseEntity<Boolean> employeesDataSave(@PathVariable("searchDate") String searchDate) method = RequestMethod.POST,
throws MyTimeException { produces = MediaType.APPLICATION_JSON_VALUE)
Boolean result = userService.fetchEmployeesData(searchDate,false); public ResponseEntity<Boolean> employeesDataSave(
return new ResponseEntity<>(result, HttpStatus.OK); @PathVariable("searchDate") String searchDate)
} throws MyTimeException {
Boolean result = userService.fetchEmployeesData(searchDate, false);
return new ResponseEntity<>(result, HttpStatus.OK);
}
/* @RequestMapping(value = "copyRemoteMdbFileToLocal", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) /*
public ResponseEntity<Boolean> copyRemoteMdbFileToLocal() throws MyTimeException { * @RequestMapping(value = "copyRemoteMdbFileToLocal", method =
Boolean result = attendanceService.copyRemoteMdbFileToLocal(); * RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public
return new ResponseEntity<>(result, HttpStatus.OK); * ResponseEntity<Boolean> copyRemoteMdbFileToLocal() throws MyTimeException
}*/ * { Boolean result = attendanceService.copyRemoteMdbFileToLocal(); return
* new ResponseEntity<>(result, HttpStatus.OK); }
*/
@RequestMapping(value = "resyncMonthData/{fromDate}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "resyncMonthData/{fromDate}",
public ResponseEntity<Boolean> resyncMonthData(@PathVariable("fromDate") String fromDate) throws MyTimeException { method = RequestMethod.POST,
Boolean result = userService.fetchEmployeesData(fromDate,true); produces = MediaType.APPLICATION_JSON_VALUE)
return new ResponseEntity<>(result, HttpStatus.OK); public ResponseEntity<Boolean> resyncMonthData(
} @PathVariable("fromDate") String fromDate) throws MyTimeException {
Boolean result = userService.fetchEmployeesData(fromDate, true);
return new ResponseEntity<>(result, HttpStatus.OK);
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment