This commit is contained in:
shijing 2023-06-02 13:29:05 +08:00
commit fb8bd5e2bb
1 changed files with 9 additions and 2 deletions

View File

@ -522,9 +522,16 @@ class Task2DoViewSet(ListModelMixin, GenericViewSet):
没有记录
"""
obj = self.get_object()
theattr = getattr(obj, request.data.get('key'), None)
field = request.data.get('key')
theattr = getattr(obj, field, None)
if theattr == 0:
return Response()
if theattr is None:
theattr = 0
setattr(obj, field, 0)
if field == 'num_complaint':
obj.num_complaint_10 = 0
elif field == 'num_pt':
obj.num_pt_10 = 0
else:
raise ParseError('已有记录')
obj.save()