【发布时间】:2020-11-21 09:20:26
【问题描述】:
我有以下方法。
@PostMapping(value = Constants.EMPLOYEE_INSERT,produces = MediaType.APPLICATION_JSON_VALUE)
public String employeeInsert(@RequestHeader(ConstantsValue.ID) @NotBlank final String id,
@RequestBody final List<EmployeeData> empData) {
if (empData != null) {
final List<EmployeeData> insertedData = this.employeeService.insertEmployeeData(empData, id);
if (insertedData != null) {
final List<EmployeeData> employeeDataAfterInsertion =
this.employeeService.getEmployeeData(employeeId);
if (employeeDataAfterInsertion != null) {
return new Gson().toJson(employeeDataAfterInsertion);
} else {
throw new EUCCustomException(empConstants.NO_EMPLOYEE_DATA);
}
} else {
throw new EUCCustomException(empConstants.EMPLOYEE_INSERT_ERROR_DATA);
}
} else {
throw new EUCCustomException(empConstants.EMPLOYEE_MISSING_HEADER_DATA);
}
}
在请求中,我有一个列表 empData,其中包含来自 UI 的数据。如何提取此 empData 以便我可以在 getEmployeeData 方法中传递employeeId。
【问题讨论】: