haha
This commit is contained in:
@@ -68,9 +68,12 @@ def task_list(request):
|
||||
raise ValidationError(ser.errors)
|
||||
|
||||
validated = ser.validated_data.copy()
|
||||
account_id = validated.pop("id", None) or validated.pop("account_id", None)
|
||||
boss_id = (validated.pop("boss_id", "") or "").strip()
|
||||
# form-data 可能把数字传成字符串
|
||||
# boss_id 即 /api/accounts 返回的 id(账号主键),与 id/account_id 等价,均按主键查表
|
||||
account_id = (
|
||||
validated.pop("id", None)
|
||||
or validated.pop("account_id", None)
|
||||
or validated.pop("boss_id", None)
|
||||
)
|
||||
if account_id is not None:
|
||||
try:
|
||||
account_id = int(account_id)
|
||||
@@ -80,7 +83,7 @@ def task_list(request):
|
||||
target_worker_id = req.worker_id or ""
|
||||
account_name = req.account_name or ""
|
||||
|
||||
# 指定 id 时,直接从数据库解析 worker_id 和 account_name
|
||||
# 指定 id / account_id / boss_id(均为账号主键)时,按主键查表
|
||||
if account_id:
|
||||
try:
|
||||
account = BossAccount.objects.get(pk=account_id)
|
||||
@@ -93,18 +96,6 @@ def task_list(request):
|
||||
account_name = account.browser_name
|
||||
req.worker_id = target_worker_id
|
||||
req.account_name = account_name
|
||||
# 指定 boss_id 时,按 BOSS 直聘用户 ID 查账号
|
||||
elif boss_id:
|
||||
account = BossAccount.objects.filter(boss_id=boss_id).first()
|
||||
if not account:
|
||||
return api_error(
|
||||
http_status.HTTP_404_NOT_FOUND,
|
||||
f"未找到 boss_id={boss_id} 的账号",
|
||||
)
|
||||
target_worker_id = account.worker_id
|
||||
account_name = account.browser_name
|
||||
req.worker_id = target_worker_id
|
||||
req.account_name = account_name
|
||||
|
||||
if not target_worker_id and account_name:
|
||||
target_worker_id = worker_manager.find_worker_by_account(account_name)
|
||||
|
||||
Reference in New Issue
Block a user