fix: 修复考核官添加板块校验与板块改名接口
板块 ID 统一按整数校验,避免字符串与数据库整型比较导致误报不存在;板块接口补充 scope 与 bankuai_id 校验。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -139,7 +139,7 @@ class HqbkxxView(APIView):
|
||||
return Response({'code': 403, 'msg': '无板块管理权限'}, status=403)
|
||||
scope_err = block_non_group_catalog_scope(request)
|
||||
if scope_err:
|
||||
return Response({'code': 400, 'msg': scope_err})
|
||||
return Response({'code': 400, 'msg': scope_err}, status=400)
|
||||
|
||||
# 5. 查询所有板块
|
||||
bankuai_list = []
|
||||
@@ -241,7 +241,7 @@ class BkxgView(APIView):
|
||||
return Response({'code': 403, 'msg': '无板块管理权限'}, status=403)
|
||||
scope_err = block_non_group_catalog_scope(request)
|
||||
if scope_err:
|
||||
return Response({'code': 400, 'msg': scope_err})
|
||||
return Response({'code': 400, 'msg': scope_err}, status=400)
|
||||
|
||||
# 5. 获取操作类型
|
||||
action = request.data.get('action')
|
||||
@@ -279,9 +279,13 @@ class BkxgView(APIView):
|
||||
})
|
||||
|
||||
# ==================== 以下操作需要 bankuai_id ====================
|
||||
bankuai_id = request.data.get('bankuai_id')
|
||||
if not bankuai_id:
|
||||
raw_bankuai_id = request.data.get('bankuai_id')
|
||||
if raw_bankuai_id is None or str(raw_bankuai_id).strip() == '':
|
||||
return Response({'code': 1, 'msg': '缺少 bankuai_id'}, status=400)
|
||||
try:
|
||||
bankuai_id = int(raw_bankuai_id)
|
||||
except (TypeError, ValueError):
|
||||
return Response({'code': 1, 'msg': '无效的 bankuai_id'}, status=400)
|
||||
|
||||
try:
|
||||
bk = Bankuai.query.get(bankuai_id=bankuai_id)
|
||||
|
||||
Reference in New Issue
Block a user