Skip to content

codestates/WBABEProject-22

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Online ordering system

Minimal API for online ordering in Go

Install

  1. Start MongoDB database.
docker pull mongo
docker run --name mongodb -d -p 27017:27017 mongo
  1. Start HTTP server.
git clone https://github.com/codestates/WBABEProject-22.git oos
cd oos
go mod init
go mod tidy
swag init
go run main.go
  1. Start web browser and go to http://localhost:8080/swagger/index.html.
  2. Login as a customer or provider and try endpoints.

Tech stack

Project layout

  • config: TOML configuration
  • logger: Zap log generator
  • db: MongoDB database and collections
  • dto: data transfer objects for requests and responses
  • model: data entities
  • controller: request handlers
  • service: business logic that interacts with DB
  • router: HTTP server that connects HTTP method, URL path, and request handler
  • middleware: custom middleware (e.g. CORS, authentication, authorization, etc)
  • docs: OAS2 documentation generated by swaggo
  • logs: Log files generated by Zap

Features

  • Customer: 주문자
    • Query available products and my orders
    • Submit orders to providers
    • Give feedbacks on products and orders by writing reviews
  • Provider: 피주문자
    • Query all products and orders
    • Create products
    • Change order status

Customer

Category HTTP Method URL Path Description
Product GET /products 메뉴 전체 조회
Product GET /products/{code} 메뉴 하나 조회
Order GET /{username}/orders/active 현재 주문 내역 전체 조회
Order GET /{username}/orders/history 과거 주문 내역 전체 조회
Order GET /orders/{id} 주문 조회
Order POST /orders 주문
Order PUT /orders/{id}/cart 메뉴 추가 및 변경
Order DELETE /orders/{id}/cart 메뉴 취소
Order GET /orders/{id}/status 주문 상태 조회
Review GET /reviews/orders/{id} 평점 및 리뷰 조회
Review POST /review/products/{code} 평점 및 리뷰 작성

Provider

Category HTTP Method URL Path Description
Product POST /products 신규 메뉴 등록
Product PUT /products/{code} 기존 메뉴 수정
Product DELETE /products/{code} 기존 메뉴 삭제
Order GET /orders 주문 내역 전체 조회
Order PUT /orders/{id}/status 주문 상태 변경
Review GET /reviews/orders 리뷰 모두 조회

References

Changelog

  • 2023-01-18
    • New feature: Sort products by the following variables:
      • Date of creation
      • Average rating
      • Number of likes
      • Number of follow-up orders
    • New feature: Authorization using JWT
      • Middleware for validation of JWT format
      • Middleware for role-based access control using the scope field in JWT payload
    • New feature: Mock authentication that generates a simple JWT access token
      • Customer
      • Provider
    • Refactoring: model and dto
      • Input validation (through struct tags) isolated to dto
      • Separate *View structs to select fields to return to users

About

Simple online ordering system in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages