From bd226e0487f524a35809c88be786ad3d55427f17 Mon Sep 17 00:00:00 2001 From: nick2wang Date: Wed, 28 Sep 2022 16:13:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=B7=A5=E5=8D=95=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=8E=A5=E5=8F=A3=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql_api/serializers.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sql_api/serializers.py b/sql_api/serializers.py index 657b7362c5..265d8c156d 100644 --- a/sql_api/serializers.py +++ b/sql_api/serializers.py @@ -500,6 +500,19 @@ class WorkflowLogSerializer(serializers.Serializer): choices=[1, 2, 3], label="工单类型:1-查询权限申请,2-SQL上线申请,3-数据归档申请" ) + def validate(self, attrs): + workflow_id = attrs.get("workflow_id") + workflow_type = attrs.get("workflow_type") + + try: + WorkflowAudit.objects.get( + workflow_id=workflow_id, workflow_type=workflow_type + ) + except WorkflowAudit.DoesNotExist: + raise serializers.ValidationError({"errors": "不存在该工单"}) + + return attrs + class WorkflowLogListSerializer(serializers.ModelSerializer): class Meta: