Add GET/POST /competitors/config/system endpoints for Settings page
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8948d3abf6
commit
d94b8feee6
1 changed files with 34 additions and 0 deletions
|
|
@ -144,6 +144,40 @@ async def get_scraper_status(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/config/system")
|
||||||
|
async def get_system_config(
|
||||||
|
db: AsyncSession = Depends(get_db),
|
||||||
|
current_user: dict = Depends(get_current_user)
|
||||||
|
):
|
||||||
|
"""Return all system_config rows as a flat dict."""
|
||||||
|
result = await db.execute(text("SELECT config_key, config_value FROM system_config"))
|
||||||
|
return {row.config_key: row.config_value for row in result.fetchall()}
|
||||||
|
|
||||||
|
|
||||||
|
class SystemConfigUpdate(BaseModel):
|
||||||
|
key: str
|
||||||
|
value: str
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("/config/system")
|
||||||
|
async def set_system_config(
|
||||||
|
payload: SystemConfigUpdate,
|
||||||
|
db: AsyncSession = Depends(get_db),
|
||||||
|
current_user: dict = Depends(get_current_user)
|
||||||
|
):
|
||||||
|
"""Upsert a single system_config key."""
|
||||||
|
await db.execute(
|
||||||
|
text("""
|
||||||
|
INSERT INTO system_config (config_key, config_value)
|
||||||
|
VALUES (:key, :value)
|
||||||
|
ON CONFLICT (config_key) DO UPDATE SET config_value = EXCLUDED.config_value
|
||||||
|
"""),
|
||||||
|
{'key': payload.key, 'value': payload.value}
|
||||||
|
)
|
||||||
|
await db.commit()
|
||||||
|
return {"status": "success", "key": payload.key}
|
||||||
|
|
||||||
|
|
||||||
@router.post("/config/location")
|
@router.post("/config/location")
|
||||||
async def set_location_config(
|
async def set_location_config(
|
||||||
config: LocationConfigRequest,
|
config: LocationConfigRequest,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue