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