Skip to content

Commit

Permalink
BE 영수증 주문번호 수정 (#106)
Browse files Browse the repository at this point in the history
* [BE] README 수정 (#34)

* chore : 로컬 환경 세팅 h2 의존성추가 , mysql 연결 추가

* docs : README ERD 추가

* [BE] ci/cd 디렉토리 생성 (#40)

* chore : 로컬 환경 세팅 h2 의존성추가 , mysql 연결 추가

* docs : README ERD 추가

* chore : ci/cd 환경 세팅

* [be] feat #54 : 상단바 카테고리 조회 api (#55)

* [BE] 카테고리별 메뉴 조회 API 구현 (#65)

* [BE] feat #63: Json 형식에 맞게 DTO 만들기

* [BE] feat #63: builder 어노테이션 추가

* [BE] feat #63: 카테고리별 메뉴 조회 Controller, Service, Repository 구현

* [BE] feat #66 메뉴담기 화면 조회 API  (#67)

* [BE] feat #66: dto 생성

* [BE] feat #66: 메뉴담기 화면 조회 controller 생성

* [BE] feat #66: 메뉴담기 화면 조회 repository 생

* [BE] feat #66: 메뉴담기 화면 조회 service 생

---------

Co-authored-by: he2joo <[email protected]>

* [BE] 주문 api 구현 (#64)

* [be] feat #59 : OrderRequestDto 생성

* [be] feat #59 : 도메인에 Builder 추가

* [be] feat #59 : Orders 테이블 Insert,날짜 비교 후 주문번호 초기화 구현

* [be] feat #59 : OrderMenu 테이블 INSERT , ORDER_MENU_OPTION 테이블 INSERT 구현

* [BE] feat #69: 영수증 조회 api 구현 (#70)

* [BE] feat #59: 결제 API 구현 (#71)

* [BE] feat #59: @NoArgsConstructor 어노테이션 추가

* [BE] feat #59: Controller 결제 API 구현

* [BE] feat #59: Service 결제 API 구현

* [BE] feat #59: Repository 결제 API 구현

* [BE] feat #59: 카드 결제 실패 (#74)

Co-authored-by: he2joo <[email protected]>

* feat #59: 현금결제 ResponseDto 생성 (#73)

Co-authored-by: HeeJu Cho <[email protected]>

* [BE] feat #59: 카드 결제  (#75)

* [BE] feat #69: 영수증 조회 api 구현

* [BE] feat #59: 카드 결제 메서드 구현

* fix #59: merge 수정 (#76)

* [BE] #59 결제/주문 api 구현 완료 (#77)

* fix #59: 주문 insert 방식 수정

* fix #59: 주문번호 초기화 메서드 수정

* refactor #59: 결제 성공시 보내는 responseDto에 주문번호 추가

* refactor #59: dto 부분 수정

* refactor #59: 결제/주문 저장 api 완료

* [BE] #59 결제로직 수정 (#78)

* refactor #59: 결제 response 통합

* refactor #59: 결제 성공시 orderId 반환하게 변경

* style #59: 결제 컨트롤러 메서드명 수정

* [BE] refactor #63: getPopularityRanking() 메서드 수정 (#86)

당일 판매량이 없을 경우 테이블 값이 아예 없어 오류가 발생. Optional을 사용하여 첫번째 값만 받아오고 null일 경우 menuId가 0이 되도록 하여 인기 스티커가 아무곳에도 붙지 않도록 수정.

* [BE] feat #92: cors 추가 (#94)

Co-authored-by: he2joo <[email protected]>

* [Be] feat #92 : cors 메서드 추가 (#99)

* [BE] refactor #92: WebConfig 수정

* [BE] refactor #92: OrderRepository sql문 수정

* [BE] refactor #69: 영수증 조회 api 리팩토링 (#100)

* [BE] refactor #69: DB에서 orderNumber, name, quantity를 가져오는 DTO 구현

* [BE] refactor #69: 영수증 조회를 위해 orderNumber를 반환하도록 Repository, Service 리팩토링

---------

Co-authored-by: Jeongwisdom <[email protected]>
Co-authored-by: HeeJu Cho <[email protected]>
Co-authored-by: he2joo <[email protected]>
Co-authored-by: sejeong00 <[email protected]>
  • Loading branch information
5 people authored Jul 5, 2023
1 parent 9b86c69 commit b7ff7da
Show file tree
Hide file tree
Showing 22 changed files with 649 additions and 15 deletions.
22 changes: 22 additions & 0 deletions be/src/main/java/com/codesquad/kiosk/config/WebConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.codesquad.kiosk.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig {
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/api/**").allowedOrigins("http://localhost:3000")
.allowedMethods(HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.HEAD.name(),
HttpMethod.PUT.name(), HttpMethod.DELETE.name(), HttpMethod.OPTIONS.name());
}
};
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package com.codesquad.kiosk.controller;

import com.codesquad.kiosk.dto.CategoryResponseDto;
import com.codesquad.kiosk.dto.MenuDetailDto;
import com.codesquad.kiosk.dto.MenusByCategoryResponseDto;
import com.codesquad.kiosk.service.MenuService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
public class MenuController {
Expand All @@ -16,13 +22,26 @@ public class MenuController {

@ApiOperation(value = "카테고리별 메뉴 전체 조회")
@GetMapping("api/menus/{categoryId}")
public ResponseEntity getMenusByCategory(@PathVariable Integer categoryId) {
return null;
public ResponseEntity<List<MenusByCategoryResponseDto>> getMenusByCategory(@PathVariable Integer categoryId) {
List<MenusByCategoryResponseDto> menus = menuService.getMenusByCategory(categoryId);
return ResponseEntity.status(HttpStatus.OK).body(menus);
}

@ApiOperation(value = "개별 메뉴 조회")
@GetMapping("api/carts/{menuId}")
public ResponseEntity getMenuDetail(@PathVariable Integer menuId){
return null;
@GetMapping("api/menuInfo/{menuId}")
public ResponseEntity<MenuDetailDto> getMenuDetail(@PathVariable Integer menuId){
try {
MenuDetailDto menuDetailDto = menuService.getMenuDetail(menuId);
return ResponseEntity.status(HttpStatus.OK).body(menuDetailDto);
} catch (IllegalArgumentException e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
}
}

@ApiOperation(value = "상단 바 출력")
@GetMapping("api/categories")
public ResponseEntity<List<CategoryResponseDto>> getCategories() {
List<CategoryResponseDto> categories = menuService.getCategories();
return ResponseEntity.status(HttpStatus.OK).body(categories);
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
package com.codesquad.kiosk.controller;

import com.codesquad.kiosk.service.OrderService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import com.codesquad.kiosk.dto.PaymentFailedDto;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.codesquad.kiosk.dto.OrderRequestDto;
import com.codesquad.kiosk.dto.ReceiptDto;
import com.codesquad.kiosk.service.OrderService;

import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;

import java.util.Optional;

@RestController
@RequiredArgsConstructor
public class OrderController {
Expand All @@ -17,13 +26,28 @@ public class OrderController {

@ApiOperation(value = "결제")
@PostMapping("api/payments/{method}")
public ResponseEntity pay(@PathVariable String method) {
return null;
public ResponseEntity<?> pay(@PathVariable String method, @RequestBody OrderRequestDto orderRequestDto) {
int amountOfPay = orderService.calculateOrder(orderRequestDto);
PaymentFailedDto paymentFailedDto = orderService.paymentFail(amountOfPay);
if(method.equals("cash")) {
int orderId = orderService.saveOrder(orderRequestDto);
return ResponseEntity.status(HttpStatus.OK)
.body(orderService.paymentResponse(orderId,amountOfPay,orderRequestDto));
}

return Optional.ofNullable(paymentFailedDto)
.<ResponseEntity<?>>map(dto -> ResponseEntity.status(HttpStatus.BAD_REQUEST).body(dto))
.orElseGet(() -> {
int orderId = orderService.saveOrder(orderRequestDto);
return ResponseEntity.status(HttpStatus.OK)
.body(orderService.paymentResponse(orderId,amountOfPay,orderRequestDto));
});
}

@ApiOperation(value = "개별 주문 상세 조회")
@GetMapping("api/receipts/{orderId}")
public ResponseEntity getOrderDetail(@PathVariable Integer orderId){
return null;
ReceiptDto receipt = orderService.getReceiptByOrderId(orderId);
return ResponseEntity.status(HttpStatus.OK).body(receipt);
}
}
2 changes: 2 additions & 0 deletions be/src/main/java/com/codesquad/kiosk/domain/Menu.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.codesquad.kiosk.domain;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

@Getter
@AllArgsConstructor
@Builder
public class Menu {
Integer id;
String name;
Expand Down
10 changes: 8 additions & 2 deletions be/src/main/java/com/codesquad/kiosk/domain/Order.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package com.codesquad.kiosk.domain;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

import java.sql.Timestamp;

@Getter
@AllArgsConstructor
public class Order {
Integer id;
Integer orderNumber;
Timestamp orderTime;
String orderTime;

@Builder
public Order(Integer orderNumber, String orderTime) {
this.orderNumber = orderNumber;
this.orderTime = orderTime;
}
}
8 changes: 8 additions & 0 deletions be/src/main/java/com/codesquad/kiosk/domain/OrderMenu.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package com.codesquad.kiosk.domain;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

@Getter
@AllArgsConstructor
@Builder
public class OrderMenu {
Integer id;
Integer orderId;
Integer menuId;
Integer quantity;

@Builder
public OrderMenu(Integer menuId, Integer quantity) {
this.menuId = menuId;
this.quantity = quantity;
}
}
10 changes: 10 additions & 0 deletions be/src/main/java/com/codesquad/kiosk/dto/CategoryResponseDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.codesquad.kiosk.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class CategoryResponseDto {
String name;
}
19 changes: 19 additions & 0 deletions be/src/main/java/com/codesquad/kiosk/dto/MenuDetailDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.codesquad.kiosk.dto;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;

@Setter
@Getter
@NoArgsConstructor
public class MenuDetailDto {

private String name;
private int price;
private String img;
private List<OptionCategoryDto> option;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.codesquad.kiosk.dto;

import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class MenusByCategoryResponseDto {
private String name;
private Integer price;
private Integer menuId;
private String img;
private boolean popular;

public void setPopular() {
popular = true;
}
}
16 changes: 16 additions & 0 deletions be/src/main/java/com/codesquad/kiosk/dto/OptionCategoryDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.codesquad.kiosk.dto;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;


@Setter
@Getter
@NoArgsConstructor
public class OptionCategoryDto {
private String optionCategoryType;
private int optionId;
private String optionName;
private int optionPrice;
}
16 changes: 16 additions & 0 deletions be/src/main/java/com/codesquad/kiosk/dto/OrderItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.codesquad.kiosk.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@AllArgsConstructor
@NoArgsConstructor
public class OrderItem {
private int menuId;

private int quantity;

private int[] option;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.codesquad.kiosk.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class OrderNumberCreatorDto {
private String date;
private int orderNumber;
}
16 changes: 16 additions & 0 deletions be/src/main/java/com/codesquad/kiosk/dto/OrderRequestDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.codesquad.kiosk.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.List;

@Getter
@AllArgsConstructor
@NoArgsConstructor
public class OrderRequestDto {

private List<OrderItem> orderList;
private int inputMoney;
}
15 changes: 15 additions & 0 deletions be/src/main/java/com/codesquad/kiosk/dto/PaymentFailedDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.codesquad.kiosk.dto;

import lombok.Getter;
@Getter
public class PaymentFailedDto {

private boolean result;

private String cause;

public PaymentFailedDto(String cause) {
this.result = false;
this.cause = cause;
}
}
19 changes: 19 additions & 0 deletions be/src/main/java/com/codesquad/kiosk/dto/PaymentResponseDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.codesquad.kiosk.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class PaymentResponseDto {

private boolean result;
private int changes;
private int totalPay;
private int orderId;

}
13 changes: 13 additions & 0 deletions be/src/main/java/com/codesquad/kiosk/dto/ReceiptDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.codesquad.kiosk.dto;

import java.util.List;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public class ReceiptDto {
final Integer orderNumber;
final List<ReceiptItemDto> orderList;
}
11 changes: 11 additions & 0 deletions be/src/main/java/com/codesquad/kiosk/dto/ReceiptItemDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.codesquad.kiosk.dto;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public class ReceiptItemDto {
final String name;
final Integer quantity;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.codesquad.kiosk.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class ReceiptOrderNumberDto {
final Integer orderNumber;
final String name;
final Integer quantity;
}
Loading

0 comments on commit b7ff7da

Please sign in to comment.