This commit is contained in:
@@ -57,7 +57,6 @@ public class ComplaintEntityService {
|
||||
.status(ComplaintStatus.CREATED)
|
||||
.complaintText(request.getComplaintText())
|
||||
.email(request.getEmail())
|
||||
.links(linksJson)
|
||||
.violation(violation)
|
||||
.build();
|
||||
|
||||
@@ -105,13 +104,6 @@ public class ComplaintEntityService {
|
||||
}
|
||||
if (request.getComplaintText() != null) complaint.setComplaintText(request.getComplaintText());
|
||||
if (request.getEmail() != null) complaint.setEmail(request.getEmail());
|
||||
if (request.getLinks() != null) {
|
||||
try {
|
||||
complaint.setLinks(objectMapper.writeValueAsString(request.getLinks()));
|
||||
} catch (JsonProcessingException e) {
|
||||
complaint.setLinks(request.getLinks().toString());
|
||||
}
|
||||
}
|
||||
|
||||
return mapToResponse(complaintRepository.save(complaint));
|
||||
}
|
||||
@@ -124,22 +116,12 @@ public class ComplaintEntityService {
|
||||
}
|
||||
|
||||
private ComplaintResponse mapToResponse(ComplaintEntity entity) {
|
||||
List<String> linksList = null;
|
||||
if (entity.getLinks() != null) {
|
||||
try {
|
||||
linksList = objectMapper.readValue(entity.getLinks(),
|
||||
objectMapper.getTypeFactory().constructCollectionType(List.class, String.class));
|
||||
} catch (JsonProcessingException e) {
|
||||
log.warn("Failed to parse links JSON: {}", entity.getLinks());
|
||||
}
|
||||
}
|
||||
|
||||
return ComplaintResponse.builder()
|
||||
.id(entity.getId())
|
||||
.status(entity.getStatus() != null ? entity.getStatus().name() : null)
|
||||
.complaintText(entity.getComplaintText())
|
||||
.email(entity.getEmail())
|
||||
.links(linksList)
|
||||
.violationId(entity.getViolation() != null ? entity.getViolation().getId() : null)
|
||||
.createdAt(entity.getCreatedAt() != null ? entity.getCreatedAt().format(DATE_FORMATTER) : null)
|
||||
.updatedAt(entity.getUpdatedAt() != null ? entity.getUpdatedAt().format(DATE_FORMATTER) : null)
|
||||
|
||||
Reference in New Issue
Block a user