This repository has been archived by the owner on Dec 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: switch the category classes to clean architecture
- Loading branch information
1 parent
4f07cad
commit d83e9ee
Showing
10 changed files
with
95 additions
and
43 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
src/main/java/br/com/fiap/grupo30/fastfood/domain/repositories/CategoryRepository.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
package br.com.fiap.grupo30.fastfood.domain.repositories; | ||
|
||
import br.com.fiap.grupo30.fastfood.presentation.presenters.dto.CategoryDTO; | ||
import br.com.fiap.grupo30.fastfood.domain.entities.Category; | ||
import java.util.List; | ||
|
||
public interface CategoryRepository { | ||
List<CategoryDTO> findAll(); | ||
List<Category> findAll(); | ||
} |
18 changes: 18 additions & 0 deletions
18
...br/com/fiap/grupo30/fastfood/domain/usecases/category/ListAllCategoriesInMenuUseCase.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package br.com.fiap.grupo30.fastfood.domain.usecases.category; | ||
|
||
import br.com.fiap.grupo30.fastfood.domain.entities.Category; | ||
import br.com.fiap.grupo30.fastfood.infrastructure.gateways.CategoryGateway; | ||
import java.util.List; | ||
|
||
public class ListAllCategoriesInMenuUseCase { | ||
|
||
private final CategoryGateway categoryGateway; | ||
|
||
public ListAllCategoriesInMenuUseCase(CategoryGateway categoryGateway) { | ||
this.categoryGateway = categoryGateway; | ||
} | ||
|
||
public List<Category> execute() { | ||
return categoryGateway.findAll(); | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
.../br/com/fiap/grupo30/fastfood/domain/usecases/product/ListAllCategoriesInMenuUseCase.java
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
...java/br/com/fiap/grupo30/fastfood/infrastructure/configuration/CategoryConfiguration.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package br.com.fiap.grupo30.fastfood.infrastructure.configuration; | ||
|
||
import br.com.fiap.grupo30.fastfood.domain.repositories.CategoryRepository; | ||
import br.com.fiap.grupo30.fastfood.domain.usecases.category.ListAllCategoriesInMenuUseCase; | ||
import br.com.fiap.grupo30.fastfood.infrastructure.gateways.CategoryGateway; | ||
import br.com.fiap.grupo30.fastfood.infrastructure.persistence.repositories.JpaCategoryRepository; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class CategoryConfiguration { | ||
|
||
@Bean | ||
public CategoryRepository categoryRepository(JpaCategoryRepository jpaCategoryRepository) { | ||
return new CategoryGateway(jpaCategoryRepository); | ||
} | ||
|
||
@Bean | ||
public ListAllCategoriesInMenuUseCase listAllCategoriesInMenuUseCase( | ||
CategoryGateway categoryGateway) { | ||
return new ListAllCategoriesInMenuUseCase(categoryGateway); | ||
} | ||
} |
This file contains 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
This file contains 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
26 changes: 26 additions & 0 deletions
26
...a/br/com/fiap/grupo30/fastfood/presentation/presenters/mapper/impl/CategoryDTOMapper.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package br.com.fiap.grupo30.fastfood.presentation.presenters.mapper.impl; | ||
|
||
import br.com.fiap.grupo30.fastfood.domain.entities.Category; | ||
import br.com.fiap.grupo30.fastfood.presentation.presenters.dto.CategoryDTO; | ||
import br.com.fiap.grupo30.fastfood.presentation.presenters.mapper.Mapper; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class CategoryDTOMapper implements Mapper<Category, CategoryDTO> { | ||
|
||
@Override | ||
public CategoryDTO mapTo(Category category) { | ||
CategoryDTO dto = new CategoryDTO(); | ||
dto.setId(category.getId()); | ||
dto.setName(category.getName()); | ||
return dto; | ||
} | ||
|
||
@Override | ||
public Category mapFrom(CategoryDTO dto) { | ||
Category category = new Category(); | ||
category.setId(dto.getId()); | ||
category.setName(dto.getName()); | ||
return category; | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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