This commit is contained in:
@@ -21,9 +21,6 @@ public class ComplaintRequest {
|
||||
@JsonProperty("email")
|
||||
private String email;
|
||||
|
||||
@JsonProperty("links")
|
||||
private List<String> links;
|
||||
|
||||
@JsonProperty("status")
|
||||
private String status;
|
||||
|
||||
|
||||
@@ -28,9 +28,6 @@ public class ComplaintResponse {
|
||||
@JsonProperty("email")
|
||||
private String email;
|
||||
|
||||
@JsonProperty("links")
|
||||
private List<String> links;
|
||||
|
||||
@JsonProperty("created_at")
|
||||
private String createdAt;
|
||||
|
||||
|
||||
@@ -33,9 +33,6 @@ public class ComplaintEntity {
|
||||
@Column(name = "email")
|
||||
private String email;
|
||||
|
||||
@Column(name = "links", columnDefinition = "TEXT")
|
||||
private String links;
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "violation_id")
|
||||
@ToString.Exclude
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ru.soune.nocopy.entity.complaint;
|
||||
|
||||
public enum ComplaintStatus {
|
||||
CREATED, IN_WORK, COMPLETED, CANCELLED
|
||||
//NEW , SHOWED, LEGAL_IN_WORK, ЖАЛОБА, 3 + 4 , САНКЦАНИРОВАННОЕ ИСПОЛЬЗОВАНИЕ
|
||||
CREATED, SHOWED, IN_WORK, COMPLETED, CANCELLED
|
||||
}
|
||||
|
||||
@@ -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