Browse Source

题目条件设置。

CrazyIter_Bin 3 năm trước cách đây
mục cha
commit
937b1ac5ad
1 tập tin đã thay đổi với 38 bổ sung2 xóa
  1. 38 2
      TEAMModelOS.SDK/Models/Service/ItemService.cs

+ 38 - 2
TEAMModelOS.SDK/Models/Service/ItemService.cs

@@ -18,7 +18,8 @@ namespace TEAMModelOS.Services.Common
         /// <param name="cond"></param>
         public static void CountItemCond(ItemInfo newItem, ItemInfo odlItem, ItemCond cond)
         {
-       
+            if (newItem != null ? newItem.scope.Equals("school") : false || odlItem != null ? odlItem.scope.Equals("school") : false)
+            {
                 //检查两个对象是否是同一条记录
                 if (newItem != null && odlItem == null)
                 {
@@ -51,8 +52,43 @@ namespace TEAMModelOS.Services.Common
                 {
                     // throw new Exception();
                 }
-            
+            } else if (newItem != null ? newItem.scope.Equals("private") : false || odlItem != null ? odlItem.scope.Equals("private") : false) {
+                //检查两个对象是否是同一条记录
+                if (newItem != null && odlItem == null)
+                {
+                    string newKey = $"{newItem.creator}";
+                    List<string> grade = new List<string> { newKey };
+                    UpdateItemCond(cond, true, newKey, grade, newItem.type, newItem.level, newItem.field.HasValue ? newItem.field.Value : 0, newItem);
+                }
+                else if (newItem != null && odlItem != null)
+                {
+                    //更新时 需要保证两个题的 id code 一致
+                    if (newItem.id == odlItem.id && newItem.code == odlItem.code)
+                    {
+                        //先增加
+                        string newKey = $"{newItem.creator}";
+                        List<string> newGrade = new List<string> { newKey };
+                        UpdateItemCond(cond, true, newKey, newGrade, newItem.type, newItem.level, newItem.field.HasValue ? newItem.field.Value : 0, newItem);
+                        //后变更删除
+                        string oldKey = $"{odlItem.creator}";
+                        List<string> oldGrade = new List<string> { oldKey };
+                        UpdateItemCond(cond, false, oldKey, oldGrade, odlItem.type, odlItem.level, odlItem.field.HasValue ? odlItem.field.Value : 0, newItem);
+                    }
+                }
+                else if (newItem == null && odlItem != null)
+                {
+                    string oldKey = $"{odlItem.creator}";
+                    List<string> oldGrade = new List<string> { oldKey };
+                    UpdateItemCond(cond, false, oldKey, oldGrade, odlItem.type, odlItem.level, odlItem.field.HasValue ? odlItem.field.Value : 0, null);
+                }
+                else
+                {
+                    // throw new Exception();
+                }
+            }
         }
+
+        
         /// <summary>
         /// opt=false  减  true 增
         /// key  科目id