kboss/b/lease/update_store.dspy
2025-07-16 14:27:17 +08:00

46 lines
1.2 KiB
Plaintext

def check_args(ns={}):
if not ns:
return {"status": False, "msg": "api args is None"}
check_key = [
"id",
"name",
"bandwidth_price",
"stored_price",
"ip_price",
"user_id",
]
for k in check_key:
if not ns.get(k, None):
return f"the key is null, please check key:{k}"
else:
if len(ns[k]) == 0:
return f"the len is 0, please check key:{k}"
return ""
async def update_store(ns={}):
"""
更改仓库
:param ns:
:return:
"""
error = check_args(ns)
if error:
return {"status": False, "msg": error}
db = DBPools()
async with db.sqlorContext('kboss') as sor:
tablename = "lease_store_data"
ns["update_at"] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
try:
await sor.U(tablename, ns)
return {"status": True, "msg": "save ok"}
except Exception as e:
if " for key " in str(e):
return {"status": False, "msg": f"更新失败,仓库名重复"}
return {"status": False, "msg": f"更新失败,{e}"}
ret = await update_store(params_kw)
return ret