@@ -1,5 +1,6 @@
|
||||
package ru.soune.nocopy.dto.complaint;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import ru.soune.nocopy.entity.complaint.LawCasePriority;
|
||||
import ru.soune.nocopy.entity.complaint.LawCaseType;
|
||||
@@ -26,5 +27,7 @@ public class LawCaseRequest {
|
||||
private LawCaseType filterType;
|
||||
private String filterLawyer;
|
||||
private LawCasePriority filterPriority;
|
||||
@JsonProperty("violation_id")
|
||||
private Long violationId;
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ public class LawCaseResponse {
|
||||
private int pageSize;
|
||||
private long totalElements;
|
||||
private int totalPages;
|
||||
private long violationId;
|
||||
private List<LawCaseResponse> content;
|
||||
|
||||
public static LawCaseResponse fromEntity(LawCase lawCase) {
|
||||
@@ -39,6 +40,7 @@ public class LawCaseResponse {
|
||||
.lawyer(lawCase.getLawyer())
|
||||
.createdAt(lawCase.getCreatedAt())
|
||||
.updatedAt(lawCase.getUpdatedAt())
|
||||
.violationId(lawCase.getViolationId())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,9 @@ public class LawCase {
|
||||
@Column(name = "lawyer")
|
||||
private String lawyer;
|
||||
|
||||
@Column(name = "violation_id")
|
||||
private Long violationId;
|
||||
|
||||
@PrePersist
|
||||
public void prePersist() {
|
||||
if (this.createdAt == null) {
|
||||
|
||||
@@ -79,6 +79,7 @@ public class LawCaseHandler implements RequestHandler {
|
||||
lawCaseRequest.getFilterType(),
|
||||
lawCaseRequest.getFilterLawyer(),
|
||||
lawCaseRequest.getFilterPriority(),
|
||||
lawCaseRequest.getViolationId(),
|
||||
lawCaseRequest.getSortBy(),
|
||||
lawCaseRequest.getSortDir());
|
||||
|
||||
@@ -93,8 +94,7 @@ public class LawCaseHandler implements RequestHandler {
|
||||
lawCases.getNumber(),
|
||||
lawCases.getSize(),
|
||||
lawCases.isFirst(),
|
||||
lawCases.isLast()
|
||||
);
|
||||
lawCases.isLast());
|
||||
|
||||
return new BaseResponse(request.getMsgId(), MessageCode.SUCCESS.getCode(),
|
||||
MessageCode.SUCCESS.getDescription(), paginatedResponse);
|
||||
@@ -132,7 +132,9 @@ public class LawCaseHandler implements RequestHandler {
|
||||
lawCaseRequest.getAmount(),
|
||||
lawCaseRequest.getDescription(),
|
||||
lawCaseRequest.getName(),
|
||||
LawCasePriority.valueOf(lawCaseRequest.getPriority()));
|
||||
LawCasePriority.valueOf(lawCaseRequest.getPriority()),
|
||||
lawCaseRequest.getViolationId());
|
||||
|
||||
lawCase.setUser(user);
|
||||
|
||||
return new BaseResponse(request.getMsgId(), MessageCode.SUCCESS.getCode(),
|
||||
|
||||
@@ -31,10 +31,12 @@ public interface LawCaseRepository extends JpaRepository<LawCase, Long> {
|
||||
@Query("SELECT l FROM LawCase l WHERE l.user.Id = :userId " +
|
||||
"AND (:type IS NULL OR l.type = :type) " +
|
||||
"AND (:lawyer IS NULL OR l.lawyer = :lawyer) " +
|
||||
"AND (:violationId IS NULL OR l.violationId = :violationId) " +
|
||||
"AND (:priority IS NULL OR l.priority = :priority)")
|
||||
Page<LawCase> getUserLawCases(@Param("userId") Long userId,
|
||||
@Param("type") LawCaseType type,
|
||||
@Param("lawyer") String lawyer,
|
||||
@Param("priority") LawCasePriority priority,
|
||||
@Param("violationId") Long violationId,
|
||||
Pageable pageable);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class LawCaseService {
|
||||
private final LawCaseRepository lawCaseRepository;
|
||||
|
||||
public LawCase addLawCase(BigDecimal amount, String description, String name,
|
||||
LawCasePriority priority) {
|
||||
LawCasePriority priority, Long violationId) {
|
||||
LawCase lawCase = new LawCase();
|
||||
|
||||
BigDecimal damage = amount == null ? BigDecimal.ZERO : amount;
|
||||
@@ -30,6 +30,7 @@ public class LawCaseService {
|
||||
lawCase.setName(name);
|
||||
lawCase.setDescription(description);
|
||||
lawCase.setPriority(priority);
|
||||
lawCase.setViolationId(violationId);
|
||||
|
||||
return lawCaseRepository.save(lawCase);
|
||||
}
|
||||
@@ -67,25 +68,16 @@ public class LawCaseService {
|
||||
return lawCaseRepository.save(lawCase);
|
||||
}
|
||||
|
||||
public List<LawCase> getAllUserLawCases(Long userId, int pageSize, int pageNumber, String propertySort,
|
||||
String ascDesc) {
|
||||
Sort.Direction direction = ascDesc.equalsIgnoreCase("desc") ? Sort.Direction.DESC:
|
||||
Sort.Direction.ASC;
|
||||
Sort sort = Sort.by(direction, propertySort);
|
||||
Pageable pageable = PageRequest.of(pageNumber, pageSize, sort);
|
||||
|
||||
return lawCaseRepository.getUserLawCases(userId, pageable);
|
||||
}
|
||||
|
||||
public Page<LawCase> getAllUserLawCases(Long userId, int pageSize, int pageNumber,
|
||||
LawCaseType lawCaseType, String lawyer,
|
||||
LawCasePriority lawCasePriority,
|
||||
Long violationId,
|
||||
String propertySort, String ascDesc) {
|
||||
Sort.Direction direction = ascDesc.equalsIgnoreCase("desc") ? Sort.Direction.DESC : Sort.Direction.ASC;
|
||||
Sort sort = Sort.by(direction, propertySort);
|
||||
Pageable pageable = PageRequest.of(pageNumber, pageSize, sort);
|
||||
|
||||
return lawCaseRepository.getUserLawCases(userId, lawCaseType, lawyer, lawCasePriority, pageable);
|
||||
return lawCaseRepository.getUserLawCases(userId, lawCaseType, lawyer, lawCasePriority, violationId, pageable);
|
||||
}
|
||||
|
||||
public void deleteById(Long id) {
|
||||
|
||||
Reference in New Issue
Block a user