package ru.soune.nocopy.dto.complaint;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Builder;
import lombok.Data;
import ru.soune.nocopy.entity.complaint.LawCase;
import ru.soune.nocopy.entity.complaint.LawCasePriority;
import ru.soune.nocopy.entity.complaint.LawCaseType;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Data
@Builder
public class LawCaseResponse {
    private Long id;

    private String name;

    private String description;

    private BigDecimal amount;

    private LawCasePriority priority;

    private LawCaseType type;

    private String lawyer;

    @JsonProperty("created_at")
    private LocalDateTime createdAt;

    @JsonProperty("updated_at")
    private LocalDateTime updatedAt;

    @JsonProperty("page_number")
    private int pageNumber;

    @JsonProperty("page_size")
    private int pageSize;

    @JsonProperty("total_elements")
    private long totalElements;

    @JsonProperty("total_pages")
    private int totalPages;

    @JsonProperty("violation_id")
    private long violationId;

    @JsonProperty("file_id")
    private String fileId;

    private List<LawCaseResponse> content;

    public static LawCaseResponse fromEntity(LawCase lawCase) {
        return LawCaseResponse.builder()
                .id(lawCase.getId())
                .name(lawCase.getName())
                .description(lawCase.getDescription())
                .amount(lawCase.getAmount())
                .priority(lawCase.getPriority())
                .type(lawCase.getType())
                .lawyer(lawCase.getLawyer())
                .createdAt(lawCase.getCreatedAt())
                .updatedAt(lawCase.getUpdatedAt())
                .violationId(lawCase.getViolationId())
                .build();
    }
}
