initial commit
This commit is contained in:
17
app/services/config_store.py
Normal file
17
app/services/config_store.py
Normal file
@@ -0,0 +1,17 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user