feat: 修改 hrm & rpm 代码

This commit is contained in:
TianyangZhang 2026-04-07 13:42:30 +08:00
parent a82405e451
commit 159b644126
2 changed files with 3 additions and 3 deletions

View File

@ -39,7 +39,7 @@ class HrmService:
Returns:
_type_: _description_
"""
if not settings.DAHUA_ENABLED: # 如果大华没启用, 直接返回
if not getattr(settings, 'DAHUA_ENABLED', False): # 如果大华没启用, 直接返回
return
dh_id = ep.third_info.get('dh_id', None)
dh_photo = ep.third_info.get('dh_photo', None)

View File

@ -148,7 +148,7 @@ class RemployeeCreateSerializer(CustomModelSerializer):
if Remployee.objects.filter(id_number=validated_data['id_number'], rparty=validated_data['rparty']).exists():
raise ValidationError('该成员已存在')
with transaction.atomic():
if settings.DAHUA_ENABLED:
if getattr(settings, 'DAHUA_ENABLED', False):
dhClient.request(**dhapis['person_img_upload'], file_path_rela=validated_data['photo'])
return super().create(validated_data)
@ -161,7 +161,7 @@ class RemployeeUpdateSerializer(CustomModelSerializer):
def update(self, instance, validated_data):
with transaction.atomic():
if settings.DAHUA_ENABLED:
if getattr(settings, 'DAHUA_ENABLED', False):
dhClient.request(**dhapis['person_img_upload'], file_path_rela=validated_data['photo'])
return super().update(instance, validated_data)