19 lines
579 B
Python
19 lines
579 B
Python
from sqlalchemy.orm import Session
|
|
from app.models.auth.access_model import Access
|
|
from typing import List
|
|
|
|
class AccessService:
|
|
|
|
@staticmethod
|
|
def get_all_accesses(db: Session, category: str = None) -> List[Access]:
|
|
query = db.query(Access)
|
|
|
|
if category:
|
|
query = query.filter(Access.category == category)
|
|
|
|
return query.all()
|
|
|
|
@staticmethod
|
|
def get_access_categories(db: Session) -> List[str]:
|
|
categories = db.query(Access.category).distinct().all()
|
|
return [cat[0] for cat in categories] |