查询接口修改

This commit is contained in:
lhx
2025-09-27 09:35:54 +08:00
parent 0b1e9851dd
commit 2cdf5c97e1
2 changed files with 33 additions and 6 deletions

View File

@@ -28,16 +28,23 @@ def get_accounts(request: AccountListRequest, db: Session = Depends(get_db)):
"""获取账号列表"""
return AccountService.get_accounts(db, skip=request.skip, limit=request.limit)
@router.post("/get", response_model=AccountResponse)
@router.post("/get", response_model=List[AccountResponse])
def get_account(request: AccountGetRequest, db: Session = Depends(get_db)):
"""根据ID获取账号"""
account = AccountService.get_account(db, request.account_id)
if not account:
"""根据多种条件查询账号"""
accounts = AccountService.search_accounts(
db,
account_id=request.account_id,
account=request.account,
section=request.section,
status=request.status,
today_updated=request.today_updated
)
if not accounts:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail="账号不存在"
detail="未找到符合条件的账号"
)
return account
return accounts
@router.post("/update", response_model=AccountResponse)
def update_account(request: AccountUpdateRequest, db: Session = Depends(get_db)):