kboss/b/product/home_page_product_update.dspy
2025-11-26 15:43:40 +08:00

52 lines
1.6 KiB
Plaintext

async def home_page_product_update(ns={}):
"""
更新产品信息
:param ns:
:return:
"""
if not ns.get('id'):
return {
'status': False,
'msg': 'product id is required'
}
# 构建更新字段,只更新传入的字段
ns_dic = {'id': ns.get('id')}
if ns.get('name'):
ns_dic['name'] = ns.get('name')
if ns.get('description') is not None:
ns_dic['description'] = ns.get('description')
if ns.get('label') is not None:
ns_dic['label'] = ns.get('label')
if ns.get('product_group') is not None:
ns_dic['product_group'] = ns.get('product_group')
if ns.get('url') is not None:
ns_dic['url'] = ns.get('url')
if ns.get('list_url') is not None:
ns_dic['list_url'] = ns.get('list_url')
if ns.get('icon_url') is not None:
ns_dic['icon_url'] = ns.get('icon_url')
if ns.get('source') is not None:
ns_dic['source'] = ns.get('source')
if ns.get('sort_order') is not None:
ns_dic['sort_order'] = ns.get('sort_order')
if ns.get('menu_id'):
ns_dic['menu_id'] = ns.get('menu_id')
db = DBPools()
async with db.sqlorContext('kboss') as sor:
try:
await sor.U('home_page_product_info', ns_dic)
return {
'status': True,
'msg': 'update product success'
}
except Exception as e:
await sor.rollback()
return {
'status': False,
'msg': 'update product failed, %s' % str(e)
}
ret = await home_page_product_update(params_kw)
return ret