Skip to content

Final Project Fazztrack Backend Golang Batch 02

Notifications You must be signed in to change notification settings

adiet95/Final-Project

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

220 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

LECTRON - FINAL PROJECT

ERD (Entity Relation Database)

logo

Table Spesification

USER

user

CART

cart

MIGRATION

migration

PRODUCT

product

CHECK OUT

check out

REVIEW

review

Some commands you should know to run this application

1. go run . serve // to run the app/server
2. go run . migrate -u // for database migration
   go run . migrate -d // for database rollback
3. go run . seed // to seeding data Role admin if you want :

email : "admin@gmail.com"
password : admin12345678

๐Ÿ› ๏ธ Installation Steps

1๏ธโƒฃ Make root folder in your Gopath

github.com/Lectron-Fazztrack

2๏ธโƒฃ Chosee project name "Final-Project"

3๏ธโƒฃ Clone the repository inside the folder that was created "github.com/Lectron-Fazztrack"

git clone https://github.com/Lectron-Fazztrack/Final-Project.git

4๏ธโƒฃ Intstall dependencies

go mod tidy

5๏ธโƒฃ Add Env

DBHOST = DB Host
DBUSER = DB User
DBPASS = DB Password
DBNAME = DB Name
JWT_KEYS = JWT Keys
DBSSL = DB SSL

CLOUD_NAME = Cloud Name
CLOUD_KEY = API Key
CLOUD_SEC = API Secret

6๏ธโƒฃ Database Migration and Rollback

go run . migrate --up // database migrate table

go run . migrate --down //rollback the database

7๏ธโƒฃ Seeding data admin

go run . seed

โžก๏ธ PURPOSE TO LOGIN AS ADMIN'S ROLE { "email" : "admin@gmail.com", "password" : "admin12345678" }

8๏ธโƒฃ Run the app

go run . serve

โš™๏ธ You are all set

==================================================

๐Ÿ”— ROUTE test

๐Ÿ“Œ Authentication Register

route.POST("/register", ctrl.Register)

๐Ÿ”ง Create new Admin :

{
    "name": "<your name>",
    "email": "<your email>",
    "role": "<admin>",
    "password": "<your password>",
    "addres": "<your address>",
    "phone": "<your phone number>",
    "gender": "<male/female>"
}

โœ”๏ธ Respond :

{

"status": "OK",
 "isError": false,
 "data": {
     "id": "<uuid>",
     "name": "<name>",
     "email": "<email>",
     "role": "<admin>",
     "Password": "<generate password>",
     "gender": "<male/female>",
     "date": "<date>",
     "created_at": "<created time>",
     "updated_at": "<updated time>"
 }
}

๐Ÿ”ง Create new User :

{
    "name": "<your name>",
    "email": "<your email>",
    "password": "<your password>",
    "addres": "<your address>",
    "phone": "<your phone number>",
    "gender": "<male/female>"
}

โœ”๏ธ Respond :

{
  "status": "OK",
  "isError": false,
  "data": {
      "id": "<uuid>",
      "name": "<name>",
      "email": "<email>",
      "role": "<user>",
      "Password": "<generate password>",
      "gender": "<male/female>",
      "date": "<date>",
      "created_at": "<created time>",
      "updated_at": "<update time>"
  }
}

โš”๏ธ Request Body :

{
    "name": "<your name>", (STRING)
    "email": "<your email>", (STRING)
    "role": "<admin>", (STRING)
    "password": "<your password>", (STRING)
    "addres": "<your address>", (STRING)
    "phone": "<your phone number>", (INT)
    "gender": "<male/female>" (STRING)
}

==================================================

๐Ÿ“Œ Authentication Login

route.POST("/login", ctrl.Login)

๐Ÿ”ง Proses Login

{
    "email" : "<your email>",
    "password" : "<your password>"
}

โœ”๏ธ Respond :

{
    "status": "OK",
    "isError": false,
    "data": {
        "token": "<your token>"
    }
}

โš”๏ธ Request Body :

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

==================================================

๐Ÿ“Œ Product

โž• Add Product

route.POST("", middleware.CheckAuth(), middleware.CheckAuthor(), middleware.Cloudinary(), ctrl.AddProduct)

โ™พ๏ธ Update Product

route.PUT("/:id", middleware.CheckAuth(), middleware.CheckAuthor(), middleware.Cloudinary(), ctrl.UpdateProduct)

โŒ Delete Product

route.DELETE("/:id", middleware.CheckAuth(), middleware.CheckAuthor(), ctrl.DeleteProduct)

ยฎ๏ธ Get All

route.GET("", ctrl.GetAllProduct)

ยฎ๏ธ Get By Id

route.GET("/:id", ctrl.GetById)

ยฎ๏ธ Get By Type

route.GET("/types/:type", ctrl.GetByType)

โš”๏ธ Request Body :

{
    "name" : "<product name>", (STRING)
    "image" : "<product image>", (STRING)
    "stock" : "<product stock>", (STRING)
    "telphone" : "<your password>", (INT)
    "price" : "<product price>", (INT)
    "type" : "<product type>", (INT)
    "sold" : "<product sold>" (STRING),
    "description" : "<description product>" (STRING)
}

==================================================

๐Ÿ“Œ Cart

โš”๏ธ Request Body :

{
   "product_id" : "<rate>", (INT)
   "amount" : "<comment>" (INT)
}

==================================================

๐Ÿ“Œ Checkout and History

๐Ÿ›’ route.POST("/checkout", ctrl.Checkout)

๐Ÿ“‹ route.GET("/histories", ctrl.Histories)

โš”๏ธ Request Body :

{
    "checkout_name" : "<checkout name>", (STRING)
    "product_id" : "<product id>", (INT)
    "deliv_address" : "<delivery address>", (STRING)
    "telphone" : "<your password>", (INT)
    "notes" : "<notes>", (STRING)
    "discount" : "<product discount>", (INT)
    "amount" : "<amount>", (INT)
    "total" : "<total>", (INT)
    "status" : "<status product>", (STRING)
    "payment" : "<payment>" (STRING)
}

==================================================

๐Ÿ“Œ Review

โž• Add Review

route.POST("/review", middleware.CheckAuth(), ctrl.PostReview)

ยฎ๏ธ Get By Type

route.GET("/review/:id", ctrl.GetReview)

โš”๏ธ Request Body :

{
  "rate" : "<rate>", (INT)
  "comment" : "<comment>" (STRING)
}

==================================================

==================================================

๐Ÿ“Œ Deployment

โž• Deployment on heroku

heroku container:login
heroku create <app-backend-name>
heroku create <app-frontend-name>
heroku git:remote -a <app-backend-name>
heroku git:remote -a <app-frontend-name>
heroku container:push backend --app <app-backend-name>
heroku container:release backend --app <app-backend-name>
heroku container:push frontend --app <app-frontend-name>
heroku container:release frontend --app <app-frontend-name>

==================================================

About

Final Project Fazztrack Backend Golang Batch 02

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 58.9%
  • Go 26.6%
  • CSS 13.1%
  • Other 1.4%