Added transaction feature, fixed some mistakes

This commit is contained in:
2026-04-11 11:12:54 +03:00
parent 6872563c62
commit 545b05d5a0
37 changed files with 2509 additions and 115 deletions
+505
View File
@@ -238,6 +238,342 @@
}
}
},
"/receipts": {
"post": {
"description": "Загружает чек из внешнего сервиса и опционально автоматически создает связанную транзакцию",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Receipts"
],
"summary": "Загрузить чек",
"parameters": [
{
"description": "Receipt payload",
"name": "receipt",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/domain.AddReceiptRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.AddReceiptResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/dto.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorResponse"
}
}
}
}
},
"/transactions": {
"get": {
"description": "Возвращает список транзакций с фильтрами и пагинацией",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Transactions"
],
"summary": "Получить список транзакций",
"parameters": [
{
"type": "integer",
"description": "Family ID",
"name": "family_id",
"in": "query"
},
{
"type": "integer",
"description": "User ID",
"name": "created_by",
"in": "query"
},
{
"type": "string",
"description": "Transaction type",
"name": "type",
"in": "query"
},
{
"type": "string",
"description": "Category",
"name": "category",
"in": "query"
},
{
"type": "string",
"description": "RFC3339 start datetime",
"name": "date_from",
"in": "query"
},
{
"type": "string",
"description": "RFC3339 end datetime",
"name": "date_to",
"in": "query"
},
{
"type": "integer",
"description": "Limit, default 50",
"name": "limit",
"in": "query"
},
{
"type": "integer",
"description": "Offset",
"name": "offset",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.TransactionListResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/dto.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorResponse"
}
}
}
},
"post": {
"description": "Создает новую транзакцию и при необходимости привязывает к ней чек",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Transactions"
],
"summary": "Создать транзакцию",
"parameters": [
{
"description": "Transaction payload",
"name": "transaction",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.CreateTransactionRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/dto.TransactionResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/dto.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorResponse"
}
}
}
}
},
"/transactions/{id}": {
"get": {
"description": "Возвращает транзакцию по ее внутреннему ID",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Transactions"
],
"summary": "Получить транзакцию по ID",
"parameters": [
{
"type": "integer",
"description": "Transaction ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.TransactionResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/dto.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorResponse"
}
}
}
},
"delete": {
"description": "Удаляет транзакцию по ID",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Transactions"
],
"summary": "Удалить транзакцию",
"parameters": [
{
"type": "integer",
"description": "Transaction ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"204": {
"description": "no content",
"schema": {
"type": "string"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/dto.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorResponse"
}
}
}
},
"patch": {
"description": "Частично обновляет данные транзакции и связь с чеком",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Transactions"
],
"summary": "Обновить транзакцию",
"parameters": [
{
"type": "integer",
"description": "Transaction ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Transaction patch payload",
"name": "transaction",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.UpdateTransactionRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.TransactionResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/dto.ErrorResponse"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/dto.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/dto.ErrorResponse"
}
}
}
}
},
"/users": {
"post": {
"consumes": [
@@ -490,6 +826,55 @@
}
},
"definitions": {
"domain.AddReceiptRequest": {
"type": "object",
"required": [
"date",
"number"
],
"properties": {
"category": {
"type": "string"
},
"created_by": {
"type": "integer"
},
"date": {
"type": "string"
},
"description": {
"type": "string"
},
"family_id": {
"type": "integer"
},
"number": {
"type": "string",
"maxLength": 24,
"minLength": 24
},
"type": {
"type": "string"
}
}
},
"domain.AddReceiptResponse": {
"type": "object",
"properties": {
"date": {
"type": "string"
},
"id": {
"type": "integer"
},
"number": {
"type": "string"
},
"transaction_id": {
"type": "integer"
}
}
},
"domain.CreateFamilyRequest": {
"type": "object",
"properties": {
@@ -563,6 +948,9 @@
"name": {
"type": "string"
},
"telegram_chat_id": {
"type": "integer"
},
"telegram_chat_name": {
"type": "string"
}
@@ -621,6 +1009,123 @@
"type": "string"
}
}
},
"dto.CreateTransactionRequest": {
"type": "object",
"required": [
"amount",
"category",
"created_by",
"datetime",
"family_id",
"type"
],
"properties": {
"amount": {
"type": "number"
},
"category": {
"type": "string"
},
"created_by": {
"type": "integer"
},
"datetime": {
"type": "string"
},
"description": {
"type": "string"
},
"family_id": {
"type": "integer"
},
"receipt_id": {
"type": "integer"
},
"type": {
"type": "string"
}
}
},
"dto.ErrorResponse": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
},
"dto.TransactionListResponse": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/dto.TransactionResponse"
}
}
}
},
"dto.TransactionResponse": {
"type": "object",
"properties": {
"amount": {
"type": "number"
},
"category": {
"type": "string"
},
"created_at": {
"type": "string"
},
"created_by": {
"type": "integer"
},
"datetime": {
"type": "string"
},
"description": {
"type": "string"
},
"family_id": {
"type": "integer"
},
"id": {
"type": "integer"
},
"receipt_id": {
"type": "integer"
},
"type": {
"type": "string"
}
}
},
"dto.UpdateTransactionRequest": {
"type": "object",
"properties": {
"amount": {
"type": "number"
},
"category": {
"type": "string"
},
"datetime": {
"type": "string"
},
"description": {
"type": "string"
},
"detach_receipt": {
"type": "boolean"
},
"receipt_id": {
"type": "integer"
},
"type": {
"type": "string"
}
}
}
}
}