go-cart

command module
v0.0.0-...-423f668 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2022 License: MIT Imports: 4 Imported by: 0

README ΒΆ

Go-Cart

Mini Service Shopping Cart with Gin-Gonic HTTP Respons Framework, GORM for Object relation model, PostgreSQL for database.

πŸ”— Description

This Backend Service Shopping Cart is used for simple add product to cart. There are 3 main routers :

  1. Add Cart (Can add product if product is no exist also update quantity product if name product exist)

Attributes ProductCode, ProductName, Quantity 2. Delete Product (Delete by prodcut code) 3. Get Product (Get all product, Get by product name, Get by quantity)

Notes :

  1. I'am using UUID for cart_id, don't forget to create extenxions in SQL console after create the database with this query below :
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
  1. For answers no. 01 & 02, i put it in a folder soal_01 & soal_02, change directory to folder and run
go run .
  1. For answer no. 03 - 05 i put in a folder soal_03-05, open the .pdf file / .svg

Several command you must know in this app :

1. go run . serve //to run the app / server
2. go run . migrate -u //for database migration
# or
go run . migrate -d //for rollback

πŸ› οΈ Installation Steps

  1. Clone the repository
https://github.com/adiet95/go-cart.git
  1. Install dependencies
go mod tidy

Wait a minute, if still error run :

go mod vendor
  1. Add Env File
  USER = Your DB User
  HOST = Your DB Host
  DB   = Your DB Name
  PASS = Your DB Password
  PORT = Your Port
  1. Database Migration and Rollback
go run main.go migrate --up //for database migration table
# or
go run main.go migrate --down //for rollback the database
  1. Run the app
go run . serve
πŸš€ You are all set

πŸ”— REST API Endpoints

GET /cart

Get Data Cart

Request Body

not needed

Request Query Params

not needed
POST /cart

Post Data Cart

Request Body

{
    "product_code" : "a-03",
    "product_name" : "kabel-1",
    "quantity" : 2
}

Request Query Params

no need
DELETE /cart

Delete Data Cart by Product Code

Request Body

no need

Request Query Params

code = (input product code)
GET /cart/name

Search Data Cart by product name

Request Body

no need

Request Query Params

name = (input product name)
GET /cart/qty

Search Data Cart by quantity

Request Body

no need

Request Query Params

qty = (input quantity)

πŸ’» Built with

πŸš€ About Me

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
src

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL