Skip to content

Commit b4c4d09

Browse files
committed
chore: creates jpa configurer
1 parent fe1317f commit b4c4d09

File tree

6 files changed

+23
-3
lines changed

6 files changed

+23
-3
lines changed

src/main/java/br/com/grupo63/serviceorder/api/controller/product/ProductAPIController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public ResponseEntity<List<ProductControllerDTO>> listByCategoryName(
4040
description = "Cria um produto com nome, preço, estoque inicial e categoria. Possíveis categorias (IDs): " +
4141
"1 - Lanche, 2 - Acompanhamento, 3 - Bebida, 4 - Sobremesa")
4242
@PostMapping
43-
public ResponseEntity<ProductControllerDTO> create(@Valid @RequestBody ProductControllerDTO dto) throws ValidationException {
43+
public ResponseEntity<ProductControllerDTO> create(@Valid @RequestBody ProductControllerDTO dto) {
4444
return ResponseEntity.ok(controller.create(dto));
4545
}
4646

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package br.com.grupo63.serviceorder.config;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.data.auditing.DateTimeProvider;
6+
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
7+
8+
import java.time.LocalDateTime;
9+
import java.util.Optional;
10+
11+
@Configuration
12+
@EnableJpaAuditing(dateTimeProviderRef = "auditingDateTimeProvider")
13+
public class JPAConfigurer {
14+
15+
@Bean(name = "auditingDateTimeProvider")
16+
public DateTimeProvider dateTimeProvider() {
17+
return () -> Optional.of(LocalDateTime.now());
18+
}
19+
20+
}

src/main/java/br/com/grupo63/serviceorder/controller/ProductController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class ProductController {
2020
private final ProductUseCase useCase;
2121
private final IProductGateway gateway;
2222

23-
public ProductControllerDTO create(ProductControllerDTO productControllerDTO) throws ValidationException {
23+
public ProductControllerDTO create(ProductControllerDTO productControllerDTO) {
2424
Product product = new Product();
2525
ProductAdapter.fillEntity(productControllerDTO, product);
2626
product = useCase.create(product, gateway);
@@ -35,7 +35,7 @@ public List<ProductControllerDTO> list() {
3535
return useCase.list(gateway).stream().map(ProductPresenter::toDto).toList();
3636
}
3737

38-
public ProductControllerDTO update(ProductControllerDTO productControllerDTO, Long id) throws ValidationException, NotFoundException {
38+
public ProductControllerDTO update(ProductControllerDTO productControllerDTO, Long id) throws NotFoundException {
3939
Product entity = useCase.read(id, gateway);
4040
ProductAdapter.fillEntity(productControllerDTO, entity);
4141
entity = useCase.update(entity, gateway);
-10 Bytes
Binary file not shown.
1.46 KB
Binary file not shown.
-83 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)