feat: 优化add_mtaskb
This commit is contained in:
parent
09b3f17025
commit
e12a1042b9
|
@ -215,12 +215,15 @@ class MtaskViewSet(CustomModelViewSet):
|
||||||
sr.is_valid(raise_exception=True)
|
sr.is_valid(raise_exception=True)
|
||||||
vdata = sr.validated_data
|
vdata = sr.validated_data
|
||||||
total = 0
|
total = 0
|
||||||
|
userIds = []
|
||||||
for v in vdata:
|
for v in vdata:
|
||||||
total += v['count']
|
total += v['count']
|
||||||
|
userIds.append(v['handle_user'].id)
|
||||||
if total != mtask.count:
|
if total != mtask.count:
|
||||||
raise ParseError('任务数量与分配数量不匹配')
|
raise ParseError('任务数量与分配数量不匹配')
|
||||||
for v in vdata:
|
for v in vdata:
|
||||||
Mtaskb.objects.get_or_create(mtask=mtask, handle_user=vdata['handle_user'], count=vdata['count'])
|
Mtaskb.objects.get_or_create(mtask=mtask, handle_user=vdata['handle_user'], count=vdata['count'])
|
||||||
|
Mtaskb.objects.filter(mtask=mtask).exclude(handle_user__in=userIds).delete()
|
||||||
return Response()
|
return Response()
|
||||||
|
|
||||||
class MtaskbViewSet(CustomModelViewSet):
|
class MtaskbViewSet(CustomModelViewSet):
|
||||||
|
|
Loading…
Reference in New Issue