feat: add endpoint and logic for retrieving transaction chart data, including SQL queries, models, and service integration

This commit is contained in:
Tran Anh Tuan
2026-05-14 10:41:25 +07:00
parent 0a56dfeb61
commit 96bc22942b
11 changed files with 413 additions and 0 deletions

View File

@@ -2340,6 +2340,68 @@ const docTemplate = `{
}
}
},
"/v1/dashboard/transactions-chart": {
"get": {
"description": "Retrieve import/export transaction quantities grouped by date for chart display",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"dashboard"
],
"summary": "Get transactions chart data",
"parameters": [
{
"type": "string",
"default": "7d",
"description": "Time period: today, 7d, 30d, this_month",
"name": "period",
"in": "query"
},
{
"type": "integer",
"description": "Filter by warehouse ID",
"name": "warehouse_id",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.TransactionChartData"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/v1/invoice-config-items": {
"get": {
"description": "Retrieve a list of all invoice config items",
@@ -4512,6 +4574,31 @@ const docTemplate = `{
}
}
},
"models.TransactionChartData": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/models.TransactionChartItem"
}
}
}
},
"models.TransactionChartItem": {
"type": "object",
"properties": {
"date": {
"type": "string"
},
"exportQuantity": {
"type": "integer"
},
"importQuantity": {
"type": "integer"
}
}
},
"models.Warehouse": {
"type": "object",
"properties": {

View File

@@ -2334,6 +2334,68 @@
}
}
},
"/v1/dashboard/transactions-chart": {
"get": {
"description": "Retrieve import/export transaction quantities grouped by date for chart display",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"dashboard"
],
"summary": "Get transactions chart data",
"parameters": [
{
"type": "string",
"default": "7d",
"description": "Time period: today, 7d, 30d, this_month",
"name": "period",
"in": "query"
},
{
"type": "integer",
"description": "Filter by warehouse ID",
"name": "warehouse_id",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/response.SuccessResponse"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.TransactionChartData"
}
}
}
]
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/response.ErrorResponse"
}
}
}
}
},
"/v1/invoice-config-items": {
"get": {
"description": "Retrieve a list of all invoice config items",
@@ -4506,6 +4568,31 @@
}
}
},
"models.TransactionChartData": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/models.TransactionChartItem"
}
}
}
},
"models.TransactionChartItem": {
"type": "object",
"properties": {
"date": {
"type": "string"
},
"exportQuantity": {
"type": "integer"
},
"importQuantity": {
"type": "integer"
}
}
},
"models.Warehouse": {
"type": "object",
"properties": {

View File

@@ -352,6 +352,22 @@ definitions:
totalTypes:
type: integer
type: object
models.TransactionChartData:
properties:
items:
items:
$ref: '#/definitions/models.TransactionChartItem'
type: array
type: object
models.TransactionChartItem:
properties:
date:
type: string
exportQuantity:
type: integer
importQuantity:
type: integer
type: object
models.Warehouse:
properties:
address:
@@ -2546,6 +2562,45 @@ paths:
summary: Get dashboard summary
tags:
- dashboard
/v1/dashboard/transactions-chart:
get:
consumes:
- application/json
description: Retrieve import/export transaction quantities grouped by date for
chart display
parameters:
- default: 7d
description: 'Time period: today, 7d, 30d, this_month'
in: query
name: period
type: string
- 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:
$ref: '#/definitions/models.TransactionChartData'
type: object
"400":
description: Bad Request
schema:
$ref: '#/definitions/response.ErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/response.ErrorResponse'
summary: Get transactions chart data
tags:
- dashboard
/v1/invoice-config-items:
get:
consumes: