kboss/b/product/home_page_product_update.dspy
2025-11-27 18:00:11 +08:00

52 lines
1.5 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'):
ns_dic['description'] = ns.get('description')
if ns.get('label'):
ns_dic['label'] = ns.get('label')
if ns.get('product_group'):
ns_dic['product_group'] = ns.get('product_group')
if ns.get('url'):
ns_dic['url'] = ns.get('url')
if ns.get('list_url'):
ns_dic['list_url'] = ns.get('list_url')
if ns.get('icon_url'):
ns_dic['icon_url'] = ns.get('icon_url')
if ns.get('source'):
ns_dic['source'] = ns.get('source')
if ns.get('sort_order'):
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