fix(config): 补充 peace_enabled 字段声明并增加安全属性读取

- 在 DouyuConfigOut 与 DouyuConfigUpdate 中加入 peace_enabled 声明与序列化
- 在 update_config 中使用 getattr(req, field, None) 做安全兜底,避免 500
This commit is contained in:
yml2213
2026-10-07 16:19:23 +08:00
parent 049174a795
commit 7c1a6caf47
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -624,7 +624,7 @@ def update_config(
config = ensure_douyu_config(db)
changed_fields = []
for field in DOUYU_CONFIG_FIELDS:
value = getattr(req, field)
value = getattr(req, field, None)
if value is None:
continue
setattr(config, field, value.strip() if isinstance(value, str) else value)
+3
View File
@@ -769,6 +769,7 @@ class DouyuConfigOut(BaseModel):
esports_chicken_skin_id: str = "0"
esports_firework_gift_id: str = "24767"
esports_firework_skin_id: str = "3850"
peace_enabled: bool = False
xpd_act_alias: str = "20260623KDQFH"
xpd_act_id: str = "46195"
xpd_rid: str = "9263298"
@@ -797,6 +798,7 @@ class DouyuConfigOut(BaseModel):
"esports_chicken_skin_id": self.esports_chicken_skin_id,
"esports_firework_gift_id": self.esports_firework_gift_id,
"esports_firework_skin_id": self.esports_firework_skin_id,
"peace_enabled": self.peace_enabled,
"xpd_act_alias": self.xpd_act_alias,
"xpd_act_id": self.xpd_act_id,
"xpd_rid": self.xpd_rid,
@@ -825,6 +827,7 @@ class DouyuConfigUpdate(BaseModel):
esports_chicken_skin_id: str | None = None
esports_firework_gift_id: str | None = None
esports_firework_skin_id: str | None = None
peace_enabled: bool | None = None
xpd_act_alias: str | None = None
xpd_act_id: str | None = None
xpd_rid: str | None = None