I have a SpringBoot project with two classes DashboardController.java
and DashboardService.java
. I need to define the variable that I get from the Controller
to use it in the whole Service
class. I explain the problem.
This is the method I have in the DashboardController.java
, in which I collect by URL
the variable iniDate
from the front-end:
@GetMapping(path = { "/{employee_id}/{iniDate}" })
public EmployeeDashboardDto getEmployeeDashboarYearInidDto(
@ApiParam(value = "employee_id", required = true) @PathVariable("employee_id") Integer idEmployee,
@ApiParam(value = "iniDate", required = true) @PathVariable("iniDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate iniDate
) throws QOException {
return dashboardService.getEmployeeDashboardYearIniDto(idEmployee,iniDate);
}
And this is the method that I have in the DashboardService.java
class in which I collect the iniDate
variable from the Controller
:
public EmployeeDashboardDto getEmployeeDashboardYearIniDto(Integer idEmployee, EmployeeDashboardDto iniDate) {
EmployeeDashboardDto initDate = iniDate;
return initDate;
}
I'm not sure if I collect the variable correctly, but what I need first is to collect the variable from the front-end in the controller
using the URL
, then collect it in the service
and finally define that variable is the service
to use it in the rest of the methods.