修复修改更新应用

This commit is contained in:
18610128193
2026-06-10 14:44:09 +08:00
parent de494060ad
commit 3ba97e1f3f
2 changed files with 11 additions and 7 deletions
+7 -7
View File
@@ -12,7 +12,7 @@ from app.services.user_oauth_app_service import (
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="获取用户授权应用列表")
@@ -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(
req: UserOAuthAppCreate,
admin: User = Depends(get_admin_user),
@@ -42,7 +42,7 @@ async def create_app(
):
try:
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:
raise HTTPException(
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(
id: str,
admin: User = Depends(get_admin_user),
@@ -62,10 +62,10 @@ async def get_app(
status_code=status.HTTP_404_NOT_FOUND,
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(
id: str,
req: UserOAuthAppUpdate,
@@ -78,7 +78,7 @@ async def update_app(
status_code=status.HTTP_404_NOT_FOUND,
detail="应用不存在",
)
return app
return UserOAuthAppOut.model_validate(app)
@router.get("/delete/{id}", summary="删除用户授权应用")
@@ -76,6 +76,8 @@ async def create_user_oauth_app(
)
db.add(app)
await db.flush()
await db.commit()
await db.refresh(app)
return app
@@ -101,6 +103,8 @@ async def update_user_oauth_app(
app.create_by = create_by
await db.flush()
await db.commit()
await db.refresh(app)
return app