feat: add container management functionality

This commit is contained in:
Tran Anh Tuan
2026-05-11 09:42:19 +07:00
parent 9f27436d5d
commit 7c9a0d4670
15 changed files with 1654 additions and 1 deletions

View File

@@ -378,6 +378,279 @@ const docTemplate = `{
}
}
},
"/v1/containers": {
"get": {
"description": "Retrieve a list of all containers ordered by creation date",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"container"
],
"summary": "List all containers",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Container"
}
}
}
}
]
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
},
"post": {
"description": "Create a new container with the provided details",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"container"
],
"summary": "Create a new container",
"parameters": [
{
"description": "Container request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.CreateContainerRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.CreateContainerResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/v1/containers/{id}": {
"get": {
"description": "Retrieve a single container using its unique identifier",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"container"
],
"summary": "Get container by ID",
"parameters": [
{
"type": "integer",
"description": "Container ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.Container"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
},
"put": {
"description": "Update an existing container by its ID. Only non-empty fields will be updated.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"container"
],
"summary": "Update container",
"parameters": [
{
"type": "integer",
"description": "Container ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Container request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.UpdateContainerRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.UpdateContainerResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
},
"delete": {
"description": "Delete a container by its unique identifier",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"container"
],
"summary": "Delete container",
"parameters": [
{
"type": "integer",
"description": "Container ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.SuccessResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/v1/rooms": {
"get": {
"description": "Retrieve a list of all rooms ordered by creation date",
@@ -1216,6 +1489,41 @@ const docTemplate = `{
}
}
},
"models.Container": {
"type": "object",
"properties": {
"containerType": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"description": {
"type": "string"
},
"id": {
"type": "integer"
},
"maxCapacity": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
},
"name": {
"type": "string"
},
"shelfId": {
"type": "integer"
},
"updatedAt": {
"type": "string"
}
}
},
"models.Room": {
"type": "object",
"properties": {
@@ -1329,6 +1637,37 @@ const docTemplate = `{
}
}
},
"requests.CreateContainerRequest": {
"type": "object",
"required": [
"containerType",
"name",
"shelfId"
],
"properties": {
"containerType": {
"type": "string"
},
"description": {
"type": "string"
},
"maxCapacity": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
},
"name": {
"type": "string"
},
"shelfId": {
"type": "integer"
}
}
},
"requests.CreateRoomRequest": {
"type": "object",
"required": [
@@ -1398,6 +1737,29 @@ const docTemplate = `{
}
}
},
"requests.UpdateContainerRequest": {
"type": "object",
"properties": {
"containerType": {
"type": "string"
},
"description": {
"type": "string"
},
"maxCapacity": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
},
"name": {
"type": "string"
}
}
},
"requests.UpdateRoomRequest": {
"type": "object",
"properties": {
@@ -1486,6 +1848,14 @@ const docTemplate = `{
}
}
},
"responses.CreateContainerResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer"
}
}
},
"responses.CreateRoomResponse": {
"type": "object",
"properties": {
@@ -1527,6 +1897,35 @@ const docTemplate = `{
}
}
},
"responses.UpdateContainerResponse": {
"type": "object",
"properties": {
"containerType": {
"type": "string"
},
"description": {
"type": "string"
},
"id": {
"type": "integer"
},
"maxCapacity": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
},
"name": {
"type": "string"
},
"shelfId": {
"type": "integer"
}
}
},
"responses.UpdateRoomResponse": {
"type": "object",
"properties": {

View File

@@ -372,6 +372,279 @@
}
}
},
"/v1/containers": {
"get": {
"description": "Retrieve a list of all containers ordered by creation date",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"container"
],
"summary": "List all containers",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Container"
}
}
}
}
]
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
},
"post": {
"description": "Create a new container with the provided details",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"container"
],
"summary": "Create a new container",
"parameters": [
{
"description": "Container request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.CreateContainerRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.CreateContainerResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/v1/containers/{id}": {
"get": {
"description": "Retrieve a single container using its unique identifier",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"container"
],
"summary": "Get container by ID",
"parameters": [
{
"type": "integer",
"description": "Container ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.Container"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
},
"put": {
"description": "Update an existing container by its ID. Only non-empty fields will be updated.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"container"
],
"summary": "Update container",
"parameters": [
{
"type": "integer",
"description": "Container ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Container request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.UpdateContainerRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.UpdateContainerResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
},
"delete": {
"description": "Delete a container by its unique identifier",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"container"
],
"summary": "Delete container",
"parameters": [
{
"type": "integer",
"description": "Container ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/response.SuccessResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/v1/rooms": {
"get": {
"description": "Retrieve a list of all rooms ordered by creation date",
@@ -1210,6 +1483,41 @@
}
}
},
"models.Container": {
"type": "object",
"properties": {
"containerType": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"description": {
"type": "string"
},
"id": {
"type": "integer"
},
"maxCapacity": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
},
"name": {
"type": "string"
},
"shelfId": {
"type": "integer"
},
"updatedAt": {
"type": "string"
}
}
},
"models.Room": {
"type": "object",
"properties": {
@@ -1323,6 +1631,37 @@
}
}
},
"requests.CreateContainerRequest": {
"type": "object",
"required": [
"containerType",
"name",
"shelfId"
],
"properties": {
"containerType": {
"type": "string"
},
"description": {
"type": "string"
},
"maxCapacity": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
},
"name": {
"type": "string"
},
"shelfId": {
"type": "integer"
}
}
},
"requests.CreateRoomRequest": {
"type": "object",
"required": [
@@ -1392,6 +1731,29 @@
}
}
},
"requests.UpdateContainerRequest": {
"type": "object",
"properties": {
"containerType": {
"type": "string"
},
"description": {
"type": "string"
},
"maxCapacity": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
},
"name": {
"type": "string"
}
}
},
"requests.UpdateRoomRequest": {
"type": "object",
"properties": {
@@ -1480,6 +1842,14 @@
}
}
},
"responses.CreateContainerResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer"
}
}
},
"responses.CreateRoomResponse": {
"type": "object",
"properties": {
@@ -1521,6 +1891,35 @@
}
}
},
"responses.UpdateContainerResponse": {
"type": "object",
"properties": {
"containerType": {
"type": "string"
},
"description": {
"type": "string"
},
"id": {
"type": "integer"
},
"maxCapacity": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
},
"name": {
"type": "string"
},
"shelfId": {
"type": "integer"
}
}
},
"responses.UpdateRoomResponse": {
"type": "object",
"properties": {

View File

@@ -15,6 +15,29 @@ definitions:
updatedAt:
type: string
type: object
models.Container:
properties:
containerType:
type: string
createdAt:
type: string
description:
type: string
id:
type: integer
maxCapacity:
type: integer
metadata:
items:
type: integer
type: array
name:
type: string
shelfId:
type: integer
updatedAt:
type: string
type: object
models.Room:
properties:
createdAt:
@@ -90,6 +113,27 @@ definitions:
- name
- roomId
type: object
requests.CreateContainerRequest:
properties:
containerType:
type: string
description:
type: string
maxCapacity:
type: integer
metadata:
items:
type: integer
type: array
name:
type: string
shelfId:
type: integer
required:
- containerType
- name
- shelfId
type: object
requests.CreateRoomRequest:
properties:
description:
@@ -136,6 +180,21 @@ definitions:
name:
type: string
type: object
requests.UpdateContainerRequest:
properties:
containerType:
type: string
description:
type: string
maxCapacity:
type: integer
metadata:
items:
type: integer
type: array
name:
type: string
type: object
requests.UpdateRoomRequest:
properties:
description:
@@ -193,6 +252,11 @@ definitions:
id:
type: integer
type: object
responses.CreateContainerResponse:
properties:
id:
type: integer
type: object
responses.CreateRoomResponse:
properties:
id:
@@ -219,6 +283,25 @@ definitions:
roomId:
type: integer
type: object
responses.UpdateContainerResponse:
properties:
containerType:
type: string
description:
type: string
id:
type: integer
maxCapacity:
type: integer
metadata:
items:
type: integer
type: array
name:
type: string
shelfId:
type: integer
type: object
responses.UpdateRoomResponse:
properties:
description:
@@ -487,6 +570,176 @@ paths:
summary: Update cabinet
tags:
- cabinet
/v1/containers:
get:
consumes:
- application/json
description: Retrieve a list of all containers ordered by creation date
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
items:
$ref: '#/definitions/models.Container'
type: array
type: object
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.ErrorResponse'
summary: List all containers
tags:
- container
post:
consumes:
- application/json
description: Create a new container with the provided details
parameters:
- description: Container request body
in: body
name: body
required: true
schema:
$ref: '#/definitions/requests.CreateContainerRequest'
produces:
- application/json
responses:
"201":
description: Created
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
$ref: '#/definitions/responses.CreateContainerResponse'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.ErrorResponse'
summary: Create a new container
tags:
- container
/v1/containers/{id}:
delete:
consumes:
- application/json
description: Delete a container by its unique identifier
parameters:
- description: Container ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/response.SuccessResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.ErrorResponse'
summary: Delete container
tags:
- container
get:
consumes:
- application/json
description: Retrieve a single container using its unique identifier
parameters:
- description: Container ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
$ref: '#/definitions/models.Container'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.ErrorResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/response.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.ErrorResponse'
summary: Get container by ID
tags:
- container
put:
consumes:
- application/json
description: Update an existing container by its ID. Only non-empty fields will
be updated.
parameters:
- description: Container ID
in: path
name: id
required: true
type: integer
- description: Container request body
in: body
name: body
required: true
schema:
$ref: '#/definitions/requests.UpdateContainerRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
$ref: '#/definitions/responses.UpdateContainerResponse'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.ErrorResponse'
"404":
description: Not Found
schema:
$ref: '#/definitions/response.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.ErrorResponse'
summary: Update container
tags:
- container
/v1/rooms:
get:
consumes: