feat: add shelve management functionality

This commit is contained in:
Tran Anh Tuan
2026-05-08 18:17:07 +07:00
parent 8562d39071
commit 9f27436d5d
14 changed files with 2682 additions and 1074 deletions

View File

@@ -651,6 +651,279 @@ const docTemplate = `{
}
}
},
"/v1/shelves": {
"get": {
"description": "Retrieve a list of all shelves ordered by creation date",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"shelve"
],
"summary": "List all shelves",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/models.Shelve"
}
}
}
}
]
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
},
"post": {
"description": "Create a new shelve with the provided details",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"shelve"
],
"summary": "Create a new shelve",
"parameters": [
{
"description": "Shelve request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.CreateShelveRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.CreateShelveResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/v1/shelves/{id}": {
"get": {
"description": "Retrieve a single shelve using its unique identifier",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"shelve"
],
"summary": "Get shelve by ID",
"parameters": [
{
"type": "integer",
"description": "Shelve ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.Shelve"
}
}
}
]
}
},
"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 shelve by its ID. Only non-empty fields will be updated.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"shelve"
],
"summary": "Update shelve",
"parameters": [
{
"type": "integer",
"description": "Shelve ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Shelve request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.UpdateShelveRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.UpdateShelveResponse"
}
}
}
]
}
},
"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 shelve by its unique identifier",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"shelve"
],
"summary": "Delete shelve",
"parameters": [
{
"type": "integer",
"description": "Shelve 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/warehouses": {
"get": {
"description": "Retrieve a list of all warehouses ordered by creation date",
@@ -966,6 +1239,32 @@ const docTemplate = `{
}
}
},
"models.Shelve": {
"type": "object",
"properties": {
"cabinetId": {
"type": "integer"
},
"createdAt": {
"type": "string"
},
"description": {
"type": "string"
},
"id": {
"type": "integer"
},
"levelIndex": {
"type": "integer"
},
"name": {
"type": "string"
},
"updatedAt": {
"type": "string"
}
}
},
"models.Warehouse": {
"type": "object",
"properties": {
@@ -1048,6 +1347,28 @@ const docTemplate = `{
}
}
},
"requests.CreateShelveRequest": {
"type": "object",
"required": [
"cabinetId",
"levelIndex",
"name"
],
"properties": {
"cabinetId": {
"type": "integer"
},
"description": {
"type": "string"
},
"levelIndex": {
"type": "integer"
},
"name": {
"type": "string"
}
}
},
"requests.CreateWarehouseRequest": {
"type": "object",
"required": [
@@ -1088,6 +1409,20 @@ const docTemplate = `{
}
}
},
"requests.UpdateShelveRequest": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"levelIndex": {
"type": "integer"
},
"name": {
"type": "string"
}
}
},
"requests.UpdateWarehouseRequest": {
"type": "object",
"properties": {
@@ -1159,6 +1494,14 @@ const docTemplate = `{
}
}
},
"responses.CreateShelveResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer"
}
}
},
"responses.CreateWarehouseResponse": {
"type": "object",
"properties": {
@@ -1201,6 +1544,26 @@ const docTemplate = `{
}
}
},
"responses.UpdateShelveResponse": {
"type": "object",
"properties": {
"cabinetId": {
"type": "integer"
},
"description": {
"type": "string"
},
"id": {
"type": "integer"
},
"levelIndex": {
"type": "integer"
},
"name": {
"type": "string"
}
}
},
"responses.UpdateWarehouseResponse": {
"type": "object",
"properties": {