修复修改更新应用
This commit is contained in:
@@ -12,7 +12,7 @@ from app.services.user_oauth_app_service import (
|
|||||||
update_user_oauth_app,
|
update_user_oauth_app,
|
||||||
)
|
)
|
||||||
|
|
||||||
router = APIRouter(prefix="/user-oauth-apps", tags=["oauth"])
|
router = APIRouter(prefix="/admin/user-oauth-apps", tags=["oauth"])
|
||||||
|
|
||||||
|
|
||||||
@router.get("/list", summary="获取用户授权应用列表")
|
@router.get("/list", summary="获取用户授权应用列表")
|
||||||
@@ -34,7 +34,7 @@ async def list_apps(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@router.post("/create", summary="创建用户授权应用", response_model=UserOAuthAppOut, status_code=status.HTTP_201_CREATED)
|
@router.post("/create", summary="创建用户授权应用")
|
||||||
async def create_app(
|
async def create_app(
|
||||||
req: UserOAuthAppCreate,
|
req: UserOAuthAppCreate,
|
||||||
admin: User = Depends(get_admin_user),
|
admin: User = Depends(get_admin_user),
|
||||||
@@ -42,7 +42,7 @@ async def create_app(
|
|||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
app = await create_user_oauth_app(db, req.app_id, req.secret, req.open_type, admin.id)
|
app = await create_user_oauth_app(db, req.app_id, req.secret, req.open_type, admin.id)
|
||||||
return app
|
return UserOAuthAppOut.model_validate(app)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=status.HTTP_400_BAD_REQUEST,
|
status_code=status.HTTP_400_BAD_REQUEST,
|
||||||
@@ -50,7 +50,7 @@ async def create_app(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/read/{id}", summary="获取用户授权应用详情", response_model=UserOAuthAppOut)
|
@router.get("/read/{id}", summary="获取用户授权应用详情")
|
||||||
async def get_app(
|
async def get_app(
|
||||||
id: str,
|
id: str,
|
||||||
admin: User = Depends(get_admin_user),
|
admin: User = Depends(get_admin_user),
|
||||||
@@ -62,10 +62,10 @@ async def get_app(
|
|||||||
status_code=status.HTTP_404_NOT_FOUND,
|
status_code=status.HTTP_404_NOT_FOUND,
|
||||||
detail="应用不存在",
|
detail="应用不存在",
|
||||||
)
|
)
|
||||||
return app
|
return UserOAuthAppOut.model_validate(app)
|
||||||
|
|
||||||
|
|
||||||
@router.post("/update/{id}", summary="更新用户授权应用", response_model=UserOAuthAppOut)
|
@router.post("/update/{id}", summary="更新用户授权应用")
|
||||||
async def update_app(
|
async def update_app(
|
||||||
id: str,
|
id: str,
|
||||||
req: UserOAuthAppUpdate,
|
req: UserOAuthAppUpdate,
|
||||||
@@ -78,7 +78,7 @@ async def update_app(
|
|||||||
status_code=status.HTTP_404_NOT_FOUND,
|
status_code=status.HTTP_404_NOT_FOUND,
|
||||||
detail="应用不存在",
|
detail="应用不存在",
|
||||||
)
|
)
|
||||||
return app
|
return UserOAuthAppOut.model_validate(app)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/delete/{id}", summary="删除用户授权应用")
|
@router.get("/delete/{id}", summary="删除用户授权应用")
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ async def create_user_oauth_app(
|
|||||||
)
|
)
|
||||||
db.add(app)
|
db.add(app)
|
||||||
await db.flush()
|
await db.flush()
|
||||||
|
await db.commit()
|
||||||
|
await db.refresh(app)
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
@@ -101,6 +103,8 @@ async def update_user_oauth_app(
|
|||||||
app.create_by = create_by
|
app.create_by = create_by
|
||||||
|
|
||||||
await db.flush()
|
await db.flush()
|
||||||
|
await db.commit()
|
||||||
|
await db.refresh(app)
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user