28 lines
1.2 KiB
Plaintext
28 lines
1.2 KiB
Plaintext
async def update_cpcwidget(params_kw={}):
|
|
ns = params_kw.copy()
|
|
id = ns.get('id')
|
|
cpcid = ns.get('cpcid')
|
|
unit_price = ns.get('unit_price')
|
|
type = ns.get('type')
|
|
model = ns.get('model')
|
|
debug(f"当前更新的部件:{type} {model},算力中心ID:{cpcid},部件新单价:{unit_price}")
|
|
if (not cpcid) or (not unit_price) or (not type) or (not model):
|
|
return {'status': False,'msg': '缺少算力中心ID/单价/部件类型/型号'}
|
|
|
|
db = DBPools()
|
|
dbname = 'kboss'
|
|
update_json = {"cpcid":cpcid,"unit_price": unit_price,"type":type, "model":model}
|
|
async with db.sqlorContext(dbname) as sor:
|
|
#r = await sor.U('cpcwidget', update_json)
|
|
try:
|
|
y_sql = f'''update cpcwidget set unit_price="{unit_price}" where cpcid="{cpcid}" and type="{type}" and model="{model}"'''
|
|
debug(f'sql:{y_sql}')
|
|
resulta = await sor.sqlExe(y_sql, {})
|
|
debug('更新算力中心部件单位价格成功')
|
|
return {'status': True,'msg': '更新算力单位部件单价成功','data': update_json}
|
|
except:
|
|
raise
|
|
return {'status': False,'msg': '更新算力部件单位单价失败'}
|
|
|
|
ret = await update_cpcwidget(params_kw)
|
|
return ret |