From 22a8bf99cafab28691610340cb80c000eb9adadc Mon Sep 17 00:00:00 2001 From: Mouriya Date: Mon, 19 Aug 2024 21:21:13 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=BF=E3=83=BC=E3=83=95?= =?UTF-8?q?=E3=82=A7=E3=83=BC=E3=82=B9=E3=81=AB=E3=82=AA=E3=83=97=E3=82=B7?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E3=81=AEuserId=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=81=97=E3=81=BE=E3=81=99=E3=80=82=E6=B8=A1=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=9F=E5=A0=B4=E5=90=88=E3=81=AF=E3=81=9D=E3=81=AEuserId?= =?UTF-8?q?=E3=82=92=E4=BD=BF=E7=94=A8=E3=81=97=E3=80=81=E6=B8=A1=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=AA=E3=81=84=E5=A0=B4=E5=90=88=E3=81=AF=E3=83=88?= =?UTF-8?q?=E3=83=BC=E3=82=AF=E3=83=B3=E5=86=85=E3=81=AEID=E3=82=92?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E3=81=97=E3=81=BE=E3=81=99=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/api_v1/routers/platform.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/backend/app/api/api_v1/routers/platform.py b/backend/app/api/api_v1/routers/platform.py index 2ab6b46..53937a6 100644 --- a/backend/app/api/api_v1/routers/platform.py +++ b/backend/app/api/api_v1/routers/platform.py @@ -1,9 +1,9 @@ -from fastapi import Request,Depends, APIRouter, UploadFile,HTTPException,File +from fastapi import Query, Request,Depends, APIRouter, UploadFile,HTTPException,File from app.db import Base,engine from app.db.session import get_db from app.db.crud import * from app.db.schemas import * -from typing import List +from typing import List, Optional from app.core.auth import get_current_active_user,get_current_user from app.core.apiexception import APIException @@ -233,16 +233,17 @@ async def domain_delete( @r.get( "/domain", - response_model=List[Domain], + # response_model=List[Domain], response_model_exclude_none=True, ) async def userdomain_details( request: Request, + userId: Optional[int] = Query(None, alias="userId"), user=Depends(get_current_user), db=Depends(get_db), ): try: - domains = get_domain(db, user.id) + domains = get_domain(db, userId if userId is not None else user.id) return domains except Exception as e: raise APIException('platform:domain',request.url._url,f"Error occurred while get user({user.id}) domain:",e) @@ -285,11 +286,14 @@ async def userdomain_delete( ) async def get_useractivedomain( request: Request, + userId: Optional[int] = Query(None, alias="userId"), user=Depends(get_current_user), db=Depends(get_db), ): try: - domain = get_activedomain(db, user.id) + # domain = get_activedomain(db, user.id) + + domain = get_activedomain(db, userId if userId is not None else user.id) return domain except Exception as e: raise APIException('platform:activedomain',request.url._url,f"Error occurred while get user({user.id}) activedomain:",e) @@ -301,11 +305,12 @@ async def get_useractivedomain( async def update_activeuserdomain( request: Request, domainid:int, + userId: Optional[int] = Query(None, alias="userId"), user=Depends(get_current_user), db=Depends(get_db), ): try: - domain = active_userdomain(db, user.id,domainid) + domain = active_userdomain(db, userId if userId is not None else user.id,domainid) return domain except Exception as e: raise APIException('platform:activedomain',request.url._url,f"Error occurred while update user({user.id}) activedomain:",e)