feat: add component_types management functionality

This commit is contained in:
Tran Anh Tuan
2026-05-11 10:15:02 +07:00
parent 7c9a0d4670
commit 50564e9b78
14 changed files with 1468 additions and 1 deletions

View File

@@ -15,6 +15,23 @@ definitions:
updatedAt:
type: string
type: object
models.ComponentType:
properties:
createdAt:
type: string
description:
type: string
id:
type: integer
metadata:
items:
type: integer
type: array
name:
type: string
updatedAt:
type: string
type: object
models.Container:
properties:
containerType:
@@ -113,6 +130,19 @@ definitions:
- name
- roomId
type: object
requests.CreateComponentTypeRequest:
properties:
description:
type: string
metadata:
items:
type: integer
type: array
name:
type: string
required:
- name
type: object
requests.CreateContainerRequest:
properties:
containerType:
@@ -180,6 +210,17 @@ definitions:
name:
type: string
type: object
requests.UpdateComponentTypeRequest:
properties:
description:
type: string
metadata:
items:
type: integer
type: array
name:
type: string
type: object
requests.UpdateContainerRequest:
properties:
containerType:
@@ -252,6 +293,11 @@ definitions:
id:
type: integer
type: object
responses.CreateComponentTypeResponse:
properties:
id:
type: integer
type: object
responses.CreateContainerResponse:
properties:
id:
@@ -283,6 +329,15 @@ definitions:
roomId:
type: integer
type: object
responses.UpdateComponentTypeResponse:
properties:
description:
type: string
id:
type: integer
name:
type: string
type: object
responses.UpdateContainerResponse:
properties:
containerType:
@@ -344,6 +399,176 @@ info:
title: Warehouse Management API
version: "1.0"
paths:
/api/v1/component-types:
get:
consumes:
- application/json
description: Retrieve a list of all component types ordered by creation date
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
items:
$ref: '#/definitions/models.ComponentType'
type: array
type: object
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.ErrorResponse'
summary: List all component types
tags:
- component-type
post:
consumes:
- application/json
description: Create a new component type with the provided details
parameters:
- description: Component type request body
in: body
name: body
required: true
schema:
$ref: '#/definitions/requests.CreateComponentTypeRequest'
produces:
- application/json
responses:
"201":
description: Created
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
$ref: '#/definitions/responses.CreateComponentTypeResponse'
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 component type
tags:
- component-type
/api/v1/component-types/{id}:
delete:
consumes:
- application/json
description: Delete a component type by its unique identifier
parameters:
- description: Component type 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 component type
tags:
- component-type
get:
consumes:
- application/json
description: Retrieve a single component type using its unique identifier
parameters:
- description: Component type 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.ComponentType'
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 component type by ID
tags:
- component-type
put:
consumes:
- application/json
description: Update an existing component type by its ID. Only non-empty fields
will be updated.
parameters:
- description: Component type ID
in: path
name: id
required: true
type: integer
- description: Component type request body
in: body
name: body
required: true
schema:
$ref: '#/definitions/requests.UpdateComponentTypeRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
$ref: '#/definitions/responses.UpdateComponentTypeResponse'
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 component type
tags:
- component-type
/auth/register:
post:
consumes: