fix: исправить алиасы в эндпоинтах и удалить неиспользуемые DTO

This commit is contained in:
Artem 2025-12-03 05:31:17 +01:00
parent 38a57b3e31
commit f1503b2fda
No known key found for this signature in database
GPG key ID: 833485276B7902CE
7 changed files with 22 additions and 28 deletions

View file

@ -135,7 +135,8 @@ class UsersController(BaseController):
"""Get user subscription request history, recent 24 records"""
...
@get("/users/by-short-uuid/{short_uuid}", response_class=GetUserByShortUuidResponseDto)
# ИСПРАВЛЕНО: убран alias, используется short_uuid
@get("/users/by-short-uuid/{shortUuid}", response_class=GetUserByShortUuidResponseDto)
async def get_user_by_short_uuid(
self,
short_uuid: Annotated[str, Path(description="Short UUID of the user", alias="shortUuid")],
@ -151,7 +152,6 @@ class UsersController(BaseController):
"""Get user by username"""
...
# НОВЫЙ ЭНДПОИНТ
@get("/users/by-id/{id}", response_class=GetUserByIdResponseDto)
async def get_user_by_id(
self,
@ -160,8 +160,9 @@ class UsersController(BaseController):
"""Get user by ID"""
...
# ИСПРАВЛЕНО: убран alias, используется telegram_id
@get(
"/users/by-telegram-id/{telegram_id}",
"/users/by-telegram-id/{telegramId}",
response_class=TelegramUserResponseDto,
)
async def get_users_by_telegram_id(

View file

@ -263,7 +263,6 @@ from .users import (
# Response DTOs - Collections
GetAllUsersResponseDto,
GetAllTagsResponseDto,
GetUserAccessibleNodesResponseDto,
GetUserSubscriptionRequestHistoryResponseDto,
# Response DTOs - Arrays (RootModel)
@ -590,7 +589,6 @@ __all__ = [
"ActivateAllInboundsResponseDto",
"GetAllUsersResponseDto",
"GetAllTagsResponseDto",
"GetUserAccessibleNodesResponseDto",
"GetUserSubscriptionRequestHistoryResponseDto",
"TelegramUserResponseDto",
"EmailUserResponseDto",

View file

@ -125,8 +125,6 @@ class NodeResponseDto(BaseModel):
is_connected: bool = Field(alias="isConnected")
is_disabled: bool = Field(alias="isDisabled")
is_connecting: bool = Field(alias="isConnecting")
is_node_online: bool = Field(alias="isNodeOnline")
is_xray_running: bool = Field(alias="isXrayRunning")
last_status_change: Optional[datetime] = Field(None, alias="lastStatusChange")
last_status_message: Optional[str] = Field(None, alias="lastStatusMessage")
xray_version: Optional[str] = Field(None, alias="xrayVersion")

View file

@ -4,11 +4,17 @@ from uuid import UUID
from pydantic import BaseModel, Field, RootModel
class NodeActiveSquadDto(BaseModel):
squad_name: str = Field(alias="squadName")
active_inbounds: list[str] = Field(alias="activeInbounds")
class NodeInfoDto(BaseModel):
uuid: UUID
name: str
country_code: str = Field(alias="countryCode")
config_profile_name: str = Field(alias="configProfileName")
config_profile_uuid: UUID = Field(alias="configProfileUuid")
active_squads: List[NodeActiveSquadDto] = Field(alias="activeSquads")
class GetUserAccessibleNodesResponse(BaseModel):
user_uuid: UUID = Field(alias="userUuid")

View file

@ -320,14 +320,5 @@ class TelegramUserResponseDto(RootModel[list[UserResponseDto]]):
def __iter__(self):
return iter(self.root)
def __getitem__(self, item):
return self.root[item]
class GetUserAccessibleNodesResponseDto(RootModel[list[UUID]]):
"""Response for get user accessible nodes"""
def __iter__(self):
return iter(self.root)
def __getitem__(self, item):
return self.root[item]