Skip to content

맛집관리, 리뷰 및 별점 관리 REST API (backend)

Notifications You must be signed in to change notification settings

ksm1569/RestaurantReview

Repository files navigation

맛집리뷰 API

✨ 개발 목적 및 개요

맛집관리, 리뷰 및 별점 관리를 통한 토이 프로젝트로 공부목적

  • REST API 이해
  • SPRING BOOT 공부 - 어노테이션, H2 Database 등 이해
  • Spring Data JPA 공부 - Repository, QueryDSL, Pageable, Slice 등 이해
  • Docker 및 AWS 배포를 통한 공부 및 기록

🔨 사용한 프레임웍, 라이브러리 및 툴

  • IntelliJ Ultimate
  • Postman
  • Docker
  • JAVA 17
  • Lombok
  • Spring Boot
  • AWS EC2

✍ Flow

  • 맛집을 조회, 등록, 수정, 삭제 할 수 있다.
  • 맛집에 등록된 리뷰를 조회, 등록, 삭제 할 수 있다.
  • 맛집에 등록된 평균 별점을 조회 할 수 있다.

📜 ERD

👨‍💻 Entity Code

접기/펼치기 버튼
  • restaurant

  • menu

  • review

🧑‍💻 Mapping spec

접기/펼치기 버튼



  • 맛집 리스트 전체 조회

GET /restaurants

[
  {
    "id": Long,
    "name": string,
    "address": string,
    "createdAt": string,
    "updatedAt": string
  },
]



  • 해당 맛집 정보 조회

GET /restaurant/{restaurantId}

{
  "id": Long,
  "name": string,
  "address": string,
  "createdAt": string,
  "updatedAt": string,
  "menus": [
    {"id": Long, "name": string, "price": int, "createdAt": string, "updatedAt": string},
    {"id": Long, "name": string, "price": int, "createdAt": string, "updatedAt": string},
  ]
}



  • 맛집 등록

POST /restaurant

{
  "name": string,
  "address": string,
  "menus": [
    {"name": string, "price": int},
  ]
}



  • 맛집 수정

PUT /restaurant/{restaurantId}

{
  "name": string,
  "address": string,
  "menus": [
    {"name": string, "price": int},
  ]
}



  • 맛집 삭제

DELETE /restaurant/{restaurantId}



  • 리뷰 등록

POST /review

{
  "restaurantId": int,
  "content": string,
  "score": float
}



  • 리뷰 삭제

DELETE /review/{reviewId}

  • 맛집에 등록된 전체 리뷰 조회

GET /restaurant/{restaurantId}/reviews

{
  "avgScore": float, // 평균 별점
  "reviews": [
    {"id": int, "content": string, "score": float, "createdAt": string},
    {"id": int, "content": string, "score": float, "createdAt": string},
    {"id": int, "content": string, "score": float, "createdAt": string}
  ],
  "page": {
    "offset": int,
    "limit": int
  }
}



☑ API 통신 테스트, 데이터베이스 확인

접기/펼치기 버튼
  • API테스트

  • 맛집 테이블 조회

  • 리뷰 테이블 조회

⚙ Docker, AWS 설정

접기/펼치기 버튼
// application.properties
spring.h2.console.settings.web-allow-others=true
# Dockerfile

FROM amazoncorretto:17

WORKDIR /app

COPY ./build/libs/review-0.0.1-SNAPSHOT.jar /app/review.jar
COPY ./entry-point.sh /app/entry-point.sh
RUN chmod +x /app/entry-point.sh

ENTRYPOINT ["./entry-point.sh"]
# entry-point.sh

#!/bin/bash

java -jar /app/review.jar
# docker-compose.yml

version: "3.8"

services:
  review-api:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - 8080:8080
# Docker Contianer Image 빌드하기
$ docker build -t review-api ./

# Docker Container 실행하기
$ docker run -it -p 8080:8080 review-api

# Docker Compose 실행하기
$ docker-compose up --build

AWS EC2 인스턴스 만들고 -> 인바운드 규칙에 포트 설정 후 -> git 설치끝나면 clone 해준다음에 설정 사항들

# git, docker, jdk 설치
$ sudo yum install -y git docker java-17-amazon-corretto

# docker-compose 설치
$ sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose

# 도커 실행
$ sudo service docker start

# 자바 애플리케이션 빌드
$ ./gradlew bootJar

# 서버 실행
$ sudo docker-compose up --build

# 서버 백그라운드 실행
$ sudo docker-compose up -d --build

✌ 마치며

스프링 프레임워크, 스프링 데이터 JPA라는 기술으로 RESTAPI 통신을 하여,

백엔드단의 기본기를 다지고 복습을 해보는 과정이였다.

까먹은 내용도 있고, AWS 배포부분까지는 해본 적이 없어서 괜찮은 시간이였다고 생각이 든다.

앞으로는 토이 프로젝트들을 깃허브에 넣어두고 기록도 해두어서 틈틈히 들여다봐야겠다.

About

맛집관리, 리뷰 및 별점 관리 REST API (backend)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages