Commit da46fb50 by 岳巧源

delete status

parent 57bfeee3
Showing with 34 additions and 1 deletions
......@@ -113,6 +113,8 @@ def update_vc_attr(conf: dict):
check_sql = "select id, class_id, attr_id, attr_name, unit, enum_value, input_type, is_required from lie_shop_attr where platform = 1 and is_ext = 1 and status = 1 and class_id = %s"
cursor.execute(query=check_sql, args=(class_id, ))
check_result = cursor.fetchall()
api_attr_id_set = set()
api_attr_name_set = set()
for j in range(len(jd_results)):
result = jd_results[j]
props = result["props"]
......@@ -124,6 +126,11 @@ def update_vc_attr(conf: dict):
input_type = prop["input_type"]
platform = 1
status = 1
"""
将attr_id 和 attr_name加入集合
"""
api_attr_id_set.add(attr_id)
api_attr_name_set.add(attr_name)
if not prop["required"]:
is_required = 0
else:
......@@ -220,6 +227,20 @@ def update_vc_attr(conf: dict):
cursor.execute(query=insert_sql, args=(class_id, attr_id, attr_name, unit, enum_value, input_type, is_required, status, platform, create_time, 1))
db.commit()
print(insert_sql % (class_id, attr_id, attr_name, unit, enum_value, input_type, is_required, status, platform, create_time, 1))
"""
将api返回中没有的属性id和名称置为禁用
"""
for z in range(len(check_result)):
id = check_result[z][0]
origin_attr_id = check_result[z][2]
origin_attr_name = check_result[z][3]
if origin_attr_id not in api_attr_id_set and origin_attr_name not in api_attr_name_set:
delete_sql = "update lie_shop_attr set status = 0 where id = %s"
cursor.execute(query=delete_sql, args=(id,))
db.commit()
print(delete_sql % id)
def handle_vc_unit(conf: dict):
......@@ -293,6 +314,8 @@ def update_vc_ext_attr(conf):
check_sql = "select id, class_id, attr_id, attr_name, unit, enum_value, input_type, is_required from lie_shop_attr where platform = 1 and is_ext = 2 and status = 1 and class_id = %s"
cursor.execute(query=check_sql, args=(class_id, ))
check_result = cursor.fetchall()
api_attr_id_set = set()
api_attr_name_set = set()
for j in range(len(jd_results)):
result = jd_results[j]
flag = result["is_required"]
......@@ -306,6 +329,8 @@ def update_vc_ext_attr(conf):
update_time = int(time.time())
input_type = result["input_type"]
enum_value = "[]"
api_attr_id_set.add(attr_id)
api_attr_name_set.add(attr_name)
# 根据 input_type 不同类型分别处理
if input_type == 1 or input_type == 2:
# 单选或者多选,获取选项值
......@@ -382,7 +407,15 @@ def update_vc_ext_attr(conf):
cursor.execute(query=insert_sql, args=(class_id, attr_id, attr_name, unit, enum_value, input_type, is_required, status, platform, create_time, 2))
db.commit()
print(insert_sql % (class_id, attr_id, attr_name, unit, enum_value, input_type, is_required, status, platform, create_time, 2))
for z in range(len(check_result)):
id = check_result[z][0]
origin_attr_id = check_result[z][2]
origin_attr_name = check_result[z][3]
if origin_attr_id not in api_attr_id_set and origin_attr_name not in api_attr_name_set:
delete_sql = "update lie_shop_attr set status = 0 where id = %s"
cursor.execute(query=delete_sql, args=(id,))
db.commit()
print(delete_sql % id)
def update_vc_ext_redis(conf: dict):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment