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

@@ -9,6 +9,279 @@
"host": "localhost:3000",
"basePath": "/api/v1",
"paths": {
"/api/v1/component-codes": {
"get": {
"description": "Retrieve a list of all component codes ordered by creation date",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-code"
],
"summary": "List all component codes",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/models.ComponentCode"
}
}
}
}
]
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
},
"post": {
"description": "Create a new component code with the provided details",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-code"
],
"summary": "Create a new component code",
"parameters": [
{
"description": "Component code request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.CreateComponentCodeRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.CreateComponentCodeResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/api/v1/component-codes/{id}": {
"get": {
"description": "Retrieve a single component code using its unique identifier",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-code"
],
"summary": "Get component code by ID",
"parameters": [
{
"type": "integer",
"description": "Component code ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.ComponentCode"
}
}
}
]
}
},
"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 component code by its ID. Only non-empty fields will be updated.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-code"
],
"summary": "Update component code",
"parameters": [
{
"type": "integer",
"description": "Component code ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Component code request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.UpdateComponentCodeRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.UpdateComponentCodeResponse"
}
}
}
]
}
},
"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 component code by its unique identifier",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-code"
],
"summary": "Delete component code",
"parameters": [
{
"type": "integer",
"description": "Component code 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"
}
}
}
}
},
"/api/v1/component-types": {
"get": {
"description": "Retrieve a list of all component types ordered by creation date",
@@ -2067,6 +2340,35 @@
}
}
},
"models.ComponentCode": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"codeType": {
"type": "string"
},
"componentId": {
"type": "integer"
},
"createdAt": {
"type": "string"
},
"id": {
"type": "integer"
},
"isPrimary": {
"type": "boolean"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"models.ComponentType": {
"type": "object",
"properties": {
@@ -2241,6 +2543,33 @@
}
}
},
"requests.CreateComponentCodeRequest": {
"type": "object",
"required": [
"code",
"componentId"
],
"properties": {
"code": {
"type": "string"
},
"codeType": {
"type": "string"
},
"componentId": {
"type": "integer"
},
"isPrimary": {
"type": "boolean"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"requests.CreateComponentRequest": {
"type": "object",
"required": [
@@ -2393,6 +2722,29 @@
}
}
},
"requests.UpdateComponentCodeRequest": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"codeType": {
"type": "string"
},
"componentId": {
"type": "integer"
},
"isPrimary": {
"type": "boolean"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"requests.UpdateComponentRequest": {
"type": "object",
"properties": {
@@ -2547,6 +2899,14 @@
}
}
},
"responses.CreateComponentCodeResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer"
}
}
},
"responses.CreateComponentResponse": {
"type": "object",
"properties": {
@@ -2612,6 +2972,26 @@
}
}
},
"responses.UpdateComponentCodeResponse": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"codeType": {
"type": "string"
},
"componentId": {
"type": "integer"
},
"id": {
"type": "integer"
},
"isPrimary": {
"type": "boolean"
}
}
},
"responses.UpdateComponentResponse": {
"type": "object",
"properties": {