Files
test/app/dao/account_dao.py
T
2026-09-21 19:03:31 +08:00

21 lines
562 B
Python

"""账号 DAO。"""
from __future__ import annotations
from sqlalchemy import select
from sqlalchemy.orm import Session
from app.dao.base_dao import BaseDao
from app.model import Account
class AccountDao(BaseDao[Account]):
model = Account
@classmethod
def get_by_username(cls, db: Session, username: str, with_deleted: bool = False) -> Account | None:
stmt = select(Account).where(Account.username == username)
if not with_deleted:
stmt = stmt.where(Account.alive())
return db.scalars(stmt).unique().first()