feat: add endpoints for retrieving stock alerts and anomaly items, including database queries and models

This commit is contained in:
Tran Anh Tuan
2026-05-13 18:10:34 +07:00
parent 383bed757d
commit 0a56dfeb61
11 changed files with 695 additions and 0 deletions

View File

@@ -26,6 +26,27 @@ definitions:
priority:
type: integer
type: object
models.AnomalyItem:
properties:
componentId:
type: integer
componentName:
type: string
componentUnit:
type: string
containerId:
type: integer
createdAt:
type: string
id:
type: integer
quantity:
type: integer
status:
type: string
updatedAt:
type: string
type: object
models.Cabinet:
properties:
createdAt:
@@ -300,6 +321,23 @@ definitions:
updatedAt:
type: string
type: object
models.StockAlert:
properties:
componentTypeId:
type: integer
componentTypeName:
type: string
id:
type: integer
minQuantity:
type: integer
name:
type: string
totalQuantity:
type: integer
unit:
type: string
type: object
models.TodayInvoiceCount:
properties:
count:
@@ -2416,11 +2454,79 @@ paths:
summary: Update container
tags:
- container
/v1/dashboard/anomalies:
get:
consumes:
- application/json
description: Retrieve list of component items with abnormal status (damaged,
expired, long_unused, pending_inspection)
parameters:
- description: Filter by warehouse ID
in: query
name: warehouse_id
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
items:
$ref: '#/definitions/models.AnomalyItem'
type: array
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.ErrorResponse'
summary: Get anomaly items
tags:
- dashboard
/v1/dashboard/stock-alerts:
get:
consumes:
- application/json
description: Retrieve list of components that are low on stock (total_quantity
<= min_quantity)
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
items:
$ref: '#/definitions/models.StockAlert'
type: array
type: object
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.ErrorResponse'
summary: Get stock alerts
tags:
- dashboard
/v1/dashboard/summary:
get:
consumes:
- application/json
description: Retrieve dashboard summary with key statistics
parameters:
- description: Filter by warehouse ID
in: query
name: warehouse_id
type: integer
produces:
- application/json
responses: