1
This commit is contained in:
@@ -1593,6 +1593,34 @@ async def list_system_configs(
|
||||
return result.scalars().all()
|
||||
|
||||
|
||||
@router.post("/system-configs", response_model=SystemConfigOut)
|
||||
async def create_system_config(
|
||||
req: SystemConfigCreate,
|
||||
admin: User = Depends(get_admin_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
from app.utils.id_gen import generate_id
|
||||
config = SystemConfig(
|
||||
id=generate_id(),
|
||||
key=req.key,
|
||||
value=str(req.value),
|
||||
description=req.description or "",
|
||||
)
|
||||
db.add(config)
|
||||
await db.flush()
|
||||
await log_operation(
|
||||
db,
|
||||
admin.id,
|
||||
admin.username,
|
||||
f"创建系统配置: {config.key}",
|
||||
"POST",
|
||||
"/admin/system-configs",
|
||||
detail=json.dumps({"key": req.key, "value": req.value}, ensure_ascii=False),
|
||||
)
|
||||
await db.commit()
|
||||
return config
|
||||
|
||||
|
||||
@router.put("/system-configs/{config_id}", response_model=SystemConfigOut)
|
||||
async def update_system_config(
|
||||
config_id: str,
|
||||
|
||||
Reference in New Issue
Block a user