так корректно вообще? @GetMapping("/client") public ClientDataResponse…
- User
так корректно вообще? @GetMapping("/client") public ClientDataResponse getClient(HttpServletRequest request, HttpServletResponse response) { ClientHeaderPayload clientHeaderPayload = new Gson().fromJson((String) request.getAttribute(CLIENT_HEADER), ClientHeaderPayload.class); try { Client client = dataService.selectFromWhere(QClient.client, QClient.class, p -> p.id.eq(clientHeaderPayload.getClientId())).fetchFirst(); if (client == null) { throw new ApplicationException("Клиент не найден"); } requestService.createRequestLog(clientHeaderPayload.getRequestId(), OUT, null, response.getStatus(), new Gson().toJson(getClientDataResponse(client))); return getClientDataResponse(client); } catch (Exception e) { log.error("[getClient]", e); response.setStatus(SC_INTERNAL_SERVER_ERROR); return createClientDataResponseMobile(response, e, clientHeaderPayload.getRequestId()); } }
- Assistant
- User
я немного переделал респонс, теперь мне нужно конвертировать из applications в applicationData и засунуть в респонс @Override public ApplicationResponse getApplications(Long clientId) { Client client = dataService.selectFromWhere(QClient.client, QClient.class, p -> p.id.eq(clientId)).fetchFirst(); if (client.getFamilyName() == null && client.getFirstName() == null && client.getPatronymic() == null && client.getEmail() == null && client.getPhone() == null) { log.info("Клиент {} не прошел полную идентификацию", client.getId()); return new ApplicationResponse(); } List applications = applicationRepository.findAll(); if (applications.isEmpty()) { return new ArrayList<>(); } return convertToApplicationResponse(applications); } private ApplicationResponse convertToApplicationResponse(List applications) { return applications.stream() .map(application -> { ApplicationResponse response = new ApplicationResponse(); ApplicationResponse.ApplicationData applicationData = new ApplicationResponse.ApplicationData(); response.applicationData(application.getId()); response.setName(application.getName() != null ? application.getName().name() : null); response.setDescription(application.getDescription()); response.setGroupName(application.getGroupName()); return response; }) .collect(Collectors.toList());
- Assistant