feat: add dashboard summary endpoint and related models, queries, and services

This commit is contained in:
Tran Anh Tuan
2026-05-13 17:53:32 +07:00
parent b815111b8f
commit 383bed757d
12 changed files with 928 additions and 0 deletions

View File

@@ -1327,6 +1327,49 @@ const docTemplate = `{
}
}
},
"/profile": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Returns user info with roles and permissions (requires auth)",
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Get current user profile",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.BodyProfileResponse"
}
}
}
]
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/v1/alternative-components": {
"get": {
"description": "Retrieve a list of all alternative components",
@@ -2146,6 +2189,47 @@ const docTemplate = `{
}
}
},
"/v1/dashboard/summary": {
"get": {
"description": "Retrieve dashboard summary with key statistics",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"dashboard"
],
"summary": "Get dashboard summary",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.DashboardSummary"
}
}
}
]
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/v1/invoice-config-items": {
"get": {
"description": "Retrieve a list of all invoice config items",
@@ -3780,6 +3864,17 @@ const docTemplate = `{
}
},
"definitions": {
"models.AbnormalAlert": {
"type": "object",
"properties": {
"count": {
"type": "integer"
},
"status": {
"type": "string"
}
}
},
"models.AlternativeComponent": {
"type": "object",
"properties": {
@@ -3992,6 +4087,46 @@ const docTemplate = `{
}
}
},
"models.ContainerStats": {
"type": "object",
"properties": {
"emptyContainers": {
"type": "integer"
},
"totalContainers": {
"type": "integer"
}
}
},
"models.DashboardSummary": {
"type": "object",
"properties": {
"abnormalAlerts": {
"type": "array",
"items": {
"$ref": "#/definitions/models.AbnormalAlert"
}
},
"emptyContainers": {
"$ref": "#/definitions/models.ContainerStats"
},
"lowStockComponents": {
"type": "integer"
},
"pendingInvoices": {
"type": "integer"
},
"todayInvoices": {
"type": "array",
"items": {
"$ref": "#/definitions/models.TodayInvoiceCount"
}
},
"totalComponents": {
"$ref": "#/definitions/models.TotalComponentStats"
}
}
},
"models.FindComponentItemResult": {
"type": "object",
"properties": {
@@ -4187,6 +4322,28 @@ const docTemplate = `{
}
}
},
"models.TodayInvoiceCount": {
"type": "object",
"properties": {
"count": {
"type": "integer"
},
"type": {
"type": "string"
}
}
},
"models.TotalComponentStats": {
"type": "object",
"properties": {
"totalQuantity": {
"type": "integer"
},
"totalTypes": {
"type": "integer"
}
}
},
"models.Warehouse": {
"type": "object",
"properties": {
@@ -4841,6 +4998,26 @@ const docTemplate = `{
}
}
},
"responses.BodyProfileResponse": {
"type": "object",
"properties": {
"info": {
"$ref": "#/definitions/responses.UserInfoResponse"
},
"permissions": {
"type": "array",
"items": {
"type": "string"
}
},
"roles": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.RoleItem"
}
}
}
},
"responses.BodyRegisterResponse": {
"type": "object",
"properties": {
@@ -4956,6 +5133,20 @@ const docTemplate = `{
}
}
},
"responses.RoleItem": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"responses.UpdateAlternativeComponentResponse": {
"type": "object",
"properties": {
@@ -5259,6 +5450,26 @@ const docTemplate = `{
"type": "string"
}
}
},
"responses.UserInfoResponse": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"fullName": {
"type": "string"
},
"id": {
"type": "string"
},
"isActive": {
"type": "boolean"
},
"username": {
"type": "string"
}
}
}
}
}`

View File

@@ -1321,6 +1321,49 @@
}
}
},
"/profile": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Returns user info with roles and permissions (requires auth)",
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Get current user profile",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/responses.BodyProfileResponse"
}
}
}
]
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/v1/alternative-components": {
"get": {
"description": "Retrieve a list of all alternative components",
@@ -2140,6 +2183,47 @@
}
}
},
"/v1/dashboard/summary": {
"get": {
"description": "Retrieve dashboard summary with key statistics",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"dashboard"
],
"summary": "Get dashboard summary",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.DashboardSummary"
}
}
}
]
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/v1/invoice-config-items": {
"get": {
"description": "Retrieve a list of all invoice config items",
@@ -3774,6 +3858,17 @@
}
},
"definitions": {
"models.AbnormalAlert": {
"type": "object",
"properties": {
"count": {
"type": "integer"
},
"status": {
"type": "string"
}
}
},
"models.AlternativeComponent": {
"type": "object",
"properties": {
@@ -3986,6 +4081,46 @@
}
}
},
"models.ContainerStats": {
"type": "object",
"properties": {
"emptyContainers": {
"type": "integer"
},
"totalContainers": {
"type": "integer"
}
}
},
"models.DashboardSummary": {
"type": "object",
"properties": {
"abnormalAlerts": {
"type": "array",
"items": {
"$ref": "#/definitions/models.AbnormalAlert"
}
},
"emptyContainers": {
"$ref": "#/definitions/models.ContainerStats"
},
"lowStockComponents": {
"type": "integer"
},
"pendingInvoices": {
"type": "integer"
},
"todayInvoices": {
"type": "array",
"items": {
"$ref": "#/definitions/models.TodayInvoiceCount"
}
},
"totalComponents": {
"$ref": "#/definitions/models.TotalComponentStats"
}
}
},
"models.FindComponentItemResult": {
"type": "object",
"properties": {
@@ -4181,6 +4316,28 @@
}
}
},
"models.TodayInvoiceCount": {
"type": "object",
"properties": {
"count": {
"type": "integer"
},
"type": {
"type": "string"
}
}
},
"models.TotalComponentStats": {
"type": "object",
"properties": {
"totalQuantity": {
"type": "integer"
},
"totalTypes": {
"type": "integer"
}
}
},
"models.Warehouse": {
"type": "object",
"properties": {
@@ -4835,6 +4992,26 @@
}
}
},
"responses.BodyProfileResponse": {
"type": "object",
"properties": {
"info": {
"$ref": "#/definitions/responses.UserInfoResponse"
},
"permissions": {
"type": "array",
"items": {
"type": "string"
}
},
"roles": {
"type": "array",
"items": {
"$ref": "#/definitions/responses.RoleItem"
}
}
}
},
"responses.BodyRegisterResponse": {
"type": "object",
"properties": {
@@ -4950,6 +5127,20 @@
}
}
},
"responses.RoleItem": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"responses.UpdateAlternativeComponentResponse": {
"type": "object",
"properties": {
@@ -5253,6 +5444,26 @@
"type": "string"
}
}
},
"responses.UserInfoResponse": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"fullName": {
"type": "string"
},
"id": {
"type": "string"
},
"isActive": {
"type": "boolean"
},
"username": {
"type": "string"
}
}
}
}
}

View File

@@ -1,5 +1,12 @@
basePath: /api/v1
definitions:
models.AbnormalAlert:
properties:
count:
type: integer
status:
type: string
type: object
models.AlternativeComponent:
properties:
alternativeComponentId:
@@ -139,6 +146,32 @@ definitions:
updatedAt:
type: string
type: object
models.ContainerStats:
properties:
emptyContainers:
type: integer
totalContainers:
type: integer
type: object
models.DashboardSummary:
properties:
abnormalAlerts:
items:
$ref: '#/definitions/models.AbnormalAlert'
type: array
emptyContainers:
$ref: '#/definitions/models.ContainerStats'
lowStockComponents:
type: integer
pendingInvoices:
type: integer
todayInvoices:
items:
$ref: '#/definitions/models.TodayInvoiceCount'
type: array
totalComponents:
$ref: '#/definitions/models.TotalComponentStats'
type: object
models.FindComponentItemResult:
properties:
cabinetName:
@@ -267,6 +300,20 @@ definitions:
updatedAt:
type: string
type: object
models.TodayInvoiceCount:
properties:
count:
type: integer
type:
type: string
type: object
models.TotalComponentStats:
properties:
totalQuantity:
type: integer
totalTypes:
type: integer
type: object
models.Warehouse:
properties:
address:
@@ -703,6 +750,19 @@ definitions:
status:
type: integer
type: object
responses.BodyProfileResponse:
properties:
info:
$ref: '#/definitions/responses.UserInfoResponse'
permissions:
items:
type: string
type: array
roles:
items:
$ref: '#/definitions/responses.RoleItem'
type: array
type: object
responses.BodyRegisterResponse:
properties:
id:
@@ -775,6 +835,15 @@ definitions:
id:
type: integer
type: object
responses.RoleItem:
properties:
description:
type: string
id:
type: string
name:
type: string
type: object
responses.UpdateAlternativeComponentResponse:
properties:
alternativeComponentId:
@@ -973,6 +1042,19 @@ definitions:
name:
type: string
type: object
responses.UserInfoResponse:
properties:
email:
type: string
fullName:
type: string
id:
type: string
isActive:
type: boolean
username:
type: string
type: object
host: localhost:3000
info:
contact: {}
@@ -1800,6 +1882,30 @@ paths:
summary: Health check
tags:
- health
/profile:
get:
description: Returns user info with roles and permissions (requires auth)
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
$ref: '#/definitions/responses.BodyProfileResponse'
type: object
"401":
description: Unauthorized
schema:
$ref: '#/definitions/response.ErrorResponse'
security:
- BearerAuth: []
summary: Get current user profile
tags:
- auth
/v1/alternative-components:
get:
consumes:
@@ -2310,6 +2416,30 @@ paths:
summary: Update container
tags:
- container
/v1/dashboard/summary:
get:
consumes:
- application/json
description: Retrieve dashboard summary with key statistics
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/response.SuccessResponse'
- properties:
data:
$ref: '#/definitions/models.DashboardSummary'
type: object
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.ErrorResponse'
summary: Get dashboard summary
tags:
- dashboard
/v1/invoice-config-items:
get:
consumes: