39 lines
1.2 KiB
Plaintext
39 lines
1.2 KiB
Plaintext
async def home_page_content_update(ns={}):
|
|
"""
|
|
更新内容项
|
|
:param ns: 包含id和需要更新的字段的字典
|
|
:return: 更新结果
|
|
"""
|
|
if not ns.get('id'):
|
|
return {
|
|
'status': False,
|
|
'msg': 'id is required'
|
|
}
|
|
|
|
# 构建更新字段,排除空值
|
|
ns_dic = {'id': ns.get('id')}
|
|
update_fields = ['title', 'description', 'img', 'name', 'price',
|
|
'pre_price', 'price_unit', 'discount', 'bg_img_url',
|
|
'icon', 'sort_order', 'parent_id', 'level']
|
|
|
|
for field in update_fields:
|
|
if ns.get(field):
|
|
ns_dic[field] = ns.get(field)
|
|
|
|
db = DBPools()
|
|
async with db.sqlorContext('kboss') as sor:
|
|
try:
|
|
await sor.U('home_page_content_items', ns_dic)
|
|
return {
|
|
'status': True,
|
|
'msg': 'update home page content success'
|
|
}
|
|
except Exception as e:
|
|
await sor.rollback()
|
|
return {
|
|
'status': False,
|
|
'msg': 'update home page content failed, %s' % str(e)
|
|
}
|
|
|
|
ret = await home_page_content_update(params_kw)
|
|
return ret |