18 lines
491 B
Python
18 lines
491 B
Python
from sqlalchemy.orm import Session
|
|
|
|
from app.models.system import AppConfig
|
|
|
|
|
|
def get_config(db: Session, key: str, default: str = "") -> str:
|
|
row = db.query(AppConfig).filter(AppConfig.key == key).first()
|
|
return row.value if row else default
|
|
|
|
|
|
def set_config(db: Session, key: str, value: str) -> None:
|
|
row = db.query(AppConfig).filter(AppConfig.key == key).first()
|
|
if row:
|
|
row.value = value
|
|
else:
|
|
db.add(AppConfig(key=key, value=value))
|
|
db.commit()
|