Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

Commit

Permalink
#66 1차 리뷰 반영 및 충돌 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
ypr821 authored and YPR committed Feb 7, 2022
2 parents 601c4f9 + 9d6a00f commit 18e8c0b
Show file tree
Hide file tree
Showing 49 changed files with 1,105 additions and 55 deletions.
1 change: 1 addition & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
MYSQL_DBNAME: ${{ secrets.MYSQL_DBNAME }}
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
MYSQL_USERNAME: ${{ secrets.MYSQL_USERNAME }}
AUTHORIZATION: ${{ secrets.AUTHORIZATION }}
run: ./gradlew build
working-directory: ${{ env.working-directory }}
- name: build result to slack
Expand Down
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,68 @@
# DoorRush


<img width="600" alt="README 이미지_2" src="https://user-images.githubusercontent.com/56250078/151295612-86d6cf93-49ea-4c92-ba8a-d3c7c55d2400.png">

#### "Restaurnts and more, delivered to your door!"

#### Door Dash, 배달의 민족을 모티브로 만든 배달 플랫폼 API 서버 프로젝트입니다.


<br><br>

### ![:풍선:](https://a.slack-edge.com/production-standard-emoji-assets/13.0/google-medium/[email protected]) **목표**

- Door Dash/ 배달의 민족와 같은 배달 앱 서비스를 구현해 내는 것이 목표입니다.
- 유지보수성을 위해 객체지향적 설계와 이론을 바탕으로 클린한 코드를 작성하는 것이 목표입니다.
- 단순한 기능 구현뿐 아니라 대용량 트래픽 처리까지 고려한 기능을 구현하는 것이 목표입니다.
- 테스트를 높은 우선순위를 두어 작성하여 Code Coverage 70%를 유지하고 있습니다.
- CI/CD를 통한 자동화를 구현하여 쉽게 협업이 가능한 프로젝트로 만들고 있습니다.
- Github, Slack을 통한 활발한 소통을 바탕으로 효율적인 협업을 추구합니다.

<br><br>

### ![:축구공:](https://a.slack-edge.com/production-standard-emoji-assets/13.0/google-medium/[email protected]) 기술적 이슈와 해결 과정

- [외부 API가 응답 코드조차 보낼 수 없는 장애가 발생했다면? Circuit Breaker Pattern로 해결하기](https://github.com/f-lab-edu/DoorRush/issues/67) <br>

- [인증 기능에는 어떤 기술을 사용해야 할까?](https://github.com/ypr821/TIL/blob/main/2022_01/%EC%9D%B8%EC%A6%9D(Authentication)%EA%B3%BC_%EC%9D%B8%EA%B0%80(Authorization).md) <br>

- [인증 관련 보안 이슈](https://github.com/ypr821/TIL/blob/main/2022_01/%EC%9E%90%EB%8F%99%EB%A1%9C%EA%B7%B8%EC%9D%B8%EA%B8%B0%EB%8A%A5_%EB%B3%B4%EC%95%88%EC%9D%B4%EC%8A%88_%EA%B3%A0%EB%AF%BC.md) <br>

- [로그인 체크는 어떻게 하면 좋을까?](https://dev-promise.tistory.com/entry/%EB%A1%9C%EA%B7%B8%EC%9D%B8-%EC%B2%B4%ED%81%AC%EB%A5%BC-%EC%9C%84%ED%95%9C-%EA%B8%B0%EC%88%A0%EC%A0%81-%EA%B3%A0%EB%AF%BC)
<br>



<br><br>

### ![:렌치:](https://a.slack-edge.com/production-standard-emoji-assets/13.0/google-medium/[email protected]) **기술 스택**

### **Java 11, Spring Boot 2.5.6, Spring MVC, MyBatis, gradle, MySQL**






<br><br>

### ![:책갈피_탭:](https://a.slack-edge.com/production-standard-emoji-assets/13.0/google-large/[email protected])**ERD**

![image](https://user-images.githubusercontent.com/56250078/152634236-79887af9-5b27-4265-ba99-e737e57c6016.png)


<br><br>

### 주요 기능 시퀀스 다이어그램

- 로그인 기능
![로그인시퀀스다이어그램](https://user-images.githubusercontent.com/56250078/152634301-141280e0-93ec-4b59-87e6-1f5c4f229603.png)




<br><br>
### ![:구급차:](https://a.slack-edge.com/production-standard-emoji-assets/13.0/google-large/[email protected]) 서버 구조도
- 링크 업데이트 예정

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jacoco {
dependencies {
/* spring-boot-starter-web : Spring MVC 를 사용한 restful 서비스를 개발하는데 사용합니다. */
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-aop:2.6.2'
implementation 'org.springframework.boot:spring-boot-starter-aop'
/* spring-boot-starter-test : JUnit Jupiter, Hamcrest 및 Mockito 를 포함한 라이브러리로 Spring Boot 애플리케이션을 테스트하기 위한 스타터 */
implementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.springframework.boot:spring-boot-starter-validation'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

@Component
@Aspect
Expand All @@ -18,7 +19,7 @@ public class CheckLoginAspect {
@Before("@annotation(com.flab.doorrush.domain.authentication.annotation.CheckLogin)")
public void checkLogin() throws AuthenticationCredentialsNotFoundException {
String currentId = (String) httpSession.getAttribute(AuthenticationService.LOGIN_SESSION);
if (currentId == null || currentId.equals("null")) {
if (!StringUtils.hasLength(currentId)) {
throw new AuthenticationCredentialsNotFoundException("로그인이 필요합니다.");
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.flab.doorrush.domain.order.api;

import com.flab.doorrush.domain.order.dto.request.MenuDTO;
import com.flab.doorrush.domain.order.dto.request.OrderRequest;
import com.flab.doorrush.domain.order.dto.response.CreateOrderResponse;
import com.flab.doorrush.domain.order.dto.response.OrderMenusCartResponse;
import com.flab.doorrush.domain.order.service.OrderService;
import com.flab.doorrush.global.Response.BasicResponse;
import java.util.List;
import javax.servlet.http.HttpSession;
import javax.validation.Valid;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/orders/")
@RequiredArgsConstructor
public class OrderController {

private final OrderService orderService;

@GetMapping("check-price")
public ResponseEntity<BasicResponse<OrderMenusCartResponse>> checkPrice(@RequestBody @Valid List<MenuDTO> menus) {
return ResponseEntity.status(HttpStatus.OK)
.body(BasicResponse.success(orderService.getTotalPrice(menus)));
}

@PostMapping
public ResponseEntity<BasicResponse<CreateOrderResponse>> createOrder(
@RequestBody @Valid OrderRequest orderRequest,
HttpSession session) {
CreateOrderResponse response = orderService.createOrder(orderRequest,
session.getAttribute("loginId").toString());
return ResponseEntity.status(HttpStatus.CREATED).body(BasicResponse.success(response)
);
}
}
22 changes: 22 additions & 0 deletions src/main/java/com/flab/doorrush/domain/order/dao/OrderMapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.flab.doorrush.domain.order.dao;

import com.flab.doorrush.domain.order.domain.Order;
import com.flab.doorrush.domain.order.domain.OrderMenu;
import com.flab.doorrush.domain.order.dto.request.MenuDTO;
import com.flab.doorrush.domain.order.dto.response.OrderHistory;
import com.flab.doorrush.domain.order.dto.response.OrderMenuPrice;
import java.util.List;
import java.util.Optional;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface OrderMapper {

void insertOrder(Order order);

void insertOrderMenu(List<OrderMenu> orderMenus);

List<OrderHistory> selectOrderBySeq(Long orderSeq);

Optional<OrderMenuPrice> selectPriceByMenuDTO(MenuDTO menuDTO);
}
20 changes: 20 additions & 0 deletions src/main/java/com/flab/doorrush/domain/order/domain/Order.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.flab.doorrush.domain.order.domain;

import java.time.LocalDateTime;
import lombok.Builder;
import lombok.Getter;

@Builder
@Getter
public class Order {

private Long orderSeq;
private Long userSeq;
private String address;
private Long restaurantSeq;
private String restaurantName;
private OrderStatus orderStatus;
private Long amount;
private LocalDateTime orderTime;

}
16 changes: 16 additions & 0 deletions src/main/java/com/flab/doorrush/domain/order/domain/OrderMenu.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.flab.doorrush.domain.order.domain;

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

@Getter
@Builder
@AllArgsConstructor
public class OrderMenu {

private Long menuSeq;
private Long orderSeq;
private int count;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.flab.doorrush.domain.order.domain;

public enum OrderStatus {
READY, REQUEST_PAY, APPROVAL_PAY, COMPLETE_PAY, CANCEL ;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.flab.doorrush.domain.order.dto.request;

import com.flab.doorrush.domain.order.domain.OrderMenu;
import javax.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
@AllArgsConstructor
public class MenuDTO {
@NotNull
private Long menuSeq;
@NotNull
private int count;

public OrderMenu toEntity(Long orderSeq){
return OrderMenu.builder()
.menuSeq(this.menuSeq)
.orderSeq(orderSeq)
.count(this.count)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.flab.doorrush.domain.order.dto.request;

import java.util.List;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class OrderRequest {

@NotEmpty
@NotNull
private List<MenuDTO> menus;
@NotNull
private Long restaurantSeq;
@NotNull
private Long addressSeq;
@NotNull
private Long amount;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.flab.doorrush.domain.order.dto.response;

import com.flab.doorrush.domain.order.domain.Order;
import lombok.Builder;
import lombok.Getter;

@Builder
@Getter
public class CreateOrderResponse {

private Order order;

public static CreateOrderResponse from(Order order) {
return CreateOrderResponse.builder()
.order(order)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.flab.doorrush.domain.order.dto.response;

import com.flab.doorrush.domain.order.domain.OrderStatus;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
@AllArgsConstructor
public class OrderHistory {

private Long orderSeq;
private String address;
private Long restaurantSeq;
private String restaurantName;
private Long amount;
private OrderStatus orderStatus;
private String menuName;
private String menuPrice;
private String menuCount;
private LocalDateTime orderTime;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.flab.doorrush.domain.order.dto.response;

import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class OrderMenuPrice {

private String name;
private Long price;
private Long menuSumPrice;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.flab.doorrush.domain.order.dto.response;

import java.util.List;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class OrderMenusCartResponse {
private Long totalPrice;
private List<OrderMenuPrice> orderMenuCarts;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.flab.doorrush.domain.order.exception;

public class OrderException extends RuntimeException {

public OrderException(String message) {
super(message);
}

}
Loading

0 comments on commit 18e8c0b

Please sign in to comment.