diff --git a/api/api/db/logic/account.py b/api/api/db/logic/account.py index 21a73c8..f6b92fb 100644 --- a/api/api/db/logic/account.py +++ b/api/api/db/logic/account.py @@ -80,7 +80,6 @@ async def get_user_by_login(connection: AsyncConnection, login: str) -> Optional if not user_data: return None - return User.model_validate(user_data) diff --git a/api/api/db/logic/listevents.py b/api/api/db/logic/listevents.py index e28589b..d00818b 100644 --- a/api/api/db/logic/listevents.py +++ b/api/api/db/logic/listevents.py @@ -122,9 +122,6 @@ async def get_listevents_by_name(connection: AsyncConnection, name: str) -> Opti if not listevents_data: return None - - - return ListEvent.model_validate(listevents_data) diff --git a/api/api/db/logic/processschema.py b/api/api/db/logic/processschema.py index f048275..d7cdffb 100644 --- a/api/api/db/logic/processschema.py +++ b/api/api/db/logic/processschema.py @@ -13,6 +13,7 @@ from api.schemas.process.process_schema import ProcessSchema from api.schemas.endpoints.process_schema import all_process_schema_adapter, AllProcessSchemaResponse + async def get_process_schema_page_by_creator_id( connection: AsyncConnection, creator_id: int, page: int, limit: int ) -> Optional[AllProcessSchemaResponse]: @@ -39,9 +40,7 @@ async def get_process_schema_page_by_creator_id( ) count_query = ( - select(func.count()) - .select_from(process_schema_table) - .where(process_schema_table.c.creator_id == creator_id) + select(func.count()).select_from(process_schema_table).where(process_schema_table.c.creator_id == creator_id) ) result = await connection.execute(query) @@ -94,7 +93,6 @@ async def get_process_schema_page(connection: AsyncConnection, page, limit) -> O total_count = count_result.scalar() total_pages = math.ceil(total_count / limit) - validated_process_schema = all_process_schema_adapter.validate_python(events_data) return AllProcessSchemaResponse( @@ -106,7 +104,6 @@ async def get_process_schema_page(connection: AsyncConnection, page, limit) -> O ) - async def get_process_schema_by_title(connection: AsyncConnection, title: str) -> Optional[ProcessSchema]: """ Получает process schema по title. @@ -121,6 +118,7 @@ async def get_process_schema_by_title(connection: AsyncConnection, title: str) - return ProcessSchema.model_validate(processschema_data) + async def get_process_schema_by_id(connection: AsyncConnection, id: int) -> Optional[ProcessSchema]: """ Получает processschema по id. @@ -129,13 +127,13 @@ async def get_process_schema_by_id(connection: AsyncConnection, id: int) -> Opti processschema_db_cursor = await connection.execute(query) - processschema_data = processschema_db_cursor.mappings().one_or_none() if not processschema_data: return None return ProcessSchema.model_validate(processschema_data) + async def update_process_schema_by_id(connection: AsyncConnection, update_values, processschema): """ Вносит изменеия в нужное поле таблицы process_schema_table. @@ -146,7 +144,10 @@ async def update_process_schema_by_id(connection: AsyncConnection, update_values await connection.commit() -async def create_process_schema(connection: AsyncConnection, processschema: ProcessSchema, creator_id: int) -> Optional[ProcessSchema]: + +async def create_process_schema( + connection: AsyncConnection, processschema: ProcessSchema, creator_id: int +) -> Optional[ProcessSchema]: """ Создает нове поле в таблице process_schema_table. """ diff --git a/api/api/endpoints/__init__.py b/api/api/endpoints/__init__.py index d0ecfc0..be25e82 100644 --- a/api/api/endpoints/__init__.py +++ b/api/api/endpoints/__init__.py @@ -5,7 +5,7 @@ from api.endpoints.keyring import api_router as keyring_router from api.endpoints.listevents import api_router as listevents_router from api.endpoints.processschema import api_router as processschema_router -list_of_routes = [auth_router, profile_router, account_router, keyring_router, listevents_router,processschema_router] +list_of_routes = [auth_router, profile_router, account_router, keyring_router, listevents_router, processschema_router] __all__ = [ "list_of_routes", diff --git a/api/api/endpoints/account.py b/api/api/endpoints/account.py index daa0d93..0c46c7b 100644 --- a/api/api/endpoints/account.py +++ b/api/api/endpoints/account.py @@ -98,7 +98,6 @@ async def update_account( if user_update.password is not None: await update_password_key(connection, user.id, user_update.password) - updated_values = user_update.model_dump(by_alias=True, exclude_none=True) if not updated_values: diff --git a/api/api/endpoints/processschema.py b/api/api/endpoints/processschema.py index 5e3401c..6866bf7 100644 --- a/api/api/endpoints/processschema.py +++ b/api/api/endpoints/processschema.py @@ -17,7 +17,7 @@ from api.db.logic.processschema import ( get_process_schema_by_id, update_process_schema_by_id, get_process_schema_page_by_creator_id, - get_process_schema_page + get_process_schema_page, ) from api.schemas.process.process_schema import ProcessSchema @@ -42,6 +42,7 @@ api_router = APIRouter( tags=["process schema"], ) + @api_router.get("", dependencies=[Depends(bearer_schema)], response_model=AllProcessSchemaResponse) async def get_all_process_schema( page: int = 1, @@ -87,6 +88,7 @@ async def get_process_schema( return processschema_validation + @api_router.post("", dependencies=[Depends(bearer_schema)], response_model=ProcessSchema) async def create_processschema( processschema: ProcessSchemaUpdate, @@ -134,6 +136,7 @@ async def update_process_schema( return processschema + @api_router.delete("/{processschema_id}", dependencies=[Depends(bearer_schema)], response_model=ProcessSchema) async def delete_process_schema( processschema_id: int, diff --git a/api/api/endpoints/profile.py b/api/api/endpoints/profile.py index 407e627..419ec18 100644 --- a/api/api/endpoints/profile.py +++ b/api/api/endpoints/profile.py @@ -47,7 +47,6 @@ async def update_profile( raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Account not found") if user_update.role is None and user_update.login is None: - updated_values = user_update.model_dump(by_alias=True, exclude_none=True) if updated_values is None: diff --git a/api/api/schemas/endpoints/process_schema.py b/api/api/schemas/endpoints/process_schema.py index 3ba927c..6a06ce3 100644 --- a/api/api/schemas/endpoints/process_schema.py +++ b/api/api/schemas/endpoints/process_schema.py @@ -14,6 +14,7 @@ class ProcessSchemaUpdate(Base): settings: Optional[Dict[str, Any]] = None status: Optional[ProcessStatus] = None + class AllProcessSchema(Base): id: int title: str = Field(..., max_length=100) diff --git a/api/api/schemas/process/process_schema.py b/api/api/schemas/process/process_schema.py index 364a624..ad1f920 100644 --- a/api/api/schemas/process/process_schema.py +++ b/api/api/schemas/process/process_schema.py @@ -5,6 +5,7 @@ from datetime import datetime from api.schemas.base import Base from api.db.tables.process import ProcessStatus + class ProcessSchema(Base): id: int title: str = Field(..., max_length=100) diff --git a/api/api/schemas/process/ps_node.py b/api/api/schemas/process/ps_node.py index 3e75c6c..742c2d5 100644 --- a/api/api/schemas/process/ps_node.py +++ b/api/api/schemas/process/ps_node.py @@ -2,7 +2,8 @@ from datetime import datetime from typing import Dict, Any from api.schemas.base import Base -from api.db.tables.process import NodeType,NodeStatus +from api.db.tables.process import NodeType, NodeStatus + class Ps_Node(Base): id: int diff --git a/api/api/services/update_data_validation.py b/api/api/services/update_data_validation.py index 7b114a9..5d9df38 100644 --- a/api/api/services/update_data_validation.py +++ b/api/api/services/update_data_validation.py @@ -9,6 +9,7 @@ from api.db.tables.events import EventState, EventStatus from api.schemas.endpoints.process_schema import ProcessSchemaUpdate from api.db.tables.process import ProcessStatus + def update_user_data_changes(update_data: UserUpdate, user) -> Optional[dict]: """ Сравнивает данные для обновления с текущими значениями пользователя. @@ -110,6 +111,7 @@ def update_listevents_data_changes(update_data: ListEventUpdate, listevents) -> return changes if changes else None + def update_processschema_data_changes(update_data: ProcessSchemaUpdate, processschema) -> Optional[dict]: """ Сравнивает данные для обновления с текущими значениями processschema.