ソースを参照

批量打标逻辑修改`

Signed-off-by: BinrenZhang <zhangbr@elab-plus.com>
BinrenZhang 4 年 前
コミット
a5bb361156
1 ファイル変更21 行追加16 行削除
  1. 21 16
      test/http_test.py

+ 21 - 16
test/http_test.py

@@ -18,19 +18,24 @@ if __name__ == '__main__':
     import time
     mysql = MysqlDB('marketing_db')
     url = "https://api-uat3.elaber.cn/elab-marketing-content/materialLabel/markingForMaterial"
-    house = mysql.select('select a.id from house a LEFT JOIN brand_house_rlat b on a.id = b.house_id where a.status = 1 and b.status = 1 and b.brand_id = 1')
-    count = 0
-    for x in house:
-        print(x[0])
-        params = {
-            "deleteStatus": 2,
-            "materialId": x[0],
-            "materialType": 1,
-            "user": "batch"
-        }
-        response = requests.post(url, json=params, headers=headers_1)
-        print(response)
-        time.sleep(1)
-        count += 1
-        if count == 1:
-            break
+    sql_dict = {
+        1: 'select a.id from house a LEFT JOIN brand_house_rlat b on a.id = b.house_id where a.status = 1 and b.status = 1 and b.brand_id = 1',
+        2: 'select a.id from content_moment a LEFT JOIN brand_house_rlat b on a.house_id = b.house_id where a.status = 1 and b.status = 1 and b.brand_id = 1',
+        3: 'select a.id from t_content_album a LEFT JOIN brand_house_rlat b on a.house_id = b.house_id where a.status = 1 and b.status = 1 and b.brand_id = 1',
+        4: 'select a.id from content_layout a LEFT JOIN brand_house_rlat b on a.house_id = b.house_id where a.status = 1 and b.status = 1 and b.brand_id = 1'
+    }
+    for index in sql_dict.keys():
+        house = mysql.select(sql_dict.get(index))
+        count = 0
+        for x in house:
+            print(x[0])
+            params = {
+                "deleteStatus": 2,
+                "materialId": x[0],
+                # 物料类型,1:项目,2:视频,3:图集(图片),4:户型
+                "materialType": index,
+                "user": "batch20201230"
+            }
+            response = requests.post(url, json=params, headers=headers_1)
+            print(response.text)
+            time.sleep(0.5)