17 lines
450 B
Python
17 lines
450 B
Python
from sqlalchemy import select
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.models.entities import PricingRule
|
|
|
|
|
|
class PricingRepository:
|
|
def __init__(self, db: Session) -> None:
|
|
self.db = db
|
|
|
|
def list_rules(self):
|
|
return self.db.query(PricingRule).order_by(PricingRule.id.desc())
|
|
|
|
def get_rule(self, rule_id: int) -> PricingRule | None:
|
|
return self.db.scalar(select(PricingRule).where(PricingRule.id == rule_id))
|
|
|