Merge branch 'main' of https://git.demonkernel.io.vn/FoodSurf/backend into quy-connect-frontend
Quy pull main 13/5
This commit is contained in:
@@ -1,6 +1,22 @@
|
||||
## [1.5.30](https://git.demonkernel.io.vn/FoodSurf/backend/compare/v1.5.29...v1.5.30) (2026-05-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* better cart response ([#57](https://git.demonkernel.io.vn/FoodSurf/backend/issues/57)) ([5d0a047](https://git.demonkernel.io.vn/FoodSurf/backend/commit/5d0a0476029cee55f8fbe6ec6e9565ca53ee16bc))
|
||||
|
||||
## [1.5.29](https://git.demonkernel.io.vn/FoodSurf/backend/compare/v1.5.28...v1.5.29) (2026-05-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add menu item fields ([#55](https://git.demonkernel.io.vn/FoodSurf/backend/issues/55)) ([dc5bc73](https://git.demonkernel.io.vn/FoodSurf/backend/commit/dc5bc731b3345663d2640a500ecfb77e81929ab2))
|
||||
* better graphql response ([#54](https://git.demonkernel.io.vn/FoodSurf/backend/issues/54)) ([d45ed26](https://git.demonkernel.io.vn/FoodSurf/backend/commit/d45ed26a07ca5af39ea63e82a9e6453e4aedf0c4))
|
||||
* trigger release version ([#56](https://git.demonkernel.io.vn/FoodSurf/backend/issues/56)) ([e72ccf4](https://git.demonkernel.io.vn/FoodSurf/backend/commit/e72ccf4e960b1623b604c85cbeef54ab8c8d97b3))
|
||||
|
||||
## [1.5.30](https://git.demonkernel.io.vn/FoodSurf/backend/compare/v1.5.29...v1.5.30) (2026-05-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add menu item fields ([#55](https://git.demonkernel.io.vn/FoodSurf/backend/issues/55)) ([dc5bc73](https://git.demonkernel.io.vn/FoodSurf/backend/commit/dc5bc731b3345663d2640a500ecfb77e81929ab2))
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.drinkool.entities;
|
||||
import com.drinkool.Role;
|
||||
import com.drinkool.models.UserModel;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -150,11 +150,11 @@ public class CartService {
|
||||
}
|
||||
|
||||
@Mutation("addItem")
|
||||
public Uni<Cart> addItem(
|
||||
public Cart addItem(
|
||||
@Name("cartId") UUID cartId,
|
||||
@Name("menuItemId") UUID menuItemId,
|
||||
@Name("quantity") long quantity
|
||||
) {
|
||||
) throws GraphQLException {
|
||||
String key = "cart:" + cartId;
|
||||
String priceKey = "cart_prices:" + cartId;
|
||||
|
||||
@@ -163,35 +163,27 @@ public class CartService {
|
||||
|
||||
UUID eateryId = UUID.fromString(eateryIdStr);
|
||||
|
||||
return eateryController
|
||||
Response response = eateryController
|
||||
.checkMenuItemExists(eateryId, menuItemId)
|
||||
.onItem()
|
||||
.transform(response -> {
|
||||
if (response.getStatus() != Response.Status.OK.getStatusCode()) {
|
||||
throw new RuntimeException("NotFoundMenuItemInEatery");
|
||||
}
|
||||
.await()
|
||||
.indefinitely();
|
||||
|
||||
Double menuItemPrice = response.readEntity(Double.class);
|
||||
if (response.getStatus() != Response.Status.OK.getStatusCode()) {
|
||||
throw new GraphQLException("NotFoundMenuItemInEatery");
|
||||
}
|
||||
|
||||
hashCommands.hincrby(key, menuItemId.toString(), quantity);
|
||||
Double menuItemPrice = response.readEntity(Double.class);
|
||||
|
||||
hashCommands.hset(
|
||||
priceKey,
|
||||
menuItemId.toString(),
|
||||
String.valueOf(menuItemPrice)
|
||||
);
|
||||
hashCommands.hincrby(key, menuItemId.toString(), quantity);
|
||||
hashCommands.hset(
|
||||
priceKey,
|
||||
menuItemId.toString(),
|
||||
String.valueOf(menuItemPrice)
|
||||
);
|
||||
|
||||
hashCommands.getDataSource().key().expire(key, Duration.ofDays(30));
|
||||
hashCommands
|
||||
.getDataSource()
|
||||
.key()
|
||||
.expire(priceKey, Duration.ofDays(30));
|
||||
hashCommands.getDataSource().key().expire(key, Duration.ofDays(30));
|
||||
hashCommands.getDataSource().key().expire(priceKey, Duration.ofDays(30));
|
||||
|
||||
try {
|
||||
return getCart(cartId);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
});
|
||||
return getCart(cartId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class CartServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAddItem_Success() {
|
||||
void testAddItem_Success() throws GraphQLException {
|
||||
UUID cartId = UUID.randomUUID();
|
||||
UUID eateryId = UUID.randomUUID();
|
||||
UUID menuItemId = UUID.randomUUID();
|
||||
@@ -137,10 +137,7 @@ public class CartServiceTest {
|
||||
Uni.createFrom().item(Response.ok(17.0).build())
|
||||
);
|
||||
|
||||
Cart result = cartService
|
||||
.addItem(cartId, menuItemId, 2L)
|
||||
.await()
|
||||
.atMost(Duration.ofSeconds(5));
|
||||
Cart result = cartService.addItem(cartId, menuItemId, 2L);
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals(cartId, result.getId());
|
||||
|
||||
Reference in New Issue
Block a user