Simple app product order with Gin-Gonic HTTP Respons Framework, GORM for Object relation model, PostgreSQL for database.
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 :
- Customer Management (Get with paginate, Get Detail, Insert, Update, Delete, Search)
- Order Management (Get with paginate, Get Detail, Insert, Update, Delete, Search)
- Authentikasi Management (Get Login Data, Insert Login Data)
Notes :
- 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";- 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.
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- Clone the repository
https://github.com/adiet95/go-order-api.git- Install dependencies
go mod tidyWait a minute, if still error run
go mod vendor- 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- 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- Seeding data admin
go run . seedPurpose to login as Admin's Role
{
"email": "admin@gmail.com",
"password": "admin12345678"
}
- Run the app
go run . serveCreate 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)
}
Process Login Request Header
not needed
Request Body
{
"email": <your email> (STRING),
"password": <your password> (STRING)
}
Get Data Costumer Request Header
Bearer Token
Request Body
not needed
Request Query Params
limit = (limit for pagination)
offset = (offset for pagination)
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
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 Data Costumer Request Header
Bearer Token
Request Body
no need
Request Query Params
email = (Delete by email)
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 Data Order
Request Header
Bearer Token
Request Body
not needed
Request Query Params
limit = (limit for pagination)
offset = (offset for pagination)
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
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 Data Order
Request Header
Bearer Token
Request Body
no need
Request Query Params
id = (Delete by id)
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)
- Linkedin : Achmad Shiddiq


