fix: door_auth bulk_create id bug

This commit is contained in:
caoqianming 2023-10-09 12:36:42 +08:00
parent af105384fe
commit 6b6175803c
1 changed files with 3 additions and 1 deletions

View File

@ -233,11 +233,13 @@ class HrmService:
# raise APIException(**DH_REQUEST_ERROR)
cls.save(ep, data={'dh_dchannels': dh_dchannels})
from apps.third.models import DoorAuth
from apps.utils.snowflake import idWorker
DoorAuth.objects.filter(employee=ep).delete()
drs = []
for i in dh_dchannels:
id = idWorker.get_id()
drs.append(
DoorAuth(employee=ep, dchannel=TDevice.objects.get(code=i)))
DoorAuth(id=id, employee=ep, dchannel=TDevice.objects.get(code=i)))
DoorAuth.objects.bulk_create(drs)
return dh_dchannels