fix: 修复考核官添加板块校验与板块改名接口

板块 ID 统一按整数校验,避免字符串与数据库整型比较导致误报不存在;板块接口补充 scope 与 bankuai_id 校验。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-16 15:33:54 +08:00
parent dac6193d5b
commit 118260a710
2 changed files with 16 additions and 8 deletions

View File

@@ -17,16 +17,20 @@ logger = logging.getLogger(__name__)
def _normalize_bankuai_ids(data):
"""将板块 ID 统一为整数bankuai_id 为 AutoField"""
ids = data.get('bankuai_ids')
if ids is None and data.get('bankuai_id'):
if ids is None and data.get('bankuai_id') is not None:
ids = [data.get('bankuai_id')]
if not isinstance(ids, list):
return []
out = []
for item in ids:
s = str(item or '').strip()
if s and s not in out:
out.append(s)
try:
bid = int(str(item).strip())
except (TypeError, ValueError):
continue
if bid > 0 and bid not in out:
out.append(bid)
return out