From 69e75cc1d784320ab0e01fa03633d05916c4c184 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 10 May 2024 16:38:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20mpointstat=E6=89=8B=E5=8A=A8=E5=BD=95?= =?UTF-8?q?=E5=85=A5=E5=9C=A8create=E6=97=B6=E6=A0=A1=E9=AA=8C=E5=94=AF?= =?UTF-8?q?=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/enm/serializers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/enm/serializers.py b/apps/enm/serializers.py index 9c999ec2..c829ab7d 100644 --- a/apps/enm/serializers.py +++ b/apps/enm/serializers.py @@ -74,6 +74,11 @@ class MpointStatSerializer(CustomModelSerializer): if key not in dictionary or not dictionary[key]: return False return True + + def create(self, validated_data): + if MpointStat.objects.filter(mpoint=validated_data["mpoint"], sflog=validated_data["sflog"]).exists(): + raise ParseError("该数据已录入") + return super().create(validated_data) def validate(self, attrs): mpoint = attrs["mpoint"]