manager

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

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

Go to latest
Published: Sep 10, 2024 License: MIT Imports: 9 Imported by: 0

README

MANAGER

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.

license last-commit repo-top-language repo-language-count

Go PostgreSQL


📦 Features

  • Product Management: Add, update, delete, and retrieve product information.
  • Order Management: Create, update, delete, and retrieve orders.

⚙️ Installation

To install and run the project, follow these steps:

  1. Clone the repository:

    git clone https://github.com/ice777x/manager.git
    cd manager
    
  2. Set up your environment variables: Create a .env file in the root directory and add the following:

    DB_NAME=db_name
    DB_USER=user
    DB_PASS=passs
    DB_HOST=host
    
  3. Build the project:

    go build
    
  4. Run the project:

    ./manager
    

🚀 Usage

Once the project is running, you can use the following endpoints to interact with the API:

Users

  • POST /api/signup: Create a new user.
  • POTS /api/login: Login as user.

Products

  • 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.

Orders

  • 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.

Categories

  • 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.

Customers

  • 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.

Example Requests

  • Get a specific product:

    curl http://localhost:3000/products?id=1
    

    Example 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
    }
    

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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