Repository navigation
Merged
Conversation
…and decimal price Adds two new columns to the products table: - description VARCHAR(500), nullable, for a short product text visible in the catalogue. - active BOOLEAN NOT NULL DEFAULT TRUE, so products can be deactivated without deletion (the shopping-cart will refuse to add inactive products to a cart). Also migrates unit_price from REAL to NUMERIC(12,2). REAL is a 32-bit IEEE 754 floating-point type that cannot represent most decimal fractions exactly, which causes rounding errors when accumulating line totals in an order. NUMERIC(12,2) stores the value as an exact decimal, the standard choice for monetary amounts in SQL. The USING clause converts existing rows. The old products_unit_price_check constraint is dropped and recreated to match the new type. Migration is numbered V13 to leave V5-V12 free for the existing pedagogical branches (feature/auth through feature/user-management) that will appear in the merge chain when this branch feeds into feature/shopping-cart.
…duct Replaces float unitPrice with BigDecimal (NUMERIC(12,2) in SQL via V13) to eliminate floating-point rounding when summing order line totals. Adds description (nullable VARCHAR(500)) for a short catalogue text, and active (boolean, default true) so an admin can deactivate a product without deleting it. Inactive products will be refused by the shopping-cart service when a user tries to add them to a cart. @Builder.Default ensures that new Product instances built with the Lombok builder start with active=true instead of false (the Java default for boolean), matching the SQL DEFAULT TRUE on the column.
…BigDecimal Adds an optional description field (nullable, no @notblank) so callers can supply a short catalogue text when creating or updating a product. Changes unitPrice from Float to BigDecimal, consistent with the NUMERIC(12,2) column type introduced in V13. Using Float in a request DTO was already lossy: JSON deserialisation to Float can silently round a value like 9.99 before it even reaches the service layer. BigDecimal preserves the exact string "9.99" from JSON all the way to the SQL INSERT.
…tResponse Adds description (nullable String) and active (boolean) to the response so API clients can display a product text and filter or badge inactive products in the UI. Changes unitPrice from float to BigDecimal, consistent with ProductRequest and the NUMERIC(12,2) column. The old float field could serialize 79.99 as 79.98999786376953 in JSON due to floating-point representation; BigDecimal serializes it as the exact string "79.99".
ProductRequest does not carry an active field: the activation state of a product is managed separately and must not be overwritten by a create or update call. Adding @mapping(target="active", ignore=true) on toEntity and updateEntityFromRequest makes this intent explicit and prevents MapStruct from emitting an "unmapped target property" warning. toResponse needs no change: description and active are same-named fields on both Product and ProductResponse, so MapStruct maps them automatically.
…cimal Aligns the price filter with the entity and DTO change from Float to BigDecimal. Using Float here with a BigDecimal column would have forced Hibernate to cast at query time, which is correct but potentially confusing. Explicit BigDecimal parameters make the type contract consistent from the HTTP layer to the SQL predicate.
Aligns the ProductService contract with the entity and specification changes. Float was the original type for minPrice/maxPrice query parameters; BigDecimal makes the type consistent from HTTP deserialization down to the SQL predicate.
…al in ProductServiceImpl Implements the updated ProductService contract. No logic change: the Specification path and the EntityGraph paths remain identical; only the parameter types change from Float to BigDecimal, consistent with the entity field and the SQL NUMERIC(12,2) column type.
… BigDecimal Spring MVC can deserialize a query parameter string like "79.99" directly into BigDecimal without loss. Using Float here would have caused rounding at the HTTP boundary before the value reached the service and the Specification predicate.
…scription and active
Replaces every float/Float literal (79.99f, 99.99f, 50f, 100f) with the
equivalent BigDecimal constructor call (new BigDecimal("79.99"), etc.) to match
the updated ProductRequest, ProductResponse and Product constructor signatures.
Passes null for the new optional description field in ProductRequest.
…description and active
Replaces every float literal and Float wrapper with BigDecimal in all ProductRequest
and ProductResponse constructor calls. Passes null for the new optional description
field. The price filter assertions in _03_ now use eq(new BigDecimal("50")) and
eq(new BigDecimal("100")) to match the updated controller parameter types.
…ve is not overwritten Changes float literals to BigDecimal, passes description in _01_ (non-null) and null in _02_ to cover both branches. _02_ also explicitly asserts that updateEntityFromRequest does not overwrite an existing active=false value, verifying the @mapping(ignore=true) on that field in ProductMapper.
Replaces all float literals (79.99f, 199.99f, 29.99f, 19.99f) with BigDecimal string-constructor equivalents in setUp() and in _04_. No behavioral change: the test logic and assertions remain identical.
…escription and active Replaces float literals with BigDecimal in sampleProduct() and all ProductResponse constructors. Passes null for description and true for the new active field. No change to the caching behavior being verified.
…e changes - Products table schema: adds description (VARCHAR(500), nullable), active (BOOLEAN, default TRUE) and changes unit_price type from FLOAT to NUMERIC(12,2). - Tasks checklist: adds two new checked items for BigDecimal/NUMERIC(12,2) and description/active. - Configuration notes: updates the Flyway numbering note to include V13 and explain the V5-V12 gap; adds notes on BigDecimal throughout the stack and the active-field immutability via the mapper.
…ecimal Product.unitPrice is now BigDecimal (V13 migration). The DataSeeder was still building Product instances with float literals (79.99f, 29.99f, 45.50f), which caused a type mismatch against the updated Lombok builder.
… new ProductResponse fields ProductResponse now carries BigDecimal unitPrice, description and active. The inline ProductResponse constructor call used the old float literal and the old 5-arg signature; updated to the current 7-arg signature with BigDecimal and null description.
…uct builder
Product.unitPrice is now BigDecimal. The inline builder call used a float
literal; replaced with new BigDecimal("79.99").
…Product builder Product.unitPrice is now BigDecimal. Two builder calls used float literals (79.99f, 29.99f); replaced with BigDecimal equivalents.
Category has NOT NULL audit columns (created_at, updated_at from V4). Without @EnableJpaAuditing, Hibernate sends NULL for those columns, violating the constraint. The test only passed in the full suite because CategoryRepositoryTest (which does import JpaAuditingConfig) ran first and its Spring context was reused - an execution-order dependency. Same fix already applied to OrderRepositoryTest per CLAUDE.md; now applied consistently here.
…nt endpoint The previous wording implied that a dedicated activation endpoint manages the active flag. No such endpoint exists on this branch. Replaced with a plain statement of intent: the flag is excluded from create/update payloads so it cannot be overwritten accidentally.
…lerTest All previous fixtures used active=true. Test _13_ adds an inactive product to confirm that the boolean field is correctly serialised as false in the JSON response - a gap the MockMvc slice could not detect without an explicit assertion on the value false.
Adds the 6 new e-commerce branches to every global section: - Table of contents: 6 new entries (product-images through integration) - Data model: products table updated (NUMERIC(12,2), description, active); orders extended (user_id, order_number, status, total_amount); new tables: order_items, product_images, cart, cart_items - Branching strategy table: 6 new rows with branch roles - Order of work: steps 9-14 with correct merge/PR strategy (only feature/integration has a PR to develop; others are feature-to-feature merges) - Concepts covered: file upload, persistent cart, atomic checkout, role-based data ownership - How to follow this tutorial: step 3 lists all 13 branches - 6 new branch sections with endpoints, task checklists, and configuration notes
…rameter seedDemoData() no longer takes a boolean argument. Both test call sites updated to match the new no-arg signature.
…nullable FK columns V14 evolves the orders schema in three steps. First, four columns are added to orders: user_id (nullable FK to app_users, reserved for a future checkout flow), order_number (VARCHAR 50 UNIQUE, human-readable UID), status (VARCHAR 20 NOT NULL DEFAULT 'PENDING'), and total_amount (NUMERIC(12,2) replacing the legacy DOUBLE PRECISION total column). Second, a new order_items table captures product snapshots per order line: product_name and unit_price are denormalized at creation time so the order history stays accurate even after a product is renamed or repriced; product_id uses ON DELETE SET NULL to preserve history if the product is removed. Third, existing rows are backfilled: each legacy order gets one OrderItem reconstructed from its joined product, total_amount is set from the legacy total column, and order_number is set to 'ORD-HIST-000NNN'.
…price, subtotal) OrderItem maps the order_items table introduced in V14. The snapshot pattern is key: productName and unitPrice are copied from Product at creation time and never updated, so the order history remains accurate even after the product is renamed or repriced. The product FK is nullable to support ON DELETE SET NULL: removing a product sets product_id to NULL without destroying historical line data. subtotal is stored (not derived) to avoid any floating-point drift on retrieval.
…ber, status, items Order gains four new mapped fields: totalAmount (BigDecimal, NUMERIC 12,2), orderNumber (VARCHAR 50 unique), status (@Enumerated(STRING), defaults to PENDING via @Builder.Default), and items (@onetomany cascade ALL with orphanRemoval, the authoritative multi-line breakdown). The legacy customer and product FK mappings are kept and their @joincolumn constraints are relaxed to nullable so existing CRUD flows continue to compile and pre-V14 rows survive the migration without both FK columns set.
…updateStatus Three methods introduced on this branch had no unit tests in OrderServiceImplTest: - findAll(String, boolean, Pageable): add _01d_ (admin path, delegates to orderRepository.findAll), _01e_ (user path, delegates to findByUserId), _01f_ (user not found, returns empty page). - findById user path: add _03b_ (user owns order, returns response) and _03c_ (order belongs to another user, 404-not-403 ownership check). - updateStatus: add _updateStatus_01_ (valid PENDING->CONFIRMED transition), _updateStatus_02_ (invalid CONFIRMED->PENDING raises BusinessRuleException), _updateStatus_03_ (order not found raises ResourceNotFoundException).
…o integration branch
…ocker-compose.yml Two new environment variables forwarded from .env to the app service: - APP_NOTIFICATION_ADMIN_EMAIL: used by NotificationProperties to send admin alerts on new orders. - APP_STORAGE_UPLOAD_DIR: used by StorageProperties to resolve the upload root directory for product images. A host volume ./uploads:/app/uploads is also added so uploaded product images survive container restarts and are accessible from the host.
Covers the full e-commerce flow in a single test method against a real PostgreSQL instance (Testcontainers) and the full Spring Security stack: 1. Product catalogue is accessible without authentication. 2. Authenticated user adds a product to their cart. 3. Cart is retrieved and the item is verified. 4. Cart item quantity is updated via PATCH. 5. Checkout creates an order and empties the cart atomically. 6. Cart is confirmed empty after checkout. 7. User sees only their own orders. 8. User retrieves order detail (status=PENDING, items present). 9. Admin transitions order to CONFIRMED. 10. User sees updated status (CONFIRMED). 11. Another user gets 404 on the first user's order (ownership check). Steps run sequentially inside a single @test to share intermediate state (cart item id, order id) without relying on undefined JUnit method ordering.
…ojection) After merging feature/product-images, ProductResponse gained an 8th field List<ProductImageResponse> images. The projection-based overload of OrderMapper.toResponse(OrderProjection) built ProductResponse with 7 args; the compact canonical constructor now requires 8. Fixed by passing List.of() since projections are flat JPQL rows that carry no image data.
…ory delete CartItemRepository.deleteAllByCartId() ran inside the checkout() transaction, which had already loaded Cart with its items via @EntityGraph. Because Cart.items has cascade = ALL + orphanRemoval = true, Hibernate cascades PERSIST to the items collection at flush time, re-inserting the rows just deleted by the repository call. Fix: cart.getItems().clear() lets Hibernate's orphan removal detect the removed items through normal collection change tracking and issue the DELETEs cleanly, without the cascade conflict. CartItemRepository is no longer needed in OrderServiceImpl and is removed.
…from OrderServiceImpl
…ct structure Corrects version numbers and column details in the data model section: - orders: user_id is nullable (V18, not NOT NULL at V14); adds legacy columns product_id/quantity/total that remain in the table alongside the new V14 columns - product_images: version V15 -> V16; replaces sort_order with is_primary BOOLEAN (partial unique index enforces one primary image per product) - carts/cart_items: version V16 -> V17 (V16 is product_images) Adds the missing tables that the auth/security branches introduce: app_users (V2/V7/V8/V9), roles and permissions (V5), role_user and role_permission join tables (V5/V7), activation_tokens, blacklisted_tokens and password_reset_tokens (V6). Updates the project structure tree to show the full final state across all branches: validation/, token/, config additions (AsyncConfig, SchedulingConfig, StorageConfig, MethodSecurityConfig), security additions (JwtProperties, JwtAccessDeniedHandler, JwtAuthenticationEntryPoint, CustomPermissionEvaluator), all e-commerce entities and repositories (ProductImage, OrderItem, Cart, CartItem), all service interfaces and implementations, all controllers, all mappers, and all Flyway migrations V1 through V18 (V10-V12 unused, reserved for future use). Adds an intro note to the data model section explaining that the base 4-table model is the starting point and the e-commerce extension adds the remaining tables.
…ct structure to feature/products
…ucture to feature/user-management
…cture to feature/shopping-cart
…ure to feature/order-checkout
…ture to feature/order-notifications
…structure to feature/integration
# Conflicts: # README.md # src/main/java/com/edgareldy/springboottutorial/controller/OrderController.java # src/main/java/com/edgareldy/springboottutorial/dto/customer/CustomerResponse.java # src/main/java/com/edgareldy/springboottutorial/dto/order/CustomerOrdersResponse.java # src/main/java/com/edgareldy/springboottutorial/dto/order/OrderResponse.java # src/main/java/com/edgareldy/springboottutorial/dto/order/OrderedProductResponse.java # src/main/java/com/edgareldy/springboottutorial/mapper/CustomerMapper.java # src/main/java/com/edgareldy/springboottutorial/mapper/OrderMapper.java # src/main/java/com/edgareldy/springboottutorial/repository/OrderRepository.java # src/main/java/com/edgareldy/springboottutorial/service/OrderService.java # src/main/java/com/edgareldy/springboottutorial/service/impl/CustomerServiceImpl.java # src/main/java/com/edgareldy/springboottutorial/service/impl/OrderServiceImpl.java # src/test/java/com/edgareldy/springboottutorial/controller/CustomerControllerTest.java # src/test/java/com/edgareldy/springboottutorial/controller/OrderControllerTest.java # src/test/java/com/edgareldy/springboottutorial/mapper/CustomerMapperTest.java # src/test/java/com/edgareldy/springboottutorial/mapper/OrderMapperTest.java # src/test/java/com/edgareldy/springboottutorial/repository/OrderRepositoryTest.java # src/test/java/com/edgareldy/springboottutorial/service/impl/CustomerServiceImplTest.java # src/test/java/com/edgareldy/springboottutorial/service/impl/OrderServiceImplTest.java
…eckout, notifications, authorization, integration) in en + fr
…out, order status)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR merges
developintomaster, bringing the full e-commerce extension and all associated documentation.E-commerce features (feature/product-images through feature/integration)
@Async,OrderEmailService, Thymeleaf HTML templatesPATCH /orders/{id}/statuscart.getItems().clear()vsdeleteAllByCartId),EcommerceIntegrationTest11-step e2eDocumentation (feature/docs)
docs/en/anddocs/fr/) for all 20 feature branchesTest plan
mvn clean test- all tests must pass (454 expected)spring-boot-tutorial.insomnia.yamland verify e-commerce endpointsdocker compose up --build- verify full stack starts and Flyway runs V13-V18