Required pre-installed apps

  1. Intellij (Community/ Ultimate Edition)
  2. PostgreSQL + pgAdmin
  3. Postman
  4. Any web browser (Google, Microsoft Edge, Firefox)
  5. Github
  6. Docker

Setup Instructions

To set up the backend of the Book Social Network project, follow these steps:

  1. Clone the repository:
   git clone https://github.com/PhuNguyenPT/Shopping_Cart.git
   cd Shopping_Cart
  • Create a new database in pgAdmin 4 with the name shopping_cart
  • Change docker-compose.yml
   environment:
      POSTGRES_PASSWORD: to your database password
  • Change src/main/resources/application.yaml
   datasource:
      password: to your database password
  1. Run the docker-compose file in a terminal
   docker-compose up
  1. Install dependencies (assuming Maven is installed) in a second terminal:
   mvn clean install
  1. Run the application in the second terminal
   java -jar target/shopping-cart-api-0.0.1-SNAPSHOT.jar
  1. Run Postman and send to the register api by POST
   https://localhost:443/api/v1/auth/register
  • Example in Request Body Raw:
{
   "firstName": "firstname",
   "lastName": "lastname",
   "email": "test@gmail.com",
   "password": "password"
}
  1. Use a browser to access to mail server at the URL
   http://localhost:1080
  1. Copy the 6-digit activation code and send to the activate-account api by GET
   // Replace the value with the actual 6-digit activation code
   https://localhost:443/api/v1/auth/activate-account?token=value
  1. Login to the account by POST and receive a token as response
   https://localhost:443/api/v1/auth/login   
  • Example in Request Body Raw:
   {
      "email": "test@gmail.com",
      "password": "password"
   }
  1. Create New Environt by Environments->Create Environment

    create-environment

    • Create new variable token and Save

      save

    • Choose environment to New Environment

      environment

    • Navigate to Response Body in step 8 to select token "value" and right-click to choose Set: New Envinronment -> token:

   {
      "token": "select_this_value"
   }
  1. Access to user home page by GET
   https://localhost:443/api/v1/user/home
  • Go to Authorization->Auth Type->Bearer Token and enter in the box '{{token}}' and Send

    user-home

Admin Account

  • Login by POST
   https://localhost:443/api/v1/auth/login
  • Example in Request Body Raw:
   {
      "email": "admin@email.com",
      "password": "password"
   }

Rest API

  • (USER ONLY) : require user login
  • (ADMIN ONLY) : require admin login
  • (DELIVERER ONLY) : require deliverer login
  • (NON-USER) : no require for login

Authentication

  1. POST: https://localhost/api/v1/auth/register (NON-USER)

    • Register user
    • Request Body
      • Content-Type = application/json

      • Suported attributes for Authentication:

        • firstName
        • lastName
        • email
        • password

      • Attributes constraints for Authentication:

        • firstName : NotEmpty, NotBlank
        • lastName : NotEmpty, NotBlank
        • email : Email, NotEmpty, NotBlank
        • password : NotEmpty, NotBlank, Size(min=8)

      • Attributes explaination for Authentication:

        • firstName : first name
        • lastName : last name
        • email : email
        • password : password

  2. GET: https://localhost:443/api/v1/auth/activate-account?token=value (NON-USER)

    • Use a browser to access to mail server at http://localhost:1080
    • Get the 6-digit code to replace the value in activate-account?token=value above

  3. POST: https://localhost/api/v1/auth/login (NON-USER)

    • Login by email and password
    • Request Body
      • Content-Type = application/json

      • Suported attributes for Authentication:

        • email
        • password

      • Attributes constraints for Authentication:

        • email : Email, NotEmpty, NotBlank
        • password : NotEmpty, NotBlank, Size(min=8)

      • Attributes explaination for Authentication:

        • email : email
        • password : password

MyUser

  1. GET: https://localhost/api/v1/users?page-number=20&page-size=1 (ADMIN ONLY)
    • Find all users attributes available in database

    • Request Body:

      • Suported attributes for MyUser findAll:

        • page-size
        • page-number

      • Attributes constraints for MyUser findAll:

        • page-size : NotNull, Min(1), *Max(20)
        • page-number : NotNull, Min(1)

      • Attributes explaination for Category filter:

        • page-size : maximum number of Products in a page
        • page-number : page number of which page

    • Response Body:

      • Return Page of MyUserResponseDTOList

      • Content-Type = application/json

      • Suported attributes for MyUser:
{
    "content": [
        {
            "message": "",
            "id": 1,
            "firstName": "firstname1",
            "lastName": "lastname1",
            "dateOfBirth": "yyyy-MM-dd",
            "phoneNumber": 987654321,
            "email": "hello1@email.com",
            "addressResponseDTO": {
                "houseNumber": "12",
                "streetName": "street1",
                "wardName": "ward1",
                "city": "city1",
                "zipCode": "zipcode1"
            } 
        },
        {
            "message": "",
            "id": 2,
            "firstName": "firstname2",
            "lastName": "lastname2",
            "dateOfBirth": "yyyy-MM-dd",
            "phoneNumber": 987654321,
            "email": "hello2@email.com",
            "addressResponseDTO": {
                "houseNumber": "12",
                "streetName": "street2",
                "wardName": "ward2",
                "city": "city2",
                "zipCode": "zipcode2"
            } 
        }
    ],
    "page": {
        "size": 20,
        "number": 1,
        "totalElements": 22,
        "totalPages": 2
    }
}



  1. GET: https://localhost/api/v1/users/search/{user-id} (ADMIN ONLY)

    • Search user attributes with user-id
    • Response Body:
      • Content-Type = application/json

      • Suported attributes for MyUser:

        • message
        • id
        • firstName
        • lastName
        • dateOfBirth
        • phoneNumber
        • email
        • addressResponseDTO :
          • houseNumber
          • streetName
          • wardName
          • city
          • zipCode

      • Attributes constraints for MyUser:

        • message : Optional
        • id : Optional
        • firstName : Optional
        • lastName : Optional
        • dateOfBirth : Optional
        • phoneNumber : Optional
        • email : Optional
        • addressResponseDTO :
          • houseNumber : Optional
          • streetName : Optional
          • wardName : Optional
          • city : Optional
          • zipCode : Optional

      • Attributes explaination for MyUser:

        • message : response message
        • id : user UUID
        • firstName : first name
        • lastName : last name
        • dateOfBirth : date of birth
        • phoneNumber : phone number
        • email : email
        • addressResponseDTO :
          • houseNumber : house number
          • streetName : street name
          • wardName : ward name
          • city : city
          • zipCode : zip code

  2. GET: https://localhost/api/v1/users/account (USER ONLY)

    • Find user attributes by User authenticated Bearer Token in AUTHORIZATION
    • Response Body:
      • Content-Type = application/json

      • Suported attributes for MyUser:

        • message
        • id
        • firstName
        • lastName
        • dateOfBirth
        • phoneNumber
        • email
        • addressResponseDTO :
          • houseNumber
          • streetName
          • wardName
          • city
          • zipCode

      • Attributes constraints for MyUser:

        • message : Optional
        • id : Optional
        • firstName : Optional
        • lastName : Optional
        • dateOfBirth : Optional
        • phoneNumber : Optional
        • email : Optional
        • addressResponseDTO :
          • houseNumber : Optional
          • streetName : Optional
          • wardName : Optional
          • city : Optional
          • zipCode : Optional

      • Attributes explaination for MyUser:

        • message : response message
        • id : user UUID
        • firstName : first name
        • lastName : last name
        • dateOfBirth : date of birth
        • phoneNumber : phone number
        • email : email
        • addressResponseDTO :
          • houseNumber : house number
          • streetName : street name
          • wardName : ward name
          • city : city
          • zipCode : zip code

Product

  1. POST: https://localhost/api/v1/products/upload (ADMIN ONLY)
    • Upload Product
    • Request Body:
      • Content-Type = multipart/form-data

      • Suported attributes for Product:
        • name
        • price
        • stockQuantity
        • description
        • categoryIds
        • newCategoryNames
        • files

      • Attributes constraints for Product:
        • name : NotNull, NotBlank
        • price : NotNull, DecimalMin(0.01)
        • stockQuantity : NotNull, Min(0)
        • description : Optional
        • categoryIds : Optional
        • newCategoryNames : Optional
        • files : NotNull

      • Attributes explanation for Product:
        • name : product name
        • price : product price
        • stockQuantity : product stock quantity
        • description : product description
        • categoryIds : saved category ids from database
        • newCategoryNames : new category names to save to database
        • files : "multipart files"

      • Response Body
  {
    "message": "Save product successfully,with categories,with files",
    "id": 7,
    "name": "Example Product 6",
    "price": 10.0,
    "stockQuantity": 100,
    "description": "This is an example description for product 5",
    "createdDate": "2024-06-27T15:36:22.0399524+07:00",
    "lastModifiedDate": null,
    "categoryResponseDTOList": [
      {
        "id": 1,
        "name": "Electronics",
        "productResponseDTOList": null
      },
      {
        "id": 2,
        "name": "Gadgets",
        "productResponseDTOList": null
      }
    ],
    "fileResponseDTOList": [
      {
        "message": null,
        "id": 12,
        "name": "environment.png",
        "fileType": "image/png",
        "size": 6710,
        "fileByte": "byte"
      }
    ]
  }
  1. GET: https://localhost/api/v1/products/search?page-number=1&page-size=20&direction=asc&sort=stock-quantity&product-name=ex
    (NON-USER)
    • Search Product by product-name with page-size, page-number, direction, sort

    • Request parameters:

      • Suported attributes for Product:

        • product-name
        • page-size
        • page-number
        • direction
        • sort

      • Attributes constraints for Product:

        • product-name : Optional
        • page-size : DefaultValue(20), Min(1), *Max(20)
        • page-number : DefaultValue(1), Min(1)
        • direction : DefaultValue("desc")
        • sort : DefaultValue("created-date")

      • Attributes explaination for Product:

        • product-name : product name
        • page-size : page size
        • page-number : page number
        • direction : direction ("asc", "desc")
        • sort : sort attribute ("created-date", "last-modified-date", "amount")

    • Response body:

      • Return ProductResponseDTO
{
  "content": [
    {
      "message": null,
      "id": 2,
      "name": "Example Product 2",
      "price": 99.99,
      "stockQuantity": 70,
      "description": "This is an example description for product 2",
      "createdDate": "2024-06-26T09:48:51.594422+07:00",
      "lastModifiedDate": "2024-06-27T10:58:11.092636+07:00",
      "categoryResponseDTOList": [
        {
          "id": 2,
          "name": "Gadgets",
          "productResponseDTOList": null
        },
        {
          "id": 1,
          "name": "Electronics",
          "productResponseDTOList": null
        }
      ],
      "fileResponseDTOList": [
        {
          "message": null,
          "id": 2,
          "name": "environment.png",
          "fileType": "image/png",
          "size": 6710,
          "fileByte": ""
        }
      ]
    },
    {
      "message": null,
      "id": 1,
      "name": "Example Product 1",
      "price": 99.99,
      "stockQuantity": 90,
      "description": "This is an example description for product 1",
      "createdDate": "2024-06-26T09:48:44.588635+07:00",
      "lastModifiedDate": "2024-06-27T10:58:09.069474+07:00",
      "categoryResponseDTOList": [
        {
          "id": 1,
          "name": "Electronics",
          "productResponseDTOList": null
        },
        {
          "id": 2,
          "name": "Gadgets",
          "productResponseDTOList": null
        }
      ],
      "fileResponseDTOList": [
        {
          "message": null,
          "id": 1,
          "name": "broadcasting.png",
          "fileType": "image/png",
          "size": 54326,
          "fileByte": ""
        }
      ]
    }
  ],
  "page": {
    "size": 20,
    "number": 1,
    "totalElements": 22,
    "totalPages": 2
  }
}
  1. DELETE: https://localhost/api/v1/products/delete/{product-id} (ADMIN ONLY)

    • Delete Product by product-id but do not delete the categories

  2. PUT: https://localhost/api/v1/products/update/{product-id}/files/{file-id} (ADMIN ONLY)

    • Update Files with file-id of Product with product-id by new File

    • Request Body
      • Content-Type = multipart/form-data

      • Suported attributes for Product:

        • files

      • Attributes constraints for Product:

        • files : NotNull

      • Attributes explaination for Product:

        • files : multipart file

  3. POST: https://localhost/api/v1/products/{productId}/files (ADMIN ONLY)

    • Create new File(s) for Product with product-id

    • Request Body
      • Content-Type = multipart/form-data

      • Suported attributes for Product:

        • files

      • Attributes constraints for Product:

        • files : NotNull

      • Attributes explaination for Product:

        • files : multipart file

  4. PATCH: https://localhost/api/v1/products/update/{product-id} (ADMIN ONLY)

    • Update Product attribute(s) with product-id

    • Request Body
      • Content-Type = multipart/form-data

      • Suported attributes for Product:

        • name
        • price
        • stockQuantity
        • description
        • categoryIds

      • Attributes constraints for Product:

        • name : Optional
        • price : Optional
        • stockQuantity : Optional
        • description : Optional
        • categoryIds : Optional

      • Attributes explaination for Product:

        • name : product name
        • price : product price
        • stockQuantity : product stock quantity
        • description : product description
        • categoryIds : saved category ids from database

Category

  1. GET: https://localhost/api/v1/categories (NON-USER)

    • Return all the categories available

    • Response Body
      • Content-Type = application/json

      • Example Response Body Raw:
   [
       {
           "id": 1,
           "name": "Electronics",
           "productResponseDTOList": null
       },
       {
           "id": 2,
           "name": "Gadgets",
           "productResponseDTOList": null
       }
   ]



  1. GET: https://localhost/api/v1/categories/filter?id=1,2&page-number=1&page-size=20 (NON-USER)

    • Filter Product(s) by CategoryRequestDTOList of category-id with page-size and page-number

    • Request params
      • Supported attributes for Product:

        • page-size
        • page-number
        • id

      • Attributes constraints for Category filter:

        • page-size : DefaultValue(20), Min(1), *Max(20)
        • page-number : DefaultValue(1), Min(1)
        • id : At least 1 id

      • Attributes explanation for Category filter:

        • page-size : page size
        • page-number : page number
        • id : List of id, at least 1 id

  • Example Response Body Raw:
{
    "namesMap": {
        "1": "Electronics",
        "2": "Gadgets"
    },
    "productsPage": {
        "content": [
            {
                "message": null,
                "id": 7,
                "name": "Example Product 6",
                "price": 10.0,
                "stockQuantity": 100,
                "description": "This is an example description for product 5",
                "createdDate": null,
                "lastModifiedDate": null,
                "categoryResponseDTOList": null,
                "fileResponseDTOList": [
                    {
                        "message": null,
                        "id": 12,
                        "name": null,
                        "fileType": null,
                        "size": null,
                        "fileByte": ""
                    }
                ]
            },
          {
            "message": null,
            "id": 6,
            "name": "Example Product 5",
            "price": 10.0,
            "stockQuantity": 100,
            "description": "This is an example description for product 5",
            "createdDate": null,
            "lastModifiedDate": null,
            "categoryResponseDTOList": null,
            "fileResponseDTOList": [
              {
                "message": null,
                "id": 11,
                "name": null,
                "fileType": null,
                "size": null,
                "fileByte": ""
              }
            ]
          }
        ],
      "page": {
        "size": 20,
        "number": 1,
        "totalElements": 22,
        "totalPages": 2
      }
    }
}



Shopping Cart

  1. POST: https://localhost/api/v1/carts/upload (USER ONLY)

    • Upload List of (Product id, Quantity) for Shopping Cart (User authenticated Bearer Token needed in AUTHORIZATION)

    • Request Body
      • Content-Type = application/json

      • Suported attributes for Shopping Cart:

        • productId
        • quantity

      • Attributes constraints for Shopping Cart:

        • productId : NotNull, Min(1)
        • quantity : NotNull, Min(1)

      • Attributes explaination for Product:

        • productId : product id
        • quantity : product quantity

      • Example in Request Body Raw::

   [
       {
           "productId": 1,
           "quantity": 7
       },
       {
           "productId": 2,
           "quantity": 9
       },
       {
           "productId": 3,
           "quantity": 1
       }
   ]



  • Response Body:
    • Content-Type = application/json

    • Suported attributes for Cart:
{
  "message": "Upload cart successfully",
  "cartId": 2,
  "userId": "beaaf22c-9049-4af4-b42b-489435ccb786",
  "totalAmount": 4999.50,
  "productQuantityResponseDTOList": [
    {
      "productQuantityId": 37,
      "productId": 1,
      "shoppingCartId": 2,
      "orderId": null,
      "quantity": 10,
      "totalAmount": 999.90,
      "productResponseDTO": {
        "message": null,
        "id": null,
        "name": "Example Product 1",
        "price": 99.99,
        "stockQuantity": 90,
        "description": "This is an example description for product 1",
        "createdDate": null,
        "lastModifiedDate": null,
        "categoryResponseDTOList": [
          {
            "id": 1,
            "name": "Electronics",
            "productResponseDTOList": null
          },
          {
            "id": 2,
            "name": "Gadgets",
            "productResponseDTOList": null
          }
        ],
        "fileResponseDTOList": [
          {
            "message": null,
            "id": 1,
            "name": null,
            "fileType": null,
            "size": null,
            "fileByte": ""
          }
        ]
      }
    },
    {
      "productQuantityId": 38,
      "productId": 2,
      "shoppingCartId": 2,
      "orderId": null,
      "quantity": 30,
      "totalAmount": 2999.70,
      "productResponseDTO": {
        "message": null,
        "id": null,
        "name": "Example Product 2",
        "price": 99.99,
        "stockQuantity": 70,
        "description": "This is an example description for product 2",
        "createdDate": null,
        "lastModifiedDate": null,
        "categoryResponseDTOList": [
          {
            "id": 2,
            "name": "Gadgets",
            "productResponseDTOList": null
          },
          {
            "id": 1,
            "name": "Electronics",
            "productResponseDTOList": null
          }
        ],
        "fileResponseDTOList": [
          {
            "message": null,
            "id": 2,
            "name": null,
            "fileType": null,
            "size": null,
            "fileByte": ""
          }
        ]
      }
    }
  ]
}
  1. GET: https://localhost/api/v1/carts (USER ONLY)

    • Retrieve Shopping Cart by User authenticated Bearer Token in AUTHORIZATION

    • Request parameters

      • Supported attributes for Product:

        • product-name
        • page-size
        • page-number

      • Attributes constraints for Product:

        • product-name : Optional
        • page-size : DefaultValue(20), Min(1), *Max(20)
        • page-number : DefaultValue(1), Min(1)
      • Attributes explanation for Product:

        • product-name : product name
        • page-size : DefaultValue(20), Min(1), *Max(20)
        • page-number : DefaultValue(1), Min(1)
    • Response Body

      • Content-Type = application/json

      • Supported attributes for Cart:
{
  "message": "Find cart successfully",
  "cartId": 2,
  "userId": "beaaf22c-9049-4af4-b42b-489435ccb786",
  "totalAmount": 4999.50,
  "productQuantityResponseDTOPage": {
    "content": [
      {
        "productQuantityId": 38,
        "productId": 2,
        "shoppingCartId": 2,
        "orderId": null,
        "quantity": 20,
        "totalAmount": 1999.80,
        "productResponseDTO": {
          "message": null,
          "id": null,
          "name": "Example Product 2",
          "price": 99.99,
          "stockQuantity": 70,
          "description": "This is an example description for product 2",
          "createdDate": null,
          "lastModifiedDate": null,
          "categoryResponseDTOList": [
            {
              "id": 2,
              "name": "Gadgets",
              "productResponseDTOList": null
            },
            {
              "id": 1,
              "name": "Electronics",
              "productResponseDTOList": null
            }
          ],
          "fileResponseDTOList": [
            {
              "message": null,
              "id": 2,
              "name": null,
              "fileType": null,
              "size": null,
              "fileByte": ""
            }
          ]
        }
      },
      {
        "productQuantityId": 39,
        "productId": 3,
        "shoppingCartId": 2,
        "orderId": null,
        "quantity": 30,
        "totalAmount": 2999.70,
        "productResponseDTO": {
          "message": null,
          "id": null,
          "name": "Example Product 3",
          "price": 99.99,
          "stockQuantity": 90,
          "description": "This is an example description for product 3",
          "createdDate": null,
          "lastModifiedDate": null,
          "categoryResponseDTOList": [
            {
              "id": 1,
              "name": "Electronics",
              "productResponseDTOList": null
            },
            {
              "id": 2,
              "name": "Gadgets",
              "productResponseDTOList": null
            }
          ],
          "fileResponseDTOList": [
            {
              "message": null,
              "id": 3,
              "name": null,
              "fileType": null,
              "size": null,
              "fileByte": ""
            }
          ]
        }
      }
    ],
    "page": {
      "size": 20,
      "number": 1,
      "totalElements": 22,
      "totalPages": 2
    }
  }
}
  1. PATCH: https://localhost/api/v1/carts/update (USER-ONLY)

  • Update the current shopping cart with productId exists in cart with quantity or add new productId if not exist in cart
  • Request Body
    • Content-Type = application/json

    • Supported attributes for Shopping Cart:

      • productId
      • quantity

    • Attributes constraints for Shopping Cart:

      • productId : NotNull, Min(1)
      • quantity : NotNull, Min(1)

    • Attributes explanation for Product:

      • productId : product id
      • quantity : product quantity

    • Example in Request Body Raw:

[
    {
        "productId": 1,
        "quantity": 20
    },
    {
        "productId": 2,
        "quantity": 20
    }
]
  • Example in Response Body Raw
{
    "message": "Upload cart successfully",
    "cartId": 2,
    "userId": "beaaf22c-9049-4af4-b42b-489435ccb786",
    "totalAmount": 4999.50,
    "productQuantityResponseDTOList": [
        {
            "productQuantityId": 38,
            "productId": 2,
            "shoppingCartId": 2,
            "orderId": null,
            "quantity": 20,
            "totalAmount": 1999.80,
            "productResponseDTO": {
                "message": null,
                "id": null,
                "name": "Example Product 2",
                "price": 99.99,
                "stockQuantity": 70,
                "description": "This is an example description for product 2",
                "createdDate": null,
                "lastModifiedDate": null,
                "categoryResponseDTOList": [
                    {
                        "id": 2,
                        "name": "Gadgets",
                        "productResponseDTOList": null
                    },
                    {
                        "id": 1,
                        "name": "Electronics",
                        "productResponseDTOList": null
                    }
                ],
                "fileResponseDTOList": [
                    {
                        "message": null,
                        "id": 2,
                        "name": null,
                        "fileType": null,
                        "size": null,
                        "fileByte": ""
                    }
                ]
            }
        },
      {
        "productQuantityId": 39,
        "productId": 3,
        "shoppingCartId": 2,
        "orderId": null,
        "quantity": 30,
        "totalAmount": 2999.70,
        "productResponseDTO": {
          "message": null,
          "id": null,
          "name": "Example Product 3",
          "price": 99.99,
          "stockQuantity": 90,
          "description": "This is an example description for product 3",
          "createdDate": null,
          "lastModifiedDate": null,
          "categoryResponseDTOList": [
            {
              "id": 1,
              "name": "Electronics",
              "productResponseDTOList": null
            },
            {
              "id": 2,
              "name": "Gadgets",
              "productResponseDTOList": null
            }
          ],
          "fileResponseDTOList": [
            {
              "message": null,
              "id": 3,
              "name": null,
              "fileType": null,
              "size": null,
              "fileByte": ""
            }
          ]
        }
      }
    ]
}

Order

  1. POST: https://localhost/api/v1/orders/upload (USER-ONLY)

    • Make Order from the user data and their cart (identifying user through token, so using Bearer Token in Authorization before send)
    • Request Body
      • Content-Type = application/json

      • Example Request Body Raw:
   {
       "orderInfo": "good",
       "anotherField": "good",
       "phoneNumber": 123456789,
       "addressRequestDTO": {
           "houseNumber": "number",
           "streetName": "street",
           "wardName": "ward",
           "city": "city",
           "zipCode": "zipCode"
       }
   }
  • Response Body:
    • Content-Type = application/json

    • Supported attributes for Oder:
{
  "message": "Save order 29 successfully.",
  "id": 29,
  "name": "admin@email.com",
  "totalAmount": 167892.00,
  "status": "PROCESSING",
  "deliveryDate": "2024-06-26T10:46:19.753213",
  "orderInfo": "good",
  "anotherField": "good",
  "productQuantityResponseDTOList": [
    {
      "productQuantityId": 40,
      "productId": 1,
      "shoppingCartId": null,
      "orderId": 29,
      "quantity": 7,
      "totalAmount": 69132.00,
      "productResponseDTO": {
        "message": null,
        "id": null,
        "name": "Product 1",
        "price": 9876.0,
        "stockQuantity": null,
        "description": "Product 1",
        "createdDate": null,
        "lastModifiedDate": null,
        "fileResponseDTOList": [
              {
                "message": null,
                "id": 1,
                "name": null,
                "fileType": null,
                "size": null,
                "fileByte": null
              }
          ],
          "categoryResponseDTOList": null
        }
      }
    ],
    "phoneNumber": 987654321,
    "addressResponseDTO": {
      "houseNumber": "34",
      "streetName": "street",
      "wardName": "ward",
      "city": "city",
      "zipCode": "zipcode"
  }
}
  1. POST: https://localhost/api/v1/orders (USER-ONLY)

    • Get All Order information according to user (use token)
    • Request Body
      • Content-Type = application/json

        • page-number
        • page-size
      • Example Request Body Raw:
  {
    "pageNumber": 1,
    "pageSize": 20
  }
  • Response Body:
    • Content-Type = application/json

    • Supported attributes for Oder:
{
    "content": [
      {
        "message": null,
        "id": 29,
        "name": "admin@email.com",
        "totalAmount": 167892.00,
        "status": "PROCESSING",
        "deliveryDate": "2024-06-26T10:46:19.753213",
        "orderInfo": "good",
        "anotherField": "good",
        "productQuantityResponseDTOList": [
          {
            "productQuantityId": 40,
            "productId": 1,
            "shoppingCartId": null,
            "orderId": 29,
            "quantity": 7,
            "totalAmount": 69132.00,
            "productResponseDTO": {
              "message": null,
              "id": null,
              "name": "Product 1",
              "price": 9876.0,
              "stockQuantity": null,
              "description": "Product 1",
              "createdDate": null,
              "lastModifiedDate": null,
              "fileResponseDTOList": [
                    {
                      "message": null,
                      "id": 1,
                      "name": null,
                      "fileType": null,
                      "size": null,
                      "fileByte": null
                    }
                ],
                "categoryResponseDTOList": null
              }
            }
          ],
          "phoneNumber": 987654321,
          "addressResponseDTO": {
            "houseNumber": "34",
            "streetName": "street",
            "wardName": "ward",
            "city": "city",
            "zipCode": "zipcode"
        }
      }
    ],
    "page": {
      "size": 20,
      "number": 1,
      "totalElements": 21,
      "totalPages": 2
    }
}
  1. GET: https://localhost/api/v1/orders/search/{order-id} (USER-ONLY)

    • Get Order information according to user and id (also use token)
    • Request Body
      • Content-Type = application/json

    • Response Body:
      • Content-Type = application/json

      • Supported attributes for Order:
{
  "message": "Search order 29 successfully.",
  "id": 29,
  "name": "admin@email.com",
  "totalAmount": 167892.00,
  "status": "PROCESSING",
  "deliveryDate": "2024-06-26T10:46:19.753213",
  "orderInfo": "good",
  "anotherField": "good",
  "productQuantityResponseDTOList": [
    {
      "productQuantityId": 40,
      "productId": 1,
      "shoppingCartId": null,
      "orderId": 29,
      "quantity": 7,
      "totalAmount": 69132.00,
      "productResponseDTO": {
        "message": null,
        "id": null,
        "name": "Product 1",
        "price": 9876.0,
        "stockQuantity": null,
        "description": "Product 1",
        "createdDate": null,
        "lastModifiedDate": null,
        "fileResponseDTOList": [
              {
                "message": null,
                "id": 1,
                "name": null,
                "fileType": null,
                "size": null,
                "fileByte": null
              }
          ],
          "categoryResponseDTOList": null
        }
      }
    ],
    "phoneNumber": 987654321,
    "addressResponseDTO": {
      "houseNumber": "34",
      "streetName": "street",
      "wardName": "ward",
      "city": "city",
      "zipCode": "zipcode"
  }
}
  1. PATCH: https://localhost/api/v1/orders/update/{order-id} (USER-ONLY)

    • Update Order information according to user and id
    • Update Order attribute(s) with product-id

    • Request Body
      • Content-Type = application/json

        • orderInfo
        • anotherField
        • phoneNumber
        • addressRequestDTO

        • Example Request Body Raw:
   {
       "orderInfo": "good",
       "anotherField": "good",
       "phoneNumber": 123456789,
       "addressRequestDTO": {
           "houseNumber": "number",
           "streetName": "street",
           "wardName": "ward",
           "city": "city",
           "zipCode": "zipCode"
       }
   }
  • Response Body:
    • Content-Type = application/json

    • Supported attributes for Oder:
{
  "message": "Update order 29 successfully.",
  "id": 29,
  "name": "admin@email.com",
  "totalAmount": 167892.00,
  "status": "PROCESSING",
  "deliveryDate": "2024-06-26T10:46:19.753213",
  "orderInfo": "good",
  "anotherField": "good",
  "productQuantityResponseDTOList": [
    {
      "productQuantityId": 40,
      "productId": 1,
      "shoppingCartId": null,
      "orderId": 29,
      "quantity": 7,
      "totalAmount": 69132.00,
      "productResponseDTO": {
        "message": null,
        "id": null,
        "name": "Product 1",
        "price": 9876.0,
        "stockQuantity": null,
        "description": "Product 1",
        "createdDate": null,
        "lastModifiedDate": null,
        "fileResponseDTOList": [
              {
                "message": null,
                "id": 1,
                "name": null,
                "fileType": null,
                "size": null,
                "fileByte": null
              }
          ],
          "categoryResponseDTOList": null
        }
      }
    ],
    "phoneNumber": 987654321,
    "addressResponseDTO": {
      "houseNumber": "34",
      "streetName": "street",
      "wardName": "ward",
      "city": "city",
      "zipCode": "zipcode"
  }
}
  1. DELETE: https://localhost/api/v1/orders/delete/{order-id} (ADMIN ONLY)

    • Delete Order by order-id

  2. PATCH: https://localhost/api/v1/orders/deliver/update-status/{order-id} (DELIVERER-ONLY)

  • Update Order Status according to order-id

  • Request Body

    • Content-Type = multipart/form-data

      • status

    • Supported attributes for Order:

      • status
    • Attributes constraints for Order:

      • status : NotNull, NotBlank
    • Attributes explanation for Order:

      • status : status ("delivering", "complete")

  • Response Body

{
  "message": "Update status successfully",
  "id": 6,
  "fullName": "first last",
  "totalAmount": 177768.00,
  "status": "DELIVERING",
  "deliveryDate": "2024-06-28T15:26:39.001256",
  "orderInfo": "good",
  "phoneNumber": 987654321,
  "addressResponseDTO": {
    "houseNumber": "34",
    "streetName": "street",
    "wardName": "ward",
    "city": "city",
    "zipCode": "zipcode"
  }
}
  1. GET: https://localhost/api/v1/transactions?page-number=1&page-size=20&sort=amount&direction=asc (USER-ONLY)

  • Find all Transaction(s) as Page, of User authenticated Bearer Token in AUTHORIZATION
  • Request Parameters
    • Supported attributes for Transaction finding:

      • page-size
      • page-number
      • sort
      • direction

    • Attributes constraints for Transaction finding:

      • page-size : DefaultValue(20), Min(1), *Max(20)
      • page-number : DefaultValue(1), Min(1)
      • sort : Optional
      • direction : DefaultValue("desc")

    • Attributes explanation for Transaction finding:

      • page-size : maximum number of Products in a page
      • page-number : page number of which page
      • sort : sort by attributes ("amount", "created-date", "last-modified-date")
      • direction : sort by direction ("asc", "desc")

  • Example Body Raw

Transaction

  1. POST: https://localhost/api/v1/transactions/upload (USER-ONLY)

    • Upload transaction of User authenticated Bearer Token in AUTHORIZATION
    • Request Body
      • Content-Type = application/json

      • Supported attributes for Transaction:

        • orderId
        • transactionType
        • currency

      • Attributes constraints for Transaction:

        • orderId : NotNull, Min(1)
        • transactionType : NotNull, NotBlank
        • currency : NotNull, NotBlank

      • Attributes explanation for Transaction:

        • orderId : order id
        • transactionType : transaction type (can be categorized as INTERNET_BANKING, CREDIT_CARD, CASH)
        • currency : currency (can be categorized as VND, USD, EUR)

  • Example Request Body Raw:
   {
      "orderId": 1,
      "transactionType": "CREDIT_CARD",
      "currency": "VND"
   }
  • Example in Response Body Raw
{
    "message": "Save transaction successfully",
    "orderId": 1,
    "transactionId": 9,
    "amount": 4999.50,
    "transactionType": "CREDIT_CARD",
    "currency": "VND",
    "createdDate": "2024-06-27T10:58:03.7601828+07:00",
    "lastModifiedDate": "2024-06-27T10:58:12.6250555+07:00",
    "createdBy": "test hello",
    "lastModifiedBy": null
}
  1. GET: https://localhost/api/v1/transactions?page-number=1&page-size=20&sort=amount&direction=asc (USER-ONLY)

    • Find all Transaction(s) as Page, of User authenticated Bearer Token in AUTHORIZATION
    • Request Parameters
      • Supported attributes for Transaction finding:

        • page-size
        • page-number
        • sort
        • direction

      • Attributes constraints for Transaction finding:

        • page-size : DefaultValue(20), Min(1), *Max(20)
        • page-number : DefaultValue(1), Min(1)
        • sort : Optional
        • direction : DefaultValue("desc")

      • Attributes explanation for Transaction finding:

        • page-size : maximum number of Products in a page
        • page-number : page number of which page
        • sort : sort by attributes ("amount", "created-date", "last-modified-date")
        • direction : sort by direction ("asc", "desc")

  • Example Body Raw
{
    "content": [
        {
            "message": "Find successfully",
            "orderId": 11,
            "transactionId": 8,
            "amount": 4999.50,
            "transactionType": "CREDIT_CARD",
            "currency": "VND",
            "createdDate": "2024-06-27T10:56:32.567386+07:00",
            "lastModifiedDate": null,
            "createdBy": "test hello",
            "lastModifiedBy": null
        },
        {
            "message": "Find successfully",
            "orderId": 12,
            "transactionId": 9,
            "amount": 4999.50,
            "transactionType": "CREDIT_CARD",
            "currency": "VND",
            "createdDate": "2024-06-27T10:58:03.760183+07:00",
            "lastModifiedDate": "2024-06-27T10:58:12.625056+07:00",
            "createdBy": "test hello",
            "lastModifiedBy": null
        }
    ],
    "page": {
      "size": 20,
      "number": 1,
      "totalElements": 22,
      "totalPages": 2
    }
}
  1. GET: https://localhost/api/v1/transactions/search/{user-id}?page-number=1&page-size=20&sort=amount&direction=desc (ADMIN-ONLY)

  • Find all Transaction(s) as Page of a user with user-id, authenticated Bearer Token in AUTHORIZATION
  • Request Parameters
    • Supported attributes for Transaction finding:

      • user-id
      • page-size
      • page-number
      • sort
      • direction

    • Attributes constraints for Transaction finding:

      • user-id : NotNull
      • page-size : DefaultValue(20), Min(1), *Max(20)
      • page-number : DefaultValue(1), Min(1)
      • sort : Optional
      • direction : DefaultValue("desc")

    • Attributes explanation for Transaction finding:

      • user-id : user UUID
      • page-size : maximum number of Products in a page
      • page-number : page number of which page
      • sort : sort by attributes ("amount", "created-date", "last-modified-date")
      • direction : sort by direction ("asc", "desc")

  • Example Response Body Raw
{
    "content": [
        {
            "message": "Find successfully",
            "orderId": 11,
            "transactionId": 8,
            "amount": 4999.50,
            "transactionType": "CREDIT_CARD",
            "currency": "VND",
            "createdDate": "2024-06-27T10:56:32.567386+07:00",
            "lastModifiedDate": null,
            "createdBy": "test hello",
            "lastModifiedBy": null
        },
        {
            "message": "Find successfully",
            "orderId": 12,
            "transactionId": 9,
            "amount": 4999.50,
            "transactionType": "CREDIT_CARD",
            "currency": "VND",
            "createdDate": "2024-06-27T10:58:03.760183+07:00",
            "lastModifiedDate": "2024-06-27T10:58:12.625056+07:00",
            "createdBy": "test hello",
            "lastModifiedBy": null
        }
    ],
    "page": {
      "size": 20,
      "number": 1,
      "totalElements": 22,
      "totalPages": 2
    }
}
  1. GET: https://localhost/api/v1/transactions/search?page-number=1&page-size=20&sort=amount&direction=desc (ADMIN-ONLY)

  • Find all Transaction(s) as Page of All Users, authenticated Bearer Token in AUTHORIZATION
  • Request Parameters
    • Supported attributes for Transaction finding:

      • page-size
      • page-number
      • sort
      • direction

    • Attributes constraints for Transaction finding:

      • page-size : DefaultValue(20), Min(1), *Max(20)
      • page-number : DefaultValue(1), Min(1)
      • sort : Optional
      • direction : DefaultValue("desc")

    • Attributes explanation for Transaction finding:

      • page-size : maximum number of Products in a page
      • page-number : page number of which page
      • sort : sort by attributes ("amount", "created-date", "last-modified-date")
      • direction : sort by direction ("asc", "desc")

    • Example Body Raw
{
    "content": [
        {
            "message": "Find successfully",
            "orderId": 11,
            "transactionId": 8,
            "amount": 4999.50,
            "transactionType": "CREDIT_CARD",
            "currency": "VND",
            "createdDate": "2024-06-27T10:56:32.567386+07:00",
            "lastModifiedDate": null,
            "createdBy": "test hello",
            "lastModifiedBy": null
        },
        {
            "message": "Find successfully",
            "orderId": 12,
            "transactionId": 9,
            "amount": 4999.50,
            "transactionType": "CREDIT_CARD",
            "currency": "VND",
            "createdDate": "2024-06-27T10:58:03.760183+07:00",
            "lastModifiedDate": "2024-06-27T10:58:12.625056+07:00",
            "createdBy": "test hello",
            "lastModifiedBy": null
        }
    ],
    "page": {
      "size": 20,
      "number": 1,
      "totalElements": 22,
      "totalPages": 2
    }
}