go-order-api

command module
v0.0.0-...-d636fa7 Latest Latest
Warning

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

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

README ΒΆ

Go-Order-API

Simple app product order with Gin-Gonic HTTP Respons Framework, GORM for Object relation model, PostgreSQL for database.

πŸ”— Description

This Backend Application is used for simple order product, in this application there are two models / ERD Schema likes User / Costumer & Products. Also have several features like JWT, Authentification & Authorization. There are 3 main modules :

  1. Customer Management (Get with paginate, Get Detail, Insert, Update, Delete, Search)
  2. Order Management (Get with paginate, Get Detail, Insert, Update, Delete, Search)
  3. Authentikasi Management (Get Login Data, Insert Login Data)

Notes :

  1. I'am using UUID for user_id, don't forget to create extenxion in SQL console after create the database with this query below :
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
  1. In this application there are two types of users (Roles). admins and costumer. Admin can do Costumer Management but Role Costumer can't, Registration page can only register Costumer roles, Admins can only be registered through seeding data.

ERD (Entity Relation Database)

erd.jpg

Table Specification

Costumer's Table

cost.jpg

Order's Table

order.jpg

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
3. go run . seed // to seeding data Role admin if u want Email : "admin@gmail.com" Pass : admin12345678

πŸ› οΈ Installation Steps

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

Wait a minute, if still error run

go mod vendor
  1. Add Env File
  DB_USER = Your DB User
  DB_HOST = Your DB Host
  DB_NAME = Your DB Name
  DB_PASS = Your DB Password
  JWT_KEYS = Your JWT Key
  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. Seeding data admin
go run . seed

Purpose to login as Admin's Role

{
  "email": "admin@gmail.com",
  "password": "admin12345678"
}
  1. Run the app
go run . serve
πŸš€ You are all set

πŸ”— RESTful endpoints

POST /register

Create new user Request Header

not needed

Request Body

{
  "user_name": <your username> (STRING),
  "full_name": <your username> (STRING),
  "email": <your email> (STRING),
  "password": <your password> (STRING),
  "address": <your address> (STRING),
  "phone": <your phone> (STRING)
}
POST /login

Process Login Request Header

not needed

Request Body

{
  "email": <your email> (STRING),
  "password": <your password> (STRING)
}
GET /user

Get Data Costumer Request Header

Bearer Token

Request Body

not needed

Request Query Params

limit = (limit for pagination)
offset = (offset for pagination)
POST /user

Post Data Costumer Request Header

Bearer Token

Request Body

{
    "email" : "(STRING)",
    "password" : "(STRING)",
    "address" : "(STRING)",
    "full_name" : "(STRING)",
    "phone" : "(STRING)"
}

Request Query Params

no need
PUT /user

Update Data Costumer Request Header

Bearer Token

Request Body

{
    "email" : "(STRING)",
    "password" : "(STRING)",
    "address" : "(STRING)",
    "full_name" : "(STRING)",
    "phone" : "(STRING)"
}

Request Query Params

no need
DELETE /user

Delete Data Costumer Request Header

Bearer Token

Request Body

no need

Request Query Params

email = (Delete by email)
GET /user/detail

Get Detail Data Costumer Email

Request Header

Bearer Token

Request Body

no need

Request Query Params

email = (Get detail data by email)

Search Data Costumer by Full_Name

Request Header

Bearer Token

Request Body

no need

Request Query Params

name = (Search data by full_name)
GET /order

Get Data Order

Request Header

Bearer Token

Request Body

not needed

Request Query Params

limit = (limit for pagination)
offset = (offset for pagination)
POST /order

Post Data Order

Request Header

Bearer Token

Request Body

{
    "order_name" : "Test",
    "invoice" : "test inv",
    "address" : "test address",
    "telphone" : "0813",
    "amount" : 2,
    "price" : 10000,
    "status" : "paid"
}

Request Query Params

no need
PUT /order

Update Data Order

Request Header

Bearer Token

Request Body

{
    "order_name" : "Test",
    "invoice" : "test inv",
    "address" : "test address",
    "telphone" : "0813",
    "amount" : 2,
    "price" : 10000,
    "status" : "paid"
}

Request Query Params

id = (id you want to update)
DELETE /order

Delete Data Order

Request Header

Bearer Token

Request Body

no need

Request Query Params

id = (Delete by id)
GET /order/detail

Get Data Detail by ID

Request Header

Bearer Token

Request Body

no need

Request Query Params

id = (Get detail data by id)

Search Data Order by Name

Request Header

Bearer Token

Request Body

no need

Request Query Params

name = (Search data by name)

πŸ’» Built with

πŸš€ About Me

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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