Manager is a product and order management API coded in Go. This API provides a simple and efficient way to manage products and orders in a system.
- Product Management: Add, update, delete, and retrieve product information.
- Order Management: Create, update, delete, and retrieve orders.
To install and run the project, follow these steps:
-
Clone the repository:
git clone https://github.com/ice777x/manager.git cd manager -
Set up your environment variables: Create a
.envfile in the root directory and add the following:DB_NAME=db_name DB_USER=user DB_PASS=passs DB_HOST=host -
Build the project:
go build
-
Run the project:
./manager
Once the project is running, you can use the following endpoints to interact with the API:
- POST
/api/signup: Create a new user. - POTS
/api/login: Login as user.
- GET
/api/products: Retrieve all products. - GET
/api/products?id=1,2,3: Retrieve a product by ID. - POST
/api/products: Create a new product. - PUT
/api/products/1: Update a product by ID. - DELETE
/api/products?id=5,6: Delete a product by ID.
- GET
/api/orders: Retrieve all orders. - GET
/api/orders?id=1,2,3,4: Retrieve an order by ID. - POST
/api/orders: Create a new order. - PUT
/api/orders/1: Update an order by ID. - DELETE
/api/orders?id=4: Delete an order by ID.
- GET
/api/categories: Retrieve all orders. - GET
/api/categories?id=1,2,3,4: Retrieve an order by ID. - POST
/api/categories: Create a new order. - PUT
/api/categories/1: Update an order by ID. - DELETE
/api/categories?id=4: Delete an order by ID.
- GET
/api/customers: Retrieve all orders. - GET
/api/customers?id=1,2,3,4: Retrieve an order by ID. - POST
/api/customers: Create a new order. - PUT
/api/customers/1: Update an order by ID. - DELETE
/api/customers?id=4: Delete an order by ID.
-
Get a specific product:
curl http://localhost:3000/products?id=1Example Response:
{ "result": [ { "category": { "id": 1, "name": "Masonry & Precast" }, "product": { "id": 1, "name": "Crawler", "stock": 3273, "price": 28496.33, "image": "http://dummyimage.com/152x100.png/5fa2dd/ffffff", "category_id": 1, "created_at": "2024-07-30T10:49:37.984252Z" } } ], "status": 200 } -
Create a new product:
curl -X POST -H "Content-Type: application/json" -d '[{"name":"Çivi", "stock":99, "price":0.25, "image":"civi.jpg", "category_id":1}]' http://localhost:3000/products
{ "result": 2, "status": 200 } -
Update a product:
curl -X PUT -H "Content-Type: application/json" -d '{"name":"Updated Product Name", "price":150}' http://localhost:3000/products/8 { "result": 8, "status": 200 }
-
Delete a product:
curl -X DELETE http://localhost:3000/products?id=5,6,7{ "result": [ 5, 6, 7 ], "status": 200 }
This project is licensed under the MIT License. See the LICENSE file for more details.