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": {

File diff suppressed because it is too large Load Diff

View File

@@ -30,6 +30,23 @@ definitions:
warehouseId:
type: integer
type: object
models.Shelve:
properties:
cabinetId:
type: integer
createdAt:
type: string
description:
type: string
id:
type: integer
levelIndex:
type: integer
name:
type: string
updatedAt:
type: string
type: object
models.Warehouse:
properties:
address:
@@ -85,6 +102,21 @@ definitions:
- name
- warehouseId
type: object
requests.CreateShelveRequest:
properties:
cabinetId:
type: integer
description:
type: string
levelIndex:
type: integer
name:
type: string
required:
- cabinetId
- levelIndex
- name
type: object
requests.CreateWarehouseRequest:
properties:
address:
@@ -111,6 +143,15 @@ definitions:
name:
type: string
type: object
requests.UpdateShelveRequest:
properties:
description:
type: string
levelIndex:
type: integer
name:
type: string
type: object
requests.UpdateWarehouseRequest:
properties:
address:
@@ -157,6 +198,11 @@ definitions:
id:
type: integer
type: object
responses.CreateShelveResponse:
properties:
id:
type: integer
type: object
responses.CreateWarehouseResponse:
properties:
id:
@@ -184,6 +230,19 @@ definitions:
warehouseId:
type: integer
type: object
responses.UpdateShelveResponse:
properties:
cabinetId:
type: integer
description:
type: string
id:
type: integer
levelIndex:
type: integer
name:
type: string
type: object
responses.UpdateWarehouseResponse:
properties:
address:
@@ -598,6 +657,176 @@ paths:
summary: Update room
tags:
- room
/v1/shelves:
get:
consumes:
- application/json
description: Retrieve a list of all shelves ordered by creation date
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
items:
$ref: '#/definitions/models.Shelve'
type: array
type: object
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.ErrorResponse'
summary: List all shelves
tags:
- shelve
post:
consumes:
- application/json
description: Create a new shelve with the provided details
parameters:
- description: Shelve request body
in: body
name: body
required: true
schema:
$ref: '#/definitions/requests.CreateShelveRequest'
produces:
- application/json
responses:
"201":
description: Created
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
$ref: '#/definitions/responses.CreateShelveResponse'
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 shelve
tags:
- shelve
/v1/shelves/{id}:
delete:
consumes:
- application/json
description: Delete a shelve by its unique identifier
parameters:
- description: Shelve 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 shelve
tags:
- shelve
get:
consumes:
- application/json
description: Retrieve a single shelve using its unique identifier
parameters:
- description: Shelve 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.Shelve'
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 shelve by ID
tags:
- shelve
put:
consumes:
- application/json
description: Update an existing shelve by its ID. Only non-empty fields will
be updated.
parameters:
- description: Shelve ID
in: path
name: id
required: true
type: integer
- description: Shelve request body
in: body
name: body
required: true
schema:
$ref: '#/definitions/requests.UpdateShelveRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
$ref: '#/definitions/responses.UpdateShelveResponse'
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 shelve
tags:
- shelve
/v1/warehouses:
get:
consumes: