瀏覽代碼

路径存在则更新 不存在则新增

peng 2 年之前
父節點
當前提交
7965c865d6
共有 1 個文件被更改,包括 10 次插入7 次删除
  1. 10 7
      controller/LangAVSSController.py

+ 10 - 7
controller/LangAVSSController.py

@@ -206,13 +206,16 @@ class LangAVSSView(TemplateView):
                 for location in locations:
                     # print(location['filename'])
                     # print(location['line'])
-
-                    locationValue = {
-                        'lk': lkModel,
-                        'filename': location['filename'],
-                        'line': location['line']
-                    }
-                    LangLocationModel.objects.create(**locationValue)
+                    langlocation = LangLocationModel.objects.filter(lk=lkModel.id, filename=location['filename'])
+                    if langlocation.exists():
+                        langlocation.update(line=location['line'])
+                    else:
+                        locationValue = {
+                            'lk': lkModel,
+                            'filename': location['filename'],
+                            'line': location['line']
+                        }
+                        LangLocationModel.objects.create(**locationValue)
             return response.json(0)
         else:
             return response.json(444)