Skip to content

Commit 930047a

Browse files
authored
✨ feat: 픽업 완료 API 개발
✨ feat: 픽업 완료 API 개발
2 parents fe27453 + 0d56a0e commit 930047a

File tree

15 files changed

+125
-36
lines changed

15 files changed

+125
-36
lines changed

src/main/java/com/example/Centralthon/domain/menu/entity/Menu.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class Menu extends BaseEntity {
3030
@Column(name = "sale_price", nullable = false)
3131
private int salePrice;
3232

33+
@Setter
3334
@Column(nullable = false)
3435
private int quantity;
3536

src/main/java/com/example/Centralthon/domain/menu/exception/MenuErrorCode.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
@Getter
88
@AllArgsConstructor
99
public enum MenuErrorCode implements BaseResponseCode {
10-
MENU_NOT_FOUND("MENU_NOT_FOUND_404_1",404,"존재하지 않는 메뉴 입니다.");
10+
MENU_EXPIRED("MENU_400_1", 400, "판매 마감된 메뉴입니다."),
11+
MENU_OUT_OF_STOCK("MENU_400_2", 400, "재고가 부족합니다."),
12+
MENU_NOT_FOUND("MENU_404_1",404,"존재하지 않는 메뉴 입니다.");
1113

1214
private final String code;
1315
private final int httpStatus;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.example.Centralthon.domain.menu.exception;
2+
3+
import com.example.Centralthon.global.exception.BaseException;
4+
5+
public class MenuExpiredException extends BaseException {
6+
public MenuExpiredException() {super(MenuErrorCode.MENU_EXPIRED);}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.example.Centralthon.domain.menu.exception;
2+
3+
import com.example.Centralthon.global.exception.BaseException;
4+
5+
public class MenuOutOfStockException extends BaseException {
6+
public MenuOutOfStockException() {super(MenuErrorCode.MENU_OUT_OF_STOCK);}
7+
}

src/main/java/com/example/Centralthon/domain/menu/repository/MenuRepository.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.springframework.data.repository.query.Param;
77
import org.springframework.stereotype.Repository;
88

9+
import java.util.Collection;
910
import java.util.List;
1011
import java.time.LocalDateTime;
1112
@Repository
@@ -27,6 +28,12 @@ List<Menu> findNearbyMenus(
2728
@Param("maxLng") double maxLng
2829
);
2930

31+
/**
32+
* ids에 포함된 Menu와 연관된 Store를 한번에 가져옴
33+
*/
34+
@Query(value = "SELECT m from Menu m join fetch m.store where m.id in :ids")
35+
List<Menu> findAllByIdWithStore(@Param("ids") Collection<Long> ids);
36+
3037

3138

3239
}

src/main/java/com/example/Centralthon/domain/order/entity/Order.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ public static Order toEntity(String pickUpCode, int price){
3333
.pickedUp(false)
3434
.build();
3535
}
36+
37+
public void completeOrder(){
38+
this.pickedUp = true;
39+
}
3640
}

src/main/java/com/example/Centralthon/domain/order/exception/CodeNotCreatedException.java

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.example.Centralthon.domain.order.exception;
2+
3+
import com.example.Centralthon.global.exception.BaseException;
4+
5+
public class OrderCodeNotCreatedException extends BaseException {
6+
public OrderCodeNotCreatedException() {
7+
super(OrderErrorCode.ORDER_CODE_NOT_CREATED);
8+
}
9+
}

src/main/java/com/example/Centralthon/domain/order/exception/OrderErrorCode.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
@Getter
88
@AllArgsConstructor
99
public enum OrderErrorCode implements BaseResponseCode {
10-
CODE_NOT_CREATED("ORDER_500_1",500,"서버에서 유일한 픽업 코드를 생성하지 못했습니다.");
10+
ORDER_EXPIRED("ORDER_400_1", 400, "만료된 주문입니다."),
11+
ORDER_NOT_FOUND("ORDER_404_1", 404, "존재하지 않는 주문입니다."),
12+
ORDER_CODE_NOT_CREATED("ORDER_500_1",500,"서버에서 유일한 픽업 코드를 생성하지 못했습니다.");
1113

1214
private final String code;
1315
private final int httpStatus;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.example.Centralthon.domain.order.exception;
2+
3+
import com.example.Centralthon.global.exception.BaseException;
4+
5+
public class OrderExpiredException extends BaseException {
6+
public OrderExpiredException() {
7+
super(OrderErrorCode.ORDER_EXPIRED);
8+
}
9+
}

0 commit comments

Comments
 (0)