This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lombok.Getter; | |
import lombok.RequiredArgsConstructor; | |
import org.springframework.http.HttpStatus; | |
@Getter | |
@RequiredArgsConstructor | |
public enum ErrorEnum { | |
CLIENT_UNAVAILABLE_ERROR("Service unavailable.", HttpStatus.BAD_REQUEST), | |
RESOURCE_NOT_FOUND("Resource not found.", HttpStatus.NOT_FOUND); | |
private final String message; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ResourceNotFoundException extends BackendException { | |
public ResourceNotFoundException(Integer id, String message) { | |
super(ErrorEnum.RESOURCE_NOT_FOUND, "%s id = %s not found", message, id); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lombok.Getter; | |
import lombok.Setter; | |
import lombok.extern.slf4j.Slf4j; | |
import java.util.Arrays; | |
import java.util.List; | |
@Getter | |
@Setter | |
@Slf4j |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>com.pivovarit</groupId> | |
<artifactId>throwing-function</artifactId> | |
<version>1.5.0</version> | |
</dependency> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mak.springbootefficientsearchapi.configuration; | |
import net.kaczmarzyk.spring.data.jpa.web.SpecificationArgumentResolver; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.transaction.annotation.EnableTransactionManagement; | |
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | |
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | |
import java.util.List; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>net.kaczmarzyk</groupId> | |
<artifactId>specification-arg-resolver</artifactId> | |
<version>2.1.1</version> | |
</dependency> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* get element using Criteria. | |
* | |
* @param spec * | |
* @param headers pagination data | |
* @param sort sort criteria | |
* @return retrieve elements with pagination | |
*/ | |
public PagingResponse get(Specification<Car> spec, HttpHeaders headers, Sort sort) { | |
if (isRequestPaged(headers)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Transactional | |
@GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE) | |
@ResponseStatus(HttpStatus.OK) | |
public ResponseEntity<List<Car>> get( | |
@And({ | |
@Spec(path = "manufacturer", params = "manufacturer", spec = Like.class), | |
@Spec(path = "model", params = "model", spec = Like.class), | |
@Spec(path = "country", params = "country", spec = In.class), | |
@Spec(path = "type", params = "type", spec = Like.class), | |
@Spec(path = "createDate", params = "createDate", spec = Equal.class), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mak.springbootefficientsearchapi.entity; | |
import lombok.AllArgsConstructor; | |
import lombok.Getter; | |
import lombok.NoArgsConstructor; | |
import lombok.Setter; | |
import javax.persistence.Column; | |
import javax.persistence.Entity; | |
import javax.persistence.GeneratedValue; |