feat: implement component-item management with CRUD operations and status updates
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user