feat: add cabinet management functionality

This commit is contained in:
Tran Anh Tuan
2026-05-08 15:26:31 +07:00
parent 459ff6b384
commit 58cfe890a1
14 changed files with 1981 additions and 856 deletions

View File

@@ -1,5 +1,20 @@
basePath: /api/v1
definitions:
models.Cabinet:
properties:
createdAt:
type: string
description:
type: string
id:
type: integer
name:
type: string
roomId:
type: integer
updatedAt:
type: string
type: object
models.Room:
properties:
createdAt:
@@ -46,6 +61,18 @@ definitions:
- password
- username
type: object
requests.CreateCabinetRequest:
properties:
description:
type: string
name:
type: string
roomId:
type: integer
required:
- name
- roomId
type: object
requests.CreateRoomRequest:
properties:
description:
@@ -70,6 +97,13 @@ definitions:
- address
- name
type: object
requests.UpdateCabinetRequest:
properties:
description:
type: string
name:
type: string
type: object
requests.UpdateRoomRequest:
properties:
description:
@@ -113,6 +147,11 @@ definitions:
id:
type: string
type: object
responses.CreateCabinetResponse:
properties:
id:
type: integer
type: object
responses.CreateRoomResponse:
properties:
id:
@@ -123,6 +162,17 @@ definitions:
id:
type: integer
type: object
responses.UpdateCabinetResponse:
properties:
description:
type: string
id:
type: integer
name:
type: string
roomId:
type: integer
type: object
responses.UpdateRoomResponse:
properties:
description:
@@ -208,6 +258,176 @@ paths:
summary: Health check
tags:
- health
/v1/cabinets:
get:
consumes:
- application/json
description: Retrieve a list of all cabinets ordered by creation date
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
items:
$ref: '#/definitions/models.Cabinet'
type: array
type: object
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.ErrorResponse'
summary: List all cabinets
tags:
- cabinet
post:
consumes:
- application/json
description: Create a new cabinet with the provided details
parameters:
- description: Cabinet request body
in: body
name: body
required: true
schema:
$ref: '#/definitions/requests.CreateCabinetRequest'
produces:
- application/json
responses:
"201":
description: Created
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
$ref: '#/definitions/responses.CreateCabinetResponse'
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 cabinet
tags:
- cabinet
/v1/cabinets/{id}:
delete:
consumes:
- application/json
description: Delete a cabinet by its unique identifier
parameters:
- description: Cabinet 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 cabinet
tags:
- cabinet
get:
consumes:
- application/json
description: Retrieve a single cabinet using its unique identifier
parameters:
- description: Cabinet 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.Cabinet'
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 cabinet by ID
tags:
- cabinet
put:
consumes:
- application/json
description: Update an existing cabinet by its ID. Only non-empty fields will
be updated.
parameters:
- description: Cabinet ID
in: path
name: id
required: true
type: integer
- description: Cabinet request body
in: body
name: body
required: true
schema:
$ref: '#/definitions/requests.UpdateCabinetRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
$ref: '#/definitions/responses.UpdateCabinetResponse'
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 cabinet
tags:
- cabinet
/v1/rooms:
get:
consumes: