feat: implement component-item management with CRUD operations and status updates

This commit is contained in:
Tran Anh Tuan
2026-05-11 17:49:18 +07:00
parent 9ea72b4eea
commit 0ff65a18c0
23 changed files with 3870 additions and 0 deletions

View File

@@ -288,6 +288,409 @@ const docTemplate = `{
}
}
},
"/api/v1/component-items": {
"get": {
"description": "Retrieve a list of all component items ordered by creation date",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-item"
],
"summary": "List all component items",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/models.ComponentItem"
}
}
}
}
]
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
},
"post": {
"description": "Create a new component item with the provided details",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-item"
],
"summary": "Create a new component item",
"parameters": [
{
"description": "Component item request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.CreateComponentItemRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.CreateComponentItemResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/api/v1/component-items/find/{componentId}": {
"get": {
"description": "Retrieve component items with full location details (container, shelf, cabinet, room, warehouse) for a given component ID",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-item"
],
"summary": "Find component items by component ID",
"parameters": [
{
"type": "integer",
"description": "Component ID",
"name": "componentId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/models.FindComponentItemResult"
}
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/api/v1/component-items/{id}": {
"get": {
"description": "Retrieve a single component item using its unique identifier",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-item"
],
"summary": "Get component item by ID",
"parameters": [
{
"type": "integer",
"description": "Component item ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.ComponentItem"
}
}
}
]
}
},
"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 item by its ID. Only non-empty fields will be updated.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-item"
],
"summary": "Update component item",
"parameters": [
{
"type": "integer",
"description": "Component item ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Component item request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.UpdateComponentItemRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.UpdateComponentItemResponse"
}
}
}
]
}
},
"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 item by its unique identifier",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-item"
],
"summary": "Delete component item",
"parameters": [
{
"type": "integer",
"description": "Component item 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-items/{id}/status": {
"put": {
"description": "Change the status of a component item. Supports partial quantity change with automatic split/merge logic. A status history record is created automatically.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-item"
],
"summary": "Change component item status",
"parameters": [
{
"type": "integer",
"description": "Component item ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Status change request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.UpdateComponentItemStatusRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.UpdateComponentItemStatusResponse"
}
}
}
]
}
},
"400": {
"description": "Validation error (e.g., changed_quantity \u003e quantity, status unchanged)",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"404": {
"description": "Component item not found",
"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",
@@ -2375,6 +2778,38 @@ const docTemplate = `{
}
}
},
"models.ComponentItem": {
"type": "object",
"properties": {
"componentId": {
"type": "integer"
},
"containerId": {
"type": "integer"
},
"createdAt": {
"type": "string"
},
"id": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
},
"quantity": {
"type": "integer"
},
"status": {
"type": "string"
},
"updatedAt": {
"type": "string"
}
}
},
"models.ComponentType": {
"type": "object",
"properties": {
@@ -2436,6 +2871,41 @@ const docTemplate = `{
}
}
},
"models.FindComponentItemResult": {
"type": "object",
"properties": {
"cabinetName": {
"type": "string"
},
"componentName": {
"type": "string"
},
"containerName": {
"type": "string"
},
"containerType": {
"type": "string"
},
"quantity": {
"type": "integer"
},
"roomName": {
"type": "string"
},
"shelfName": {
"type": "string"
},
"status": {
"type": "string"
},
"typeName": {
"type": "string"
},
"warehouseName": {
"type": "string"
}
}
},
"models.Room": {
"type": "object",
"properties": {
@@ -2576,6 +3046,35 @@ const docTemplate = `{
}
}
},
"requests.CreateComponentItemRequest": {
"type": "object",
"required": [
"componentId",
"containerId",
"quantity",
"status"
],
"properties": {
"componentId": {
"type": "integer"
},
"containerId": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
},
"quantity": {
"type": "integer"
},
"status": {
"type": "string"
}
}
},
"requests.CreateComponentRequest": {
"type": "object",
"required": [
@@ -2751,6 +3250,47 @@ const docTemplate = `{
}
}
},
"requests.UpdateComponentItemRequest": {
"type": "object",
"properties": {
"componentId": {
"type": "integer"
},
"containerId": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"requests.UpdateComponentItemStatusRequest": {
"type": "object",
"required": [
"status"
],
"properties": {
"changedQuantity": {
"type": "integer"
},
"note": {
"type": "string"
},
"status": {
"type": "string",
"enum": [
"normal",
"damaged",
"long_unused",
"expired",
"pending_inspection"
]
}
}
},
"requests.UpdateComponentRequest": {
"type": "object",
"properties": {
@@ -2913,6 +3453,14 @@ const docTemplate = `{
}
}
},
"responses.CreateComponentItemResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer"
}
}
},
"responses.CreateComponentResponse": {
"type": "object",
"properties": {
@@ -2998,6 +3546,58 @@ const docTemplate = `{
}
}
},
"responses.UpdateComponentItemResponse": {
"type": "object",
"properties": {
"componentId": {
"type": "integer"
},
"containerId": {
"type": "integer"
},
"id": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
},
"quantity": {
"type": "integer"
},
"status": {
"type": "string"
}
}
},
"responses.UpdateComponentItemStatusResponse": {
"type": "object",
"properties": {
"changedQuantity": {
"type": "integer"
},
"historyId": {
"type": "integer"
},
"id": {
"type": "integer"
},
"mergedComponentItemId": {
"type": "integer"
},
"newComponentItemId": {
"type": "integer"
},
"newStatus": {
"type": "string"
},
"oldStatus": {
"type": "string"
}
}
},
"responses.UpdateComponentResponse": {
"type": "object",
"properties": {

View File

@@ -282,6 +282,409 @@
}
}
},
"/api/v1/component-items": {
"get": {
"description": "Retrieve a list of all component items ordered by creation date",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-item"
],
"summary": "List all component items",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/models.ComponentItem"
}
}
}
}
]
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
},
"post": {
"description": "Create a new component item with the provided details",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-item"
],
"summary": "Create a new component item",
"parameters": [
{
"description": "Component item request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.CreateComponentItemRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.CreateComponentItemResponse"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/api/v1/component-items/find/{componentId}": {
"get": {
"description": "Retrieve component items with full location details (container, shelf, cabinet, room, warehouse) for a given component ID",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-item"
],
"summary": "Find component items by component ID",
"parameters": [
{
"type": "integer",
"description": "Component ID",
"name": "componentId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/models.FindComponentItemResult"
}
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/api/v1/component-items/{id}": {
"get": {
"description": "Retrieve a single component item using its unique identifier",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-item"
],
"summary": "Get component item by ID",
"parameters": [
{
"type": "integer",
"description": "Component item ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.ComponentItem"
}
}
}
]
}
},
"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 item by its ID. Only non-empty fields will be updated.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-item"
],
"summary": "Update component item",
"parameters": [
{
"type": "integer",
"description": "Component item ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Component item request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.UpdateComponentItemRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.UpdateComponentItemResponse"
}
}
}
]
}
},
"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 item by its unique identifier",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-item"
],
"summary": "Delete component item",
"parameters": [
{
"type": "integer",
"description": "Component item 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-items/{id}/status": {
"put": {
"description": "Change the status of a component item. Supports partial quantity change with automatic split/merge logic. A status history record is created automatically.",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"component-item"
],
"summary": "Change component item status",
"parameters": [
{
"type": "integer",
"description": "Component item ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Status change request body",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/requests.UpdateComponentItemStatusRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.UpdateComponentItemStatusResponse"
}
}
}
]
}
},
"400": {
"description": "Validation error (e.g., changed_quantity \u003e quantity, status unchanged)",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"404": {
"description": "Component item not found",
"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",
@@ -2369,6 +2772,38 @@
}
}
},
"models.ComponentItem": {
"type": "object",
"properties": {
"componentId": {
"type": "integer"
},
"containerId": {
"type": "integer"
},
"createdAt": {
"type": "string"
},
"id": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
},
"quantity": {
"type": "integer"
},
"status": {
"type": "string"
},
"updatedAt": {
"type": "string"
}
}
},
"models.ComponentType": {
"type": "object",
"properties": {
@@ -2430,6 +2865,41 @@
}
}
},
"models.FindComponentItemResult": {
"type": "object",
"properties": {
"cabinetName": {
"type": "string"
},
"componentName": {
"type": "string"
},
"containerName": {
"type": "string"
},
"containerType": {
"type": "string"
},
"quantity": {
"type": "integer"
},
"roomName": {
"type": "string"
},
"shelfName": {
"type": "string"
},
"status": {
"type": "string"
},
"typeName": {
"type": "string"
},
"warehouseName": {
"type": "string"
}
}
},
"models.Room": {
"type": "object",
"properties": {
@@ -2570,6 +3040,35 @@
}
}
},
"requests.CreateComponentItemRequest": {
"type": "object",
"required": [
"componentId",
"containerId",
"quantity",
"status"
],
"properties": {
"componentId": {
"type": "integer"
},
"containerId": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
},
"quantity": {
"type": "integer"
},
"status": {
"type": "string"
}
}
},
"requests.CreateComponentRequest": {
"type": "object",
"required": [
@@ -2745,6 +3244,47 @@
}
}
},
"requests.UpdateComponentItemRequest": {
"type": "object",
"properties": {
"componentId": {
"type": "integer"
},
"containerId": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"requests.UpdateComponentItemStatusRequest": {
"type": "object",
"required": [
"status"
],
"properties": {
"changedQuantity": {
"type": "integer"
},
"note": {
"type": "string"
},
"status": {
"type": "string",
"enum": [
"normal",
"damaged",
"long_unused",
"expired",
"pending_inspection"
]
}
}
},
"requests.UpdateComponentRequest": {
"type": "object",
"properties": {
@@ -2907,6 +3447,14 @@
}
}
},
"responses.CreateComponentItemResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer"
}
}
},
"responses.CreateComponentResponse": {
"type": "object",
"properties": {
@@ -2992,6 +3540,58 @@
}
}
},
"responses.UpdateComponentItemResponse": {
"type": "object",
"properties": {
"componentId": {
"type": "integer"
},
"containerId": {
"type": "integer"
},
"id": {
"type": "integer"
},
"metadata": {
"type": "array",
"items": {
"type": "integer"
}
},
"quantity": {
"type": "integer"
},
"status": {
"type": "string"
}
}
},
"responses.UpdateComponentItemStatusResponse": {
"type": "object",
"properties": {
"changedQuantity": {
"type": "integer"
},
"historyId": {
"type": "integer"
},
"id": {
"type": "integer"
},
"mergedComponentItemId": {
"type": "integer"
},
"newComponentItemId": {
"type": "integer"
},
"newStatus": {
"type": "string"
},
"oldStatus": {
"type": "string"
}
}
},
"responses.UpdateComponentResponse": {
"type": "object",
"properties": {

View File

@@ -59,6 +59,27 @@ definitions:
type: integer
type: array
type: object
models.ComponentItem:
properties:
componentId:
type: integer
containerId:
type: integer
createdAt:
type: string
id:
type: integer
metadata:
items:
type: integer
type: array
quantity:
type: integer
status:
type: string
updatedAt:
type: string
type: object
models.ComponentType:
properties:
createdAt:
@@ -99,6 +120,29 @@ definitions:
updatedAt:
type: string
type: object
models.FindComponentItemResult:
properties:
cabinetName:
type: string
componentName:
type: string
containerName:
type: string
containerType:
type: string
quantity:
type: integer
roomName:
type: string
shelfName:
type: string
status:
type: string
typeName:
type: string
warehouseName:
type: string
type: object
models.Room:
properties:
createdAt:
@@ -192,6 +236,26 @@ definitions:
- code
- componentId
type: object
requests.CreateComponentItemRequest:
properties:
componentId:
type: integer
containerId:
type: integer
metadata:
items:
type: integer
type: array
quantity:
type: integer
status:
type: string
required:
- componentId
- containerId
- quantity
- status
type: object
requests.CreateComponentRequest:
properties:
componentTypeId:
@@ -309,6 +373,34 @@ definitions:
type: integer
type: array
type: object
requests.UpdateComponentItemRequest:
properties:
componentId:
type: integer
containerId:
type: integer
metadata:
items:
type: integer
type: array
type: object
requests.UpdateComponentItemStatusRequest:
properties:
changedQuantity:
type: integer
note:
type: string
status:
enum:
- normal
- damaged
- long_unused
- expired
- pending_inspection
type: string
required:
- status
type: object
requests.UpdateComponentRequest:
properties:
componentTypeId:
@@ -414,6 +506,11 @@ definitions:
id:
type: integer
type: object
responses.CreateComponentItemResponse:
properties:
id:
type: integer
type: object
responses.CreateComponentResponse:
properties:
id:
@@ -468,6 +565,40 @@ definitions:
isPrimary:
type: boolean
type: object
responses.UpdateComponentItemResponse:
properties:
componentId:
type: integer
containerId:
type: integer
id:
type: integer
metadata:
items:
type: integer
type: array
quantity:
type: integer
status:
type: string
type: object
responses.UpdateComponentItemStatusResponse:
properties:
changedQuantity:
type: integer
historyId:
type: integer
id:
type: integer
mergedComponentItemId:
type: integer
newComponentItemId:
type: integer
newStatus:
type: string
oldStatus:
type: string
type: object
responses.UpdateComponentResponse:
properties:
componentTypeId:
@@ -723,6 +854,260 @@ paths:
summary: Update component code
tags:
- component-code
/api/v1/component-items:
get:
consumes:
- application/json
description: Retrieve a list of all component items ordered by creation date
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
items:
$ref: '#/definitions/models.ComponentItem'
type: array
type: object
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.ErrorResponse'
summary: List all component items
tags:
- component-item
post:
consumes:
- application/json
description: Create a new component item with the provided details
parameters:
- description: Component item request body
in: body
name: body
required: true
schema:
$ref: '#/definitions/requests.CreateComponentItemRequest'
produces:
- application/json
responses:
"201":
description: Created
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
$ref: '#/definitions/responses.CreateComponentItemResponse'
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 item
tags:
- component-item
/api/v1/component-items/{id}:
delete:
consumes:
- application/json
description: Delete a component item by its unique identifier
parameters:
- description: Component item 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 item
tags:
- component-item
get:
consumes:
- application/json
description: Retrieve a single component item using its unique identifier
parameters:
- description: Component item 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.ComponentItem'
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 item by ID
tags:
- component-item
put:
consumes:
- application/json
description: Update an existing component item by its ID. Only non-empty fields
will be updated.
parameters:
- description: Component item ID
in: path
name: id
required: true
type: integer
- description: Component item request body
in: body
name: body
required: true
schema:
$ref: '#/definitions/requests.UpdateComponentItemRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
$ref: '#/definitions/responses.UpdateComponentItemResponse'
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 item
tags:
- component-item
/api/v1/component-items/{id}/status:
put:
consumes:
- application/json
description: Change the status of a component item. Supports partial quantity
change with automatic split/merge logic. A status history record is created
automatically.
parameters:
- description: Component item ID
in: path
name: id
required: true
type: integer
- description: Status change request body
in: body
name: body
required: true
schema:
$ref: '#/definitions/requests.UpdateComponentItemStatusRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
$ref: '#/definitions/responses.UpdateComponentItemStatusResponse'
type: object
"400":
description: Validation error (e.g., changed_quantity > quantity, status
unchanged)
schema:
$ref: '#/definitions/response.ErrorResponse'
"404":
description: Component item not found
schema:
$ref: '#/definitions/response.ErrorResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/response.ErrorResponse'
summary: Change component item status
tags:
- component-item
/api/v1/component-items/find/{componentId}:
get:
consumes:
- application/json
description: Retrieve component items with full location details (container,
shelf, cabinet, room, warehouse) for a given component ID
parameters:
- description: Component ID
in: path
name: componentId
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
items:
$ref: '#/definitions/models.FindComponentItemResult'
type: array
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.ErrorResponse'
summary: Find component items by component ID
tags:
- component-item
/api/v1/component-types:
get:
consumes: