diff --git a/b/product/get_firstpage_product_tree.dspy b/b/product/get_firstpage_product_tree.dspy index 53cdfeb..5e07266 100644 --- a/b/product/get_firstpage_product_tree.dspy +++ b/b/product/get_firstpage_product_tree.dspy @@ -705,6 +705,18 @@ async def get_firstpage_product_tree(ns={}): key=lambda x: (priority.get(x['thrTitle'], 4), result.index(x)) ) data['product_service'][0]['secMenu'][0]['thrMenu'] = sorted_data + + # 使用jsonpath 查找data下所有value下name包含'用'的对象 + if ns.get('keyword'): + jsonpath_result = jsonpath.jsonpath(data, '$..value') + data = [] + jsonpath_result = jsonpath_result if jsonpath_result else [] + for item in jsonpath_result: + for sub_item in item: + if ns['keyword'] in sub_item.get('name', ''): + data.append(sub_item) + + return { 'status': True, 'msg': 'get product list success', diff --git a/kgadget/src/kgadget.py b/kgadget/src/kgadget.py index eb6de3a..f40200a 100644 --- a/kgadget/src/kgadget.py +++ b/kgadget/src/kgadget.py @@ -111,6 +111,8 @@ from KaiYyEnDecryptUtil import KaiYyEnDecryptUtil from async_container import async_post +import jsonpath + if __name__ == '__main__': p = ProgramPath() parser = argparse.ArgumentParser(prog='Kaiyuan cloud Bussiness Operation Support System') @@ -214,6 +216,7 @@ if __name__ == '__main__': g.BaiduKafKaConsumer = BaiduKafKaConsumer g.KaiYyEnDecryptUtil = KaiYyEnDecryptUtil g.async_post = async_post + g.jsonpath = jsonpath i18n = getI18N(path=workdir) info(f'gadget version={__version__}')