Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c4dce6f670 | |||
| eef3fb773b | |||
| 5d0a047602 | |||
| 8b2d3e7bef | |||
| e72ccf4e96 | |||
| 8487a8ff19 | |||
| dc5bc731b3 | |||
| d45ed26a07 | |||
| 4a0e0e935c |
@@ -1,3 +1,33 @@
|
||||
## [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))
|
||||
|
||||
## [1.5.28](https://git.demonkernel.io.vn/FoodSurf/backend/compare/v1.5.27...v1.5.28) (2026-05-12)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* resolved minor issue ([#53](https://git.demonkernel.io.vn/FoodSurf/backend/issues/53)) ([43734b5](https://git.demonkernel.io.vn/FoodSurf/backend/commit/43734b51aafad7f823ff5d34322cc6fb6f4e6699))
|
||||
|
||||
## [1.5.27](https://git.demonkernel.io.vn/FoodSurf/backend/compare/v1.5.26...v1.5.27) (2026-05-12)
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>com.drinkool</groupId>
|
||||
<artifactId>drinkool</artifactId>
|
||||
<version>1.5.27</version>
|
||||
<version>1.5.30</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -11,6 +12,7 @@ import java.util.List;
|
||||
@Table(name = Role.Manager)
|
||||
public class ManagerEntity extends UserModel {
|
||||
|
||||
@JsonIgnore
|
||||
@OneToMany(
|
||||
mappedBy = "serve",
|
||||
cascade = CascadeType.ALL,
|
||||
@@ -18,6 +20,7 @@ public class ManagerEntity extends UserModel {
|
||||
)
|
||||
public List<StaffEntity> staffs = new ArrayList<>();
|
||||
|
||||
@JsonIgnore
|
||||
@Column(nullable = true)
|
||||
public String bankAccount;
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ public class ManagerService extends BaseService<ManagerEntity> {
|
||||
.build();
|
||||
|
||||
return Response.accepted()
|
||||
.entity(manager)
|
||||
.header(InternalValue.userId, manager.id.toString())
|
||||
.header(InternalValue.role, Role.Manager)
|
||||
.build();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>com.drinkool</groupId>
|
||||
<artifactId>drinkool</artifactId>
|
||||
<version>1.5.27</version>
|
||||
<version>1.5.30</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>com.drinkool</groupId>
|
||||
<artifactId>drinkool</artifactId>
|
||||
<version>1.5.27</version>
|
||||
<version>1.5.30</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -23,5 +23,9 @@ public class AddMenuItem implements MenuItemInterface {
|
||||
@NonNull
|
||||
private Double price;
|
||||
|
||||
private Boolean available;
|
||||
|
||||
private String description;
|
||||
|
||||
private String imageUrl;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.drinkool.dtos;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.eclipse.microprofile.graphql.NonNull;
|
||||
|
||||
@NoArgsConstructor
|
||||
public class CreateShift {
|
||||
|
||||
@NonNull
|
||||
public String name;
|
||||
public Date date;
|
||||
|
||||
@NonNull
|
||||
public LocalTime startTime;
|
||||
@@ -17,4 +18,7 @@ public class CreateShift {
|
||||
public LocalTime endTime;
|
||||
|
||||
public Integer maxStaff;
|
||||
|
||||
@NonNull
|
||||
public Integer wage;
|
||||
}
|
||||
|
||||
@@ -26,5 +26,9 @@ public class UpdateMenuItem implements EntityInterface, MenuItemInterface {
|
||||
|
||||
Double price;
|
||||
|
||||
Boolean available;
|
||||
|
||||
String description;
|
||||
|
||||
String imageUrl;
|
||||
}
|
||||
|
||||
@@ -20,10 +20,16 @@ public class MenuItemEntity extends BaseEntity implements MenuItemInterface {
|
||||
@Column(nullable = false)
|
||||
public Double price;
|
||||
|
||||
@Column(columnDefinition = "boolean default true")
|
||||
public Boolean available;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "eatery_id")
|
||||
public EateryEntity eatery;
|
||||
|
||||
@Column(columnDefinition = "TEXT default ''")
|
||||
public String description;
|
||||
|
||||
@Column(nullable = true)
|
||||
public String imageUrl;
|
||||
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package com.drinkool.entities;
|
||||
|
||||
import com.drinkool.lib.entities.BaseEntity;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
import java.time.LocalTime;
|
||||
import java.util.UUID;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table
|
||||
@@ -19,7 +23,7 @@ public class ShiftEntity extends BaseEntity {
|
||||
public EateryEntity eatery;
|
||||
|
||||
@Column(nullable = false)
|
||||
public String name;
|
||||
public Date date;
|
||||
|
||||
@Column(nullable = false)
|
||||
public LocalTime startTime;
|
||||
@@ -29,4 +33,14 @@ public class ShiftEntity extends BaseEntity {
|
||||
|
||||
@Column(nullable = true)
|
||||
public Integer maxStaff;
|
||||
|
||||
@Column(nullable = false)
|
||||
public Integer wage;
|
||||
|
||||
@OneToMany(
|
||||
mappedBy = "shift",
|
||||
cascade = CascadeType.ALL,
|
||||
orphanRemoval = true
|
||||
)
|
||||
public List<ShiftRegistrationEntity> registeredStaff = new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.drinkool.entities;
|
||||
import com.drinkool.lib.entities.BaseEntity;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import java.util.List;
|
||||
@@ -15,7 +17,8 @@ public class ShiftRegistrationEntity extends BaseEntity {
|
||||
@Column(nullable = false)
|
||||
public UUID staffId;
|
||||
|
||||
@ManyToOne
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "shiftId")
|
||||
public ShiftEntity shift;
|
||||
|
||||
public static long countByShift(UUID shiftId) {
|
||||
|
||||
@@ -116,10 +116,11 @@ public class ShiftService {
|
||||
|
||||
ShiftEntity shift = new ShiftEntity();
|
||||
shift.eatery = eatery;
|
||||
shift.name = input.name;
|
||||
shift.date = input.date;
|
||||
shift.startTime = input.startTime;
|
||||
shift.endTime = input.endTime;
|
||||
shift.maxStaff = input.maxStaff;
|
||||
shift.wage = input.wage;
|
||||
|
||||
if (shift.endTime.isBefore(shift.startTime)) {
|
||||
throw new GraphQLException("InvalidEndTime");
|
||||
@@ -145,7 +146,6 @@ public class ShiftService {
|
||||
!shift.eatery.ownerId.toString().equals(ownerId)
|
||||
) throw new GraphQLException("InvalidShiftId");
|
||||
|
||||
shift.name = input.name;
|
||||
shift.startTime = input.startTime;
|
||||
shift.endTime = input.endTime;
|
||||
shift.maxStaff = input.maxStaff;
|
||||
|
||||
@@ -88,6 +88,8 @@ public class EateryServiceTest {
|
||||
new AddMenuItem(
|
||||
faker.food().dish(),
|
||||
faker.number().randomDouble(2, 10, 100),
|
||||
true,
|
||||
"",
|
||||
""
|
||||
)
|
||||
).id;
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.drinkool.entities.ShiftRegistrationEntity;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@@ -40,13 +41,12 @@ public class ShiftServiceTest {
|
||||
.header(InternalValue.role, Role.Manager)
|
||||
.header(InternalValue.userId, ownerId)
|
||||
.contentType("application/json")
|
||||
.body("{ \"query\": \"{ allShifts { name startTime } }\" }")
|
||||
.body("{ \"query\": \"{ allShifts { startTime } }\" }")
|
||||
.when()
|
||||
.post("/graphql")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("data.allShifts", hasSize(1))
|
||||
.body("data.allShifts[0].name", is("Ca Sáng"));
|
||||
.body("data.allShifts", hasSize(1));
|
||||
}
|
||||
|
||||
// --- TEST MUTATIONS ---
|
||||
@@ -54,18 +54,31 @@ public class ShiftServiceTest {
|
||||
@Test
|
||||
void testCreateShift_AsManager() {
|
||||
String query = """
|
||||
mutation Create($input: CreateShiftInput!)
|
||||
{ createShift(shiftInput: $input) { id name } }""";
|
||||
mutation createShift($shiftInput: CreateShiftInput!) {
|
||||
createShift(shiftInput: $shiftInput) {
|
||||
id
|
||||
date
|
||||
startTime
|
||||
endTime
|
||||
maxStaff
|
||||
wage
|
||||
registeredStaff {
|
||||
staffId
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
Map<String, Object> input = new HashMap<>();
|
||||
input.put("name", "Ca Sáng");
|
||||
input.put("date", "26/04/2026");
|
||||
input.put("startTime", "08:00:00");
|
||||
input.put("endTime", "12:00:00");
|
||||
input.put("maxStaff", 5);
|
||||
input.put("wage", 1000000);
|
||||
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("query", query);
|
||||
body.put("variables", Map.of("input", input));
|
||||
body.put("variables", Map.of("shiftInput", input));
|
||||
|
||||
UUID ownerId = createMockOwner();
|
||||
createMockEatery(ownerId);
|
||||
@@ -78,8 +91,7 @@ public class ShiftServiceTest {
|
||||
.when()
|
||||
.post("/graphql")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("data.createShift.name", is("Ca Sáng"));
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -196,9 +208,10 @@ public class ShiftServiceTest {
|
||||
) {
|
||||
ShiftEntity shift = new ShiftEntity();
|
||||
shift.eatery = eatery;
|
||||
shift.name = name;
|
||||
shift.date = new Date();
|
||||
shift.startTime = LocalTime.parse(start);
|
||||
shift.endTime = LocalTime.parse(end);
|
||||
shift.wage = 10000;
|
||||
shift.maxStaff = 5;
|
||||
shift.persist();
|
||||
return shift;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>com.drinkool</groupId>
|
||||
<artifactId>drinkool</artifactId>
|
||||
<version>1.5.27</version>
|
||||
<version>1.5.30</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>com.drinkool</groupId>
|
||||
<artifactId>drinkool</artifactId>
|
||||
<version>1.5.27</version>
|
||||
<version>1.5.30</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@ import jakarta.json.bind.Jsonb;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class GraphqlBase {
|
||||
|
||||
@@ -39,18 +42,25 @@ public abstract class GraphqlBase {
|
||||
gqlRequest.variables
|
||||
);
|
||||
|
||||
if (response.hasError()) {
|
||||
return Response.status(400)
|
||||
.entity(jsonb.toJson(response.getErrors()))
|
||||
.build();
|
||||
}
|
||||
Map<String, Object> gqlBody = new HashMap<>();
|
||||
|
||||
return Response.ok(jsonb.toJson(response.getData()))
|
||||
gqlBody.put("data", response.getData());
|
||||
gqlBody.put("errors", response.getErrors());
|
||||
return Response.ok(jsonb.toJson(gqlBody))
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.build();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Response.serverError().entity("Lỗi kết nối tới service").build();
|
||||
Map<String, Object> errorBody = new HashMap<>();
|
||||
errorBody.put(
|
||||
"errors",
|
||||
List.of(Map.of("message", "Lỗi kết nối tới service: " + e.getMessage()))
|
||||
);
|
||||
|
||||
return Response.serverError()
|
||||
.type(MediaType.APPLICATION_JSON)
|
||||
.entity(jsonb.toJson(errorBody))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: account-pod
|
||||
image: git.demonkernel.io.vn/foodsurf/account-service:1.5.27
|
||||
image: git.demonkernel.io.vn/foodsurf/account-service:1.5.30
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: cart-pod
|
||||
image: git.demonkernel.io.vn/foodsurf/cart-service:1.5.27
|
||||
image: git.demonkernel.io.vn/foodsurf/cart-service:1.5.30
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
|
||||
@@ -14,7 +14,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: eatery-pod
|
||||
image: git.demonkernel.io.vn/foodsurf/eatery-service:1.5.27
|
||||
image: git.demonkernel.io.vn/foodsurf/eatery-service:1.5.30
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: file-pod
|
||||
image: git.demonkernel.io.vn/foodsurf/file-service:1.5.27
|
||||
image: git.demonkernel.io.vn/foodsurf/file-service:1.5.30
|
||||
imagePullPolicy: IfNotPresent
|
||||
volumeMounts:
|
||||
- name: file-volume
|
||||
|
||||
@@ -14,7 +14,7 @@ spec:
|
||||
spec:
|
||||
containers:
|
||||
- name: gateway-pod
|
||||
image: git.demonkernel.io.vn/foodsurf/gateway-service:1.5.27
|
||||
image: git.demonkernel.io.vn/foodsurf/gateway-service:1.5.30
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>com.drinkool</groupId>
|
||||
<artifactId>drinkool</artifactId>
|
||||
<version>1.5.27</version>
|
||||
<version>1.5.30</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -5,6 +5,10 @@ public interface MenuItemInterface {
|
||||
void setName(String x);
|
||||
Double getPrice();
|
||||
void setPrice(Double x);
|
||||
Boolean getAvailable();
|
||||
void setAvailable(Boolean x);
|
||||
String getImageUrl();
|
||||
void setImageUrl(String x);
|
||||
String getDescription();
|
||||
void setDescription(String x);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user