Browse Source

Done: add board && add class

nandHyf 1 year ago
parent
commit
e71418ca64
2 changed files with 41 additions and 12 deletions
  1. 36 11
      Stateful.py
  2. 5 1
      dev_config.toml

+ 36 - 11
Stateful.py

@@ -156,6 +156,7 @@ class OC():
 
 
     def add(self, addType:str="board", addName:str="", after_to:str=""):
+        # Logic see also: /else/addBoardLogic.png
         if addType == "board":
             ie = IsExist("Board", addName)
 
@@ -164,25 +165,49 @@ class OC():
 
             elif ie == False:
                 sqls = "INSERT INTO Board VALUES(null, '{name}', 'alive');".format(name=self.name)
-    
+
+
+        # Logic see also: /else/addClassLogic.png
         elif addType == "class":
-            # 1. 检查cl存在
             ie = IsExist("Class", addName)
 
-            # 2. 有没有指定目标(after_to)
-            if ie == False:
+            if ie == True:
+
+                if after_to != "none":
+                    sqls = "SELECT usingBoard FROM Class WHERE name='{name}';".format(name=addName)
+                    # 'ub' == 'usingBoard'
+                    ub = Exec_one(self.dp, ub)
+                    ub = ub + after_to
+                    sqls = "UPDATE Class SET usingBoard='{usingBoard}' WHERE name='{name}';".format(usingBoard=ub, name=addName)
+                
+                elif after_to == "none":
+
+                    if len(self.cp) < 2:
+                        print("err <Code>: syntax error")
+
+                    elif len(self.cp) >= 2:
+                        sqls = "SELECT usingBoard FROM Class WHERE name='{name}';".format(name=addName)
+                        # 'ub' == 'usingBoard'
+                        ub = Exec_one(self.dp, ub)
+                        ub = ub + self.cp[1]
+                        sqls = "UPDATE Class SET usingBoard='{usingBoard}' WHERE name='{name}';".format(usingBoard=ub, name=addName)
 
-                if after_to == "" and len(self.cp) == 1:
-                    print("err <Code>: syntax error")
+            elif ie == False:
 
-                elif 
-                            
+                if after_to != "none":
+                   sqls = "INSERT INTO Class VALUES(null, '{name}', '{usingBoard}', 'alive');".format(name=addName, usingBoard=after_to)
                 
+                elif after_to == "none":
 
-            elif ie == True:
-                pass
-            # 3. 没有指定目标的 情况下, 当前路径(dp)有没有可以输入的; 没有就err
+                    if len(self.cp) < 2:
+                        print("err <Code>: syntax error")
+
+                    elif len(self.cp) >= 2:
+                        ub = self.cp[1]
+                        sqls = "INSERT INTO Class VALUES(null, '{name}', '{usingBoard}', 'alive');".format(name=addName, usingBoard=ub)
+                
 
+        # Logic see also: /else/addEventLogic.png
         elif addType == "event":
             pass
  

+ 5 - 1
dev_config.toml

@@ -47,4 +47,8 @@ DisplayTimeZone = "utc+8"
 # status: alive/deleted/unclassified(event only)
 #                                           ↓ Don't foget to write the method(s) for it
 # ListStyle: tree/md_table/LLM_md_table/<customName>
-# [todo 4] StrickMode: 1. Have to be full length commands; 2. err when not exist
+# [todo 4] StrickMode: 1. Have to be full length commands; 2. err when not exist
+
+
+# Explanation of abbreviations
+#