Implemented families

- Added families.
- Added test for all endpoints
- Updated users DTO
This commit is contained in:
2026-03-07 11:29:40 +03:00
parent a70527b388
commit 418801b056
16 changed files with 2614 additions and 154 deletions
+411
View File
@@ -0,0 +1,411 @@
definitions:
dto.CreateFamilyRequest:
properties:
name:
type: string
owner_id:
type: integer
telegram_chat_id:
type: integer
telegram_chat_name:
type: string
type: object
dto.CreateUserRequest:
properties:
first_name:
type: string
language_code:
type: string
last_name:
type: string
telegram_id:
type: integer
username:
type: string
required:
- first_name
- telegram_id
type: object
dto.FamilyResponse:
properties:
created_at:
type: string
id:
type: integer
name:
type: string
owner_id:
type: integer
telegram_chat_id:
type: integer
telegram_chat_name:
type: string
updated_at:
type: string
type: object
dto.UpdateFamilyRequest:
properties:
name:
type: string
telegram_chat_name:
type: string
type: object
dto.UpdateUserRequest:
properties:
first_name:
type: string
language_code:
type: string
last_name:
type: string
username:
type: string
type: object
dto.UserErrorResponse:
properties:
error:
type: string
type: object
dto.UserResponse:
properties:
created_at:
type: string
first_name:
type: string
id:
type: integer
language_code:
type: string
last_name:
type: string
telegram_id:
type: integer
updated_at:
type: string
username:
type: string
type: object
info:
contact: {}
paths:
/families:
post:
consumes:
- application/json
description: Создает новую семью
parameters:
- description: Family info
in: body
name: family
required: true
schema:
$ref: '#/definitions/dto.CreateFamilyRequest'
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/dto.FamilyResponse'
"400":
description: invalid body
schema:
additionalProperties:
type: string
type: object
"500":
description: internal server error
schema:
additionalProperties:
type: string
type: object
summary: Создать семью
tags:
- Families
/families/{id}:
delete:
consumes:
- application/json
description: Удаляет семью по ее ID
parameters:
- description: Family ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"204":
description: no content
schema:
type: string
"400":
description: invalid id
schema:
additionalProperties:
type: string
type: object
"404":
description: family not found
schema:
additionalProperties:
type: string
type: object
"500":
description: internal server error
schema:
additionalProperties:
type: string
type: object
summary: Удалить семью
tags:
- Families
get:
consumes:
- application/json
description: Возвращает семью по ее внутреннему ID
parameters:
- description: Family ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.FamilyResponse'
"400":
description: invalid id
schema:
additionalProperties:
type: string
type: object
"404":
description: family not found
schema:
additionalProperties:
type: string
type: object
"500":
description: internal server error
schema:
additionalProperties:
type: string
type: object
summary: Получить семью по ID
tags:
- Families
patch:
consumes:
- application/json
description: Частично обновляет данные семьи по ID
parameters:
- description: Family ID
in: path
name: id
required: true
type: integer
- description: Данные для обновления
in: body
name: family
required: true
schema:
$ref: '#/definitions/dto.UpdateFamilyRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.FamilyResponse'
"400":
description: name is required
schema:
additionalProperties:
type: string
type: object
"404":
description: family not found
schema:
additionalProperties:
type: string
type: object
"500":
description: internal server error
schema:
additionalProperties:
type: string
type: object
summary: Обновить семью
tags:
- Families
/users:
post:
consumes:
- application/json
parameters:
- description: User info
in: body
name: user
required: true
schema:
$ref: '#/definitions/dto.CreateUserRequest'
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/dto.UserResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/dto.UserErrorResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/dto.UserErrorResponse'
summary: Создать пользователя
tags:
- Users
/users/{id}:
delete:
consumes:
- application/json
description: Удаляет пользователя по его ID
parameters:
- description: User ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"204":
description: no content
schema:
type: string
"400":
description: invalid id
schema:
$ref: '#/definitions/dto.UserErrorResponse'
"404":
description: user not found
schema:
$ref: '#/definitions/dto.UserErrorResponse'
"500":
description: internal server error
schema:
$ref: '#/definitions/dto.UserErrorResponse'
summary: Удалить пользователя
tags:
- Users
get:
consumes:
- application/json
description: Возвращает пользователя по его внутреннему ID
parameters:
- description: User ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.UserResponse'
"400":
description: invalid id
schema:
$ref: '#/definitions/dto.UserErrorResponse'
"404":
description: user not found
schema:
$ref: '#/definitions/dto.UserErrorResponse'
"500":
description: internal server error
schema:
$ref: '#/definitions/dto.UserErrorResponse'
summary: Получить пользователя по ID
tags:
- Users
patch:
consumes:
- application/json
description: Частично обновляет данные пользователя по ID
parameters:
- description: User ID
in: path
name: id
required: true
type: integer
- description: Данные для обновления
in: body
name: user
required: true
schema:
$ref: '#/definitions/dto.UpdateUserRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.UserResponse'
"400":
description: invalid id or invalid body
schema:
$ref: '#/definitions/dto.UserErrorResponse'
"404":
description: user not found
schema:
$ref: '#/definitions/dto.UserErrorResponse'
"500":
description: internal server error
schema:
$ref: '#/definitions/dto.UserErrorResponse'
summary: Обновить пользователя
tags:
- Users
/users/by-telegram/{telegramId}:
get:
consumes:
- application/json
description: Возвращает пользователя по его Telegram ID
parameters:
- description: Telegram ID
in: path
name: telegramId
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.UserResponse'
"400":
description: invalid telegram id
schema:
$ref: '#/definitions/dto.UserErrorResponse'
"404":
description: user not found
schema:
$ref: '#/definitions/dto.UserErrorResponse'
"500":
description: internal server error
schema:
$ref: '#/definitions/dto.UserErrorResponse'
summary: Получить пользователя по Telegram ID
tags:
- Users
swagger: "2.0"