Explorar el Código

优化后台上传大模型许可证接口

locky hace 3 meses
padre
commit
e2c9d05953
Se han modificado 1 ficheros con 10 adiciones y 5 borrados
  1. 10 5
      AdminController/DeviceManagementController.py

+ 10 - 5
AdminController/DeviceManagementController.py

@@ -1993,11 +1993,16 @@ class DeviceManagement(View):
             )
             assert resp.status < 300
 
-            BaiduBigModelLicense.objects.create(
-                license_name=license_name,
-                created_time=now_time,
-                updated_time=now_time
-            )
+            # 更新或创建数据
+            license_qs = BaiduBigModelLicense.objects.filter(license_name=license_name)
+            if license_qs.exists():
+                license_qs.update(updated_time=now_time)
+            else:
+                BaiduBigModelLicense.objects.create(
+                    license_name=license_name,
+                    created_time=now_time,
+                    updated_time=now_time
+                )
             return response.json(0)
         except Exception as e:
             return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))