Эх сурвалжийг харах

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

locky 3 сар өмнө
parent
commit
e2c9d05953

+ 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)))