feat: add component_codes management functionality

This commit is contained in:
Tran Anh Tuan
2026-05-11 11:00:46 +07:00
parent bf20286f04
commit 9ea72b4eea
14 changed files with 1562 additions and 0 deletions

View File

@@ -40,6 +40,25 @@ definitions:
updatedAt:
type: string
type: object
models.ComponentCode:
properties:
code:
type: string
codeType:
type: string
componentId:
type: integer
createdAt:
type: string
id:
type: integer
isPrimary:
type: boolean
metadata:
items:
type: integer
type: array
type: object
models.ComponentType:
properties:
createdAt:
@@ -155,6 +174,24 @@ definitions:
- name
- roomId
type: object
requests.CreateComponentCodeRequest:
properties:
code:
type: string
codeType:
type: string
componentId:
type: integer
isPrimary:
type: boolean
metadata:
items:
type: integer
type: array
required:
- code
- componentId
type: object
requests.CreateComponentRequest:
properties:
componentTypeId:
@@ -257,6 +294,21 @@ definitions:
name:
type: string
type: object
requests.UpdateComponentCodeRequest:
properties:
code:
type: string
codeType:
type: string
componentId:
type: integer
isPrimary:
type: boolean
metadata:
items:
type: integer
type: array
type: object
requests.UpdateComponentRequest:
properties:
componentTypeId:
@@ -357,6 +409,11 @@ definitions:
id:
type: integer
type: object
responses.CreateComponentCodeResponse:
properties:
id:
type: integer
type: object
responses.CreateComponentResponse:
properties:
id:
@@ -398,6 +455,19 @@ definitions:
roomId:
type: integer
type: object
responses.UpdateComponentCodeResponse:
properties:
code:
type: string
codeType:
type: string
componentId:
type: integer
id:
type: integer
isPrimary:
type: boolean
type: object
responses.UpdateComponentResponse:
properties:
componentTypeId:
@@ -483,6 +553,176 @@ info:
title: Warehouse Management API
version: "1.0"
paths:
/api/v1/component-codes:
get:
consumes:
- application/json
description: Retrieve a list of all component codes ordered by creation date
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
items:
$ref: '#/definitions/models.ComponentCode'
type: array
type: object
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.ErrorResponse'
summary: List all component codes
tags:
- component-code
post:
consumes:
- application/json
description: Create a new component code with the provided details
parameters:
- description: Component code request body
in: body
name: body
required: true
schema:
$ref: '#/definitions/requests.CreateComponentCodeRequest'
produces:
- application/json
responses:
"201":
description: Created
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
$ref: '#/definitions/responses.CreateComponentCodeResponse'
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 code
tags:
- component-code
/api/v1/component-codes/{id}:
delete:
consumes:
- application/json
description: Delete a component code by its unique identifier
parameters:
- description: Component code 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 code
tags:
- component-code
get:
consumes:
- application/json
description: Retrieve a single component code using its unique identifier
parameters:
- description: Component code 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.ComponentCode'
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 code by ID
tags:
- component-code
put:
consumes:
- application/json
description: Update an existing component code by its ID. Only non-empty fields
will be updated.
parameters:
- description: Component code ID
in: path
name: id
required: true
type: integer
- description: Component code request body
in: body
name: body
required: true
schema:
$ref: '#/definitions/requests.UpdateComponentCodeRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
$ref: '#/definitions/responses.UpdateComponentCodeResponse'
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 code
tags:
- component-code
/api/v1/component-types:
get:
consumes: