Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add product ports and adapters #23

Merged
merged 3 commits into from
Apr 25, 2024
Merged

Conversation

italopessoa
Copy link
Member

@italopessoa italopessoa commented Apr 25, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new product management system with CRUD operations for products.
    • Added product categorization and search by category functionality.
    • Enhanced customer creation method with additional parameters.
  • Bug Fixes

    • Updated namespace references for better organization and consistency.
  • Tests

    • Comprehensive testing for new product functionalities to ensure reliability.
    • Added testing frameworks and libraries for improved testing capabilities.
  • Refactor

    • Improved product list initialization in order tests for performance and readability.

- add services
- add repository
- change Product to Entity
- add in memory adapter for repository
- #3 #4 #5 #6
Copy link

coderabbitai bot commented Apr 25, 2024

Walkthrough

The recent update focuses on enhancing product management within the ByteMeBurger system. It introduces a new ProductController for handling product operations through HTTP requests, updates services and repositories for improved product management functionalities, and includes thorough testing to ensure system robustness. Additionally, there are namespace adjustments and new methods introduced to enhance product and customer data handling.

Changes

File Path Change Summary
.../Controllers/ProductController.cs Introduced ProductController for managing product operations via HTTP requests.
.../Program.cs Added namespaces and services related to product management.
.../Services/ProductService.cs,
.../Ports/Ingoing/IProductService.cs,
.../Ports/Outgoing/IProductRepository.cs,
.../Repository/InMemoryProductRepository.cs
Enhanced product management functionalities in services and repositories, including CRUD operations and category filtering.
.../Base/Entity.cs,
.../Entities/Customer.cs,
.../Entities/Order.cs
Namespace changes and minor formatting adjustments.
.../Entities/Product.cs Added Product class with properties, methods, and validation logic for product management.
.../Ports/Ingoing/ICustomerService.cs Updated to include new method signatures for customer creation.
.../Application.Test/...,
.../Domain.Test/...
Added new test cases and package references to ensure the functionality and integrity of product and order handling.

Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between d69b947 and 2fc1e04.
Files selected for processing (4)
  • src/FIAP.TechChallenge.ByteMeBurger.Api/Controllers/ProductController.cs (1 hunks)
  • src/FIAP.TechChallenge.ByteMeBurger.Api/Model/CreateProductCommandDto.cs (1 hunks)
  • src/FIAP.TechChallenge.ByteMeBurger.Api/Model/ProductDto.cs (1 hunks)
  • tests/FIAP.TechChallenge.ByteMeBurger.Api.Test/Controllers/ProductControllerTest.cs (1 hunks)
Files skipped from review as they are similar to previous changes (4)
  • src/FIAP.TechChallenge.ByteMeBurger.Api/Controllers/ProductController.cs
  • src/FIAP.TechChallenge.ByteMeBurger.Api/Model/CreateProductCommandDto.cs
  • src/FIAP.TechChallenge.ByteMeBurger.Api/Model/ProductDto.cs
  • tests/FIAP.TechChallenge.ByteMeBurger.Api.Test/Controllers/ProductControllerTest.cs

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Out of diff range and nitpick comments (2)
src/FIAP.TechChallenge.ByteMeBurger.Domain/Base/Entity.cs (1)

Line range hint 19-19: Add null checks before accessing Id in GetHashCode to prevent possible null reference exceptions.

- return Id.GetHashCode();
+ return Id?.GetHashCode() ?? 0;
src/FIAP.TechChallenge.ByteMeBurger.Domain/Entities/Product.cs (1)

52-60: Method Update should ensure immutability of the Product by returning a new instance rather than modifying existing one.

Consider returning a new Product instance with updated values to ensure the entity remains immutable.

Comment on lines +18 to +20
public DateTime CreationDate { get; set; }

public DateTime? LastUpdate { get; set; }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure CreationDate is set in constructor to avoid uninitialized state.

- public DateTime CreationDate { get; set; }
+ public DateTime CreationDate { get; private set; } = DateTime.UtcNow;

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
public DateTime CreationDate { get; set; }
public DateTime? LastUpdate { get; set; }
public DateTime CreationDate { get; private set; } = DateTime.UtcNow;
public DateTime? LastUpdate { get; set; }

Comment on lines +47 to +50
public void Create()
{
CreationDate = DateTime.UtcNow;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method Create should be called within constructors to ensure CreationDate is always initialized.

+ Create();

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
public void Create()
{
CreationDate = DateTime.UtcNow;
}
public void Create()
{
CreationDate = DateTime.UtcNow;
Create();
}

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Comment on lines +19 to +20
// TODO make this iternal
public Product ToProduct() => new Product(Guid.NewGuid(), Name, Description, Category, Price, Images);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method ToProduct should be internal as noted in the TODO comment to encapsulate the conversion logic within the API layer.

- public Product ToProduct() => new Product(Guid.NewGuid(), Name, Description, Category, Price, Images);
+ internal Product ToProduct() => new Product(Guid.NewGuid(), Name, Description, Category, Price, Images);

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
// TODO make this iternal
public Product ToProduct() => new Product(Guid.NewGuid(), Name, Description, Category, Price, Images);
// TODO make this iternal
internal Product ToProduct() => new Product(Guid.NewGuid(), Name, Description, Category, Price, Images);

@italopessoa italopessoa merged commit 2f0d361 into main Apr 25, 2024
@italopessoa italopessoa deleted the create_product_flow branch April 25, 2024 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

1 participant