From 68433e429c574550204c445e92fdf44e18bf59c0 Mon Sep 17 00:00:00 2001 From: xuyonghao <898441624@qq.com> Date: 星期四, 26 十二月 2024 13:42:26 +0800 Subject: [PATCH] resources表同步 --- app/task/fetch_agent.py | 118 +++++- main.py | 8 app/config/env_conf/resource.json | 862 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 959 insertions(+), 29 deletions(-) diff --git a/app/config/env_conf/resource.json b/app/config/env_conf/resource.json new file mode 100644 index 0000000..88d0d9b --- /dev/null +++ b/app/config/env_conf/resource.json @@ -0,0 +1,862 @@ +[ + { + "id": "1eed48e2-d510-42f2-9495-bc299bae237b", + "created_at": "8/8/2024 19:21:42", + "updated_at": "8/8/2024 19:21:42", + "name": "root", + "url": "root", + "path": null, + "perms": "root", + "description": null, + "icon": null, + "seq": 0, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "3", + "resource_id": null, + "status": "1", + "hidden": null, + "children": [ + { + "id": "76e81844-c3a6-4ea0-882f-150be2987d9d", + "created_at": "23/12/2024 09:50:31", + "updated_at": "23/12/2024 09:50:31", + "name": "鏅鸿兘浣撹鎯�", + "url": "/intelligent/detail", + "path": "/intelligent/detail", + "perms": "system:intelligent:detail", + "description": "", + "icon": "", + "seq": 0, + "target": null, + "canbdeeleted": null, + "resource_type_id": "3", + "resource_id": "1eed48e2-d510-42f2-9495-bc299bae237b", + "status": "2", + "hidden": 0 + }, + + { + "id": "3750795c-404b-488b-8080-89c037b4a187", + "created_at": "18/12/2024 19:20:09", + "updated_at": "20/12/2024 11:38:54", + "name": "灏忔暟", + "url": "Xiaoshu", + "path": "/xiaoshu", + "perms": "system:menu:xiaoshu", + "description": "", + "icon": "IconRobot", + "seq": 97, + "target": null, + "canbdeeleted": null, + "resource_type_id": "0", + "resource_id": "1eed48e2-d510-42f2-9495-bc299bae237b", + "status": "1", + "hidden": 0 + }, + { + "id": "3ea0f0b8-5160-4005-91d6-7c6650a5934c", + "created_at": "20/12/2024 11:38:54", + "updated_at": "20/12/2024 11:38:54", + "name": "浼氳瘽鍘嗗彶", + "url": "ConversationHistory", + "path": "/chat/history", + "perms": "system:conversation:hisroty", + "description": "", + "icon": "", + "seq": 0, + "target": null, + "canbdeeleted": null, + "resource_type_id": "3", + "resource_id": "1eed48e2-d510-42f2-9495-bc299bae237b", + "status": "1", + "hidden": 0 + }, + { + "id": "6469b565-908a-4771-a9e3-1cf8651b26f4", + "created_at": "12/9/2024 08:01:13", + "updated_at": "20/12/2024 11:38:54", + "name": "浼氳瘽", + "url": "ConversationQA", + "path": "/chat/qa", + "perms": "system:menu:conversation", + "description": null, + "icon": "iconVoice", + "seq": 101, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "0", + "resource_id": "1eed48e2-d510-42f2-9495-bc299bae237b", + "status": "1", + "hidden": null + }, + { + "id": "6b3640d2-6142-4dce-b09b-ce11f9e6c89c", + "created_at": "20/12/2024 11:38:54", + "updated_at": "20/12/2024 11:38:54", + "name": "浼氳瘽杩涜涓�", + "url": "ConversationQA", + "path": "/chat/qa", + "perms": "system:conversation:qa", + "description": "", + "icon": "", + "seq": 0, + "target": null, + "canbdeeleted": null, + "resource_type_id": "3", + "resource_id": "1eed48e2-d510-42f2-9495-bc299bae237b", + "status": "1", + "hidden": 0 + }, + { + "id": "6da7445a-5980-4380-ab1d-75021c1dd269", + "created_at": "18/12/2024 19:20:09", + "updated_at": "20/12/2024 11:38:54", + "name": "鏅鸿兘浣�", + "url": "Intelligent", + "path": "/intelligent", + "perms": "system:menu:intelligent", + "description": "", + "icon": "IconRobot", + "seq": 100, + "target": null, + "canbdeeleted": null, + "resource_type_id": "0", + "resource_id": "1eed48e2-d510-42f2-9495-bc299bae237b", + "status": "1", + "hidden": 0 + }, + { + "id": "9fb9456c-1000-485e-9cbb-905d951b86c1", + "created_at": "18/12/2024 19:20:09", + "updated_at": "20/12/2024 11:38:54", + "name": "鐭ヨ瘑搴撶鐞�", + "url": "Knowledge", + "path": "/knowledge", + "perms": "system:menu:knowledge", + "description": "", + "icon": "IconStorage", + "seq": 99, + "target": null, + "canbdeeleted": null, + "resource_type_id": "0", + "resource_id": "1eed48e2-d510-42f2-9495-bc299bae237b", + "status": "1", + "hidden": 0, + "children": [ + { + "id": "2d1c2831-79f4-4817-b79f-be4e49687bd1", + "created_at": "19/12/2024 10:08:40", + "updated_at": "24/12/2024 19:15:20", + "name": "鐭ヨ瘑搴撹鎯�", + "url": "KnowledgeDetail", + "path": "detail", + "perms": "system:knowledge:detail", + "description": "", + "icon": "", + "seq": 0, + "target": null, + "canbdeeleted": null, + "resource_type_id": "3", + "resource_id": "9fb9456c-1000-485e-9cbb-905d951b86c1", + "status": "1", + "hidden": 0 + }, + { + "id": "242060f6-741e-423a-8634-2f7ece1f0c6d", + "created_at": "19/12/2024 10:08:40", + "updated_at": "24/12/2024 19:15:20", + "name": "鐭ヨ瘑搴撳垹闄�", + "url": "-", + "path": "-", + "perms": "system:knowledge:delete", + "description": "", + "icon": "", + "seq": 0, + "target": null, + "canbdeeleted": null, + "resource_type_id": "1", + "resource_id": "9fb9456c-1000-485e-9cbb-905d951b86c1", + "status": "1", + "hidden": 0 + }, + { + "id": "25722c9e-63fe-4c80-8c05-5fcb9fb58d01", + "created_at": "19/12/2024 10:08:40", + "updated_at": "24/12/2024 19:15:20", + "name": "鐭ヨ瘑搴撴柊澧�", + "url": "-", + "path": "-", + "perms": "system:knowledge:add", + "description": "", + "icon": "", + "seq": 0, + "target": null, + "canbdeeleted": null, + "resource_type_id": "1", + "resource_id": "9fb9456c-1000-485e-9cbb-905d951b86c1", + "status": "0", + "hidden": 0 + } + ] + }, + { + "id": "a4931c80-c890-4142-a698-87940c937b57", + "created_at": "20/12/2024 11:38:54", + "updated_at": "20/12/2024 11:38:54", + "name": "浼氳瘽闈㈡澘", + "url": "ConversationBoard", + "path": "/chat/board", + "perms": "system:conversation:board", + "description": "", + "icon": "", + "seq": 0, + "target": null, + "canbdeeleted": null, + "resource_type_id": "3", + "resource_id": "1eed48e2-d510-42f2-9495-bc299bae237b", + "status": "1", + "hidden": 0 + }, + { + "id": "online", + "created_at": "25/8/2015 10:34:53", + "updated_at": "20/12/2024 11:38:54", + "name": "妯″瀷绠$悊", + "url": "Model", + "path": "/model", + "perms": "system:menu:model", + "description": "鐩戞帶鐢ㄦ埛鐧诲綍銆佹敞閿�", + "icon": "IconRelation", + "seq": 98, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "0", + "resource_id": "1eed48e2-d510-42f2-9495-bc299bae237b", + "status": "1", + "hidden": null + }, + { + "id": "xtgl", + "created_at": "25/8/2015 10:34:53", + "updated_at": "20/12/2024 11:38:54", + "name": "鏉冮檺绠$悊", + "url": "layout/LayoutPermission", + "path": "/permission", + "perms": "system:menu:permission", + "description": "绠$悊绯荤粺鐨勮祫婧愩�佽鑹层�佹満鏋勩�佺敤鎴风瓑淇℃伅", + "icon": "IconLock", + "seq": 96, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "0", + "resource_id": "1eed48e2-d510-42f2-9495-bc299bae237b", + "status": "1", + "hidden": null, + "children": [ + { + "id": "0642e4a6-3d48-4635-ba2a-bf4e39c351ed", + "created_at": "28/10/2024 07:38:41", + "updated_at": "18/12/2024 20:05:23", + "name": "鐢ㄦ埛缁勭鐞�", + "url": "PermissionGroup", + "path": "/permission/group", + "perms": "system:group", + "description": "绠$悊绯荤粺鐢ㄦ埛缁�", + "icon": null, + "seq": 0, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "0", + "resource_id": "xtgl", + "status": "1", + "hidden": null, + "children": [ + { + "id": "0bcb1f37-f87e-4f47-ba72-a2e194884b8f", + "created_at": "28/10/2024 07:41:16", + "updated_at": "18/12/2024 15:09:28", + "name": "缂栬緫鐢ㄦ埛缁�", + "url": "/base/syuser!update", + "path": "", + "perms": "system:group:edit", + "description": "鏌ョ湅鐢ㄦ埛缁�", + "icon": null, + "seq": 0, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "0642e4a6-3d48-4635-ba2a-bf4e39c351ed", + "status": "1", + "hidden": null + }, + + { + "id": "2648f4bd-b5d5-4a34-8b9c-128fd970b014", + "created_at": "18/12/2024 15:09:28", + "updated_at": "18/12/2024 15:09:28", + "name": "鐢ㄦ埛缁勬垚鍛樼鐞�", + "url": "-", + "path": "", + "perms": "system:group:memberConfig", + "description": "", + "icon": "", + "seq": 0, + "target": null, + "canbdeeleted": null, + "resource_type_id": "1", + "resource_id": "0642e4a6-3d48-4635-ba2a-bf4e39c351ed", + "status": "1", + "hidden": 0 + }, + + { + "id": "3daf1a03-c0c9-4ebd-935d-fe46561971fb", + "created_at": "28/10/2024 07:46:14", + "updated_at": "28/10/2024 07:46:41", + "name": "鐢ㄦ埛缁勫垪琛�", + "url": "/base/syuser!grid", + "path": null, + "perms": "system:group:list", + "description": null, + "icon": null, + "seq": 0, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "0642e4a6-3d48-4635-ba2a-bf4e39c351ed", + "status": "1", + "hidden": null + }, + + { + "id": "72fe917f-70ee-4cbf-8c21-f1852f3ef037", + "created_at": "18/12/2024 15:09:28", + "updated_at": "19/12/2024 16:08:38", + "name": "鐢ㄦ埛缁勬潈闄愮鐞�", + "url": "-", + "path": "", + "perms": "system:group:permissionConfig", + "description": "", + "icon": "", + "seq": 0, + "target": null, + "canbdeeleted": null, + "resource_type_id": "3", + "resource_id": "0642e4a6-3d48-4635-ba2a-bf4e39c351ed", + "status": "1", + "hidden": 0 + }, + + { + "id": "5d9ab44e-488c-4dd8-8688-56650393fab1", + "created_at": "18/12/2024 11:35:02", + "updated_at": "18/12/2024 11:35:02", + "name": "鍒犻櫎鐢ㄦ埛缁�", + "url": "-", + "path": "", + "perms": "system:group:delete", + "description": "", + "icon": "", + "seq": 0, + "target": null, + "canbdeeleted": null, + "resource_type_id": "1", + "resource_id": "0642e4a6-3d48-4635-ba2a-bf4e39c351ed", + "status": "1", + "hidden": 0 + }, + + { + "id": "f2b2c9be-1c39-4416-b3c7-21891fc28f84", + "created_at": "28/10/2024 07:56:04", + "updated_at": "28/10/2024 07:56:04", + "name": "娣诲姞鐢ㄦ埛缁�", + "url": "/base/sygroup!save", + "path": null, + "perms": "system:group:add", + "description": null, + "icon": null, + "seq": 0, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "0642e4a6-3d48-4635-ba2a-bf4e39c351ed", + "status": "1", + "hidden": null + } + ] + }, + { + "id": "jggl", + "created_at": "25/8/2015 10:34:53", + "updated_at": "18/12/2024 20:05:23", + "name": "鏈烘瀯绠$悊", + "url": "PermissionOrganization", + "path": "/permission/org", + "perms": "system:dept", + "description": "绠$悊绯荤粺涓敤鎴风殑鏈烘瀯", + "icon": "tree", + "seq": 0, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "0", + "resource_id": "xtgl", + "status": "1", + "hidden": null, + "children": [ + { + "id": "jgbj", + "created_at": "25/8/2015 10:34:53", + "updated_at": "25/5/2022 00:39:56", + "name": "缂栬緫鏈烘瀯", + "url": "/base/syorganization!update", + "path": null, + "perms": "system:dept:edit", + "description": "缂栬緫鏈烘瀯", + "icon": "ext-icon-bullet_wrench", + "seq": 2, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "jggl", + "status": "1", + "hidden": null + }, + { + "id": "jglb", + "created_at": "25/8/2015 10:34:53", + "updated_at": "28/11/2016 14:09:52", + "name": "鏈烘瀯鍒楄〃", + "url": "/base/syorganization!treeGrid", + "path": null, + "perms": "system:dept:list", + "description": "鏌ヨ鏈烘瀯鍒楄〃", + "icon": "ext-icon-bullet_wrench", + "seq": 0, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "jggl", + "status": "1", + "hidden": null + }, + { + "id": "jgsc", + "created_at": "25/8/2015 10:34:53", + "updated_at": "18/12/2024 11:35:02", + "name": "鍒犻櫎鏈烘瀯", + "url": "/base/syorganization!delete", + "path": "", + "perms": "system:dept:delete", + "description": "鍒犻櫎鏈烘瀯", + "icon": "ext-icon-bullet_wrench", + "seq": 0, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "jggl", + "status": "1", + "hidden": null + }, + { + "id": "jgtj", + "created_at": "25/8/2015 10:34:53", + "updated_at": "25/8/2015 10:34:53", + "name": "娣诲姞鏈烘瀯", + "url": "/base/syorganization!save", + "path": null, + "perms": "system:dept:add", + "description": "娣诲姞鏈烘瀯", + "icon": "ext-icon-bullet_wrench", + "seq": 1, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "jggl", + "status": "1", + "hidden": null + } + ] + }, + { + "id": "jsgl", + "created_at": "25/8/2015 10:34:53", + "updated_at": "18/12/2024 20:05:23", + "name": "瑙掕壊绠$悊", + "url": "PermissionRole", + "path": "/permission/role", + "perms": "system:role", + "description": "绠$悊绯荤粺涓敤鎴风殑瑙掕壊", + "icon": "peoples", + "seq": 0, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "0", + "resource_id": "xtgl", + "status": "1", + "hidden": null, + "children": [ + { + "id": "00b61433-a5cd-46e9-a867-2e249dd310f4", + "created_at": "18/12/2024 11:35:02", + "updated_at": "18/12/2024 11:35:02", + "name": "瑙掕壊鏉冮檺閰嶇疆", + "url": "-", + "path": "", + "perms": "system:role:permissionEdit", + "description": "瑙掕壊鏉冮檺閰嶇疆", + "icon": "", + "seq": 0, + "target": null, + "canbdeeleted": null, + "resource_type_id": "1", + "resource_id": "jsgl", + "status": "1", + "hidden": 0 + }, + { + "id": "f9947112-c8e4-42cd-ba3a-2612eb373564", + "created_at": "18/12/2024 11:35:02", + "updated_at": "18/12/2024 11:35:02", + "name": "瑙掕壊閮ㄩ棬閰嶇疆", + "url": "-", + "path": "", + "perms": "system:role:deptEdit", + "description": "瑙掕壊閮ㄩ棬閰嶇疆", + "icon": "", + "seq": 0, + "target": null, + "canbdeeleted": null, + "resource_type_id": "1", + "resource_id": "jsgl", + "status": "1", + "hidden": 0 + }, + { + "id": "jsbj", + "created_at": "25/8/2015 10:34:53", + "updated_at": "25/8/2015 10:34:53", + "name": "缂栬緫瑙掕壊", + "url": "/base/syrole!update", + "path": null, + "perms": "system:role:edit", + "description": "缂栬緫瑙掕壊", + "icon": "ext-icon-bullet_wrench", + "seq": 2, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "jsgl", + "status": "1", + "hidden": null + }, + { + "id": "jslb", + "created_at": "25/8/2015 10:34:53", + "updated_at": "25/8/2015 10:34:53", + "name": "瑙掕壊鍒楄〃", + "url": "/base/syrole!grid", + "path": null, + "perms": "system:role:list", + "description": "鏌ヨ瑙掕壊鍒楄〃", + "icon": "ext-icon-bullet_wrench", + "seq": 0, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "jsgl", + "status": "1", + "hidden": null + }, + { + "id": "jssc", + "created_at": "25/8/2015 10:34:53", + "updated_at": "18/12/2024 11:35:02", + "name": "鍒犻櫎瑙掕壊", + "url": "/base/syrole!delete", + "path": "", + "perms": "system:role:delete", + "description": "鍒犻櫎瑙掕壊", + "icon": "ext-icon-bullet_wrench", + "seq": 0, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "jsgl", + "status": "1", + "hidden": null + }, + { + "id": "jstj", + "created_at": "25/8/2015 10:34:53", + "updated_at": "25/8/2015 10:34:53", + "name": "娣诲姞瑙掕壊", + "url": "/base/syrole!save", + "path": null, + "perms": "system:role:add", + "description": "娣诲姞瑙掕壊", + "icon": "ext-icon-bullet_wrench", + "seq": 1, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "jsgl", + "status": "1", + "hidden": null + } + ] + }, + + { + "id": "yhgl", + "created_at": "25/8/2015 10:34:53", + "updated_at": "18/12/2024 20:05:23", + "name": "鐢ㄦ埛绠$悊", + "url": "PermissionAccount", + "path": "/permission/account", + "perms": "system:user", + "description": "绠$悊绯荤粺涓敤鎴风殑鐢ㄦ埛", + "icon": "user", + "seq": 0, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "0", + "resource_id": "xtgl", + "status": "1", + "hidden": null, + "children": [ + { + "id": "07417a54-4afc-45ec-84ee-c59baf7d45b4", + "created_at": "18/12/2024 11:35:02", + "updated_at": "18/12/2024 11:35:02", + "name": "鐢ㄦ埛瑙掕壊", + "url": "-", + "path": "", + "perms": "system:user:viewPermission", + "description": "缂栬緫鐢ㄦ埛瑙掕壊", + "icon": "ext-icon-bullet_wrench", + "seq": 0, + "target": null, + "canbdeeleted": null, + "resource_type_id": "1", + "resource_id": "yhgl", + "status": "1", + "hidden": 0 + }, + + { + "id": "a06316f1-b7e4-48b8-80c8-49b1dbb79c4a", + "created_at": "18/12/2024 11:35:02", + "updated_at": "18/12/2024 11:35:02", + "name": "閲嶅埗瀵嗙爜", + "url": "-", + "path": "", + "perms": "system:role:resetPassword", + "description": "", + "icon": "", + "seq": 0, + "target": null, + "canbdeeleted": null, + "resource_type_id": "1", + "resource_id": "yhgl", + "status": "0", + "hidden": 0 + }, + + { + "id": "e368cae2-96b6-46e5-b537-946a8dc5ede6", + "created_at": "18/12/2024 11:35:02", + "updated_at": "18/12/2024 11:35:02", + "name": "閮ㄩ棬閰嶇疆", + "url": "-", + "path": "", + "perms": "system:user:deptEdit", + "description": "缂栬緫鐢ㄦ埛鏈烘瀯", + "icon": "ext-icon-bullet_wrench", + "seq": 0, + "target": null, + "canbdeeleted": null, + "resource_type_id": "1", + "resource_id": "yhgl", + "status": "1", + "hidden": 0 + }, + + { + "id": "yhbj", + "created_at": "25/8/2015 10:34:53", + "updated_at": "25/8/2015 10:34:53", + "name": "缂栬緫鐢ㄦ埛", + "url": "/base/syuser!update", + "path": null, + "perms": "system:user:edit", + "description": "缂栬緫鐢ㄦ埛", + "icon": "ext-icon-bullet_wrench", + "seq": 2, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "yhgl", + "status": "1", + "hidden": null + }, + + { + "id": "yhlb", + "created_at": "25/8/2015 10:34:53", + "updated_at": "25/8/2015 10:34:53", + "name": "鐢ㄦ埛鍒楄〃", + "url": "/base/syuser!grid", + "path": null, + "perms": "system:user:list", + "description": "鏌ヨ鐢ㄦ埛鍒楄〃", + "icon": "ext-icon-bullet_wrench", + "seq": 0, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "yhgl", + "status": "1", + "hidden": null + }, + + { + "id": "yhsc", + "created_at": "25/8/2015 10:34:53", + "updated_at": "18/12/2024 11:35:02", + "name": "鍒犻櫎鐢ㄦ埛", + "url": "/base/syuser!delete", + "path": "", + "perms": "system:user:delete", + "description": "鍒犻櫎鐢ㄦ埛", + "icon": "ext-icon-bullet_wrench", + "seq": 0, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "yhgl", + "status": "1", + "hidden": null + }, + + { + "id": "yhtj", + "created_at": "25/8/2015 10:34:53", + "updated_at": "25/8/2015 10:34:53", + "name": "娣诲姞鐢ㄦ埛", + "url": "/base/syuser!save", + "path": null, + "perms": "system:user:add", + "description": "娣诲姞鐢ㄦ埛", + "icon": "ext-icon-bullet_wrench", + "seq": 1, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "yhgl", + "status": "1", + "hidden": null + } + ] + }, + { + "id": "zygl", + "created_at": "25/8/2015 10:34:53", + "updated_at": "18/12/2024 20:05:23", + "name": "璧勬簮绠$悊", + "url": "PermissionResource", + "path": "/permission/resource", + "perms": "system:menu", + "description": "绠$悊绯荤粺鐨勮祫婧�", + "icon": "header-zhishiku", + "seq": 0, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "0", + "resource_id": "xtgl", + "status": "1", + "hidden": null, + "children": [ + { + "id": "zybj", + "created_at": "25/8/2015 10:34:53", + "updated_at": "5/9/2024 03:14:57", + "name": "缂栬緫璧勬簮", + "url": "/base/syresource!update", + "path": null, + "perms": "system:menu:edit", + "description": "缂栬緫璧勬簮", + "icon": "/api/v1/llm/Image/e65d0ccc-026e-4e08-bcbd-742d7b5ee61a.png", + "seq": 2, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "zygl", + "status": "1", + "hidden": null + }, + + { + "id": "zylb", + "created_at": "25/8/2015 10:34:53", + "updated_at": "18/12/2024 11:35:02", + "name": "璧勬簮鍒楄〃", + "url": "/base/syresource!treeGrid", + "path": "", + "perms": "system:menu:list", + "description": "鏌ヨ璧勬簮", + "icon": "ext-icon-bullet_wrench", + "seq": 0, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "zygl", + "status": "1", + "hidden": null + }, + + { + "id": "zysc", + "created_at": "25/8/2015 10:34:53", + "updated_at": "18/12/2024 11:35:02", + "name": "鍒犻櫎璧勬簮", + "url": "/base/syresource!delete", + "path": "", + "perms": "system:menu:delete", + "description": "鍒犻櫎璧勬簮", + "icon": "ext-icon-bullet_wrench", + "seq": 0, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "zygl", + "status": "1", + "hidden": null + }, + + { + "id": "zytj", + "created_at": "25/8/2015 10:34:53", + "updated_at": "25/8/2015 10:34:53", + "name": "娣诲姞璧勬簮", + "url": "/base/syresource!save", + "path": null, + "perms": "system:menu:add", + "description": "娣诲姞璧勬簮", + "icon": "ext-icon-bullet_wrench", + "seq": 1, + "target": null, + "canbdeeleted": 1, + "resource_type_id": "1", + "resource_id": "zygl", + "status": "1", + "hidden": null + } + ] + } + ] + } + ] + } +] diff --git a/app/task/fetch_agent.py b/app/task/fetch_agent.py index 8507bee..da17b10 100644 --- a/app/task/fetch_agent.py +++ b/app/task/fetch_agent.py @@ -1,17 +1,20 @@ +import json +import os from pickle import PROTO from typing import Dict, List, Tuple from sqlalchemy import create_engine, Column, String, Integer, Text from sqlalchemy.exc import IntegrityError -from sqlalchemy.orm import sessionmaker +from sqlalchemy.orm import sessionmaker, Session from app.config.config import settings -from app.config.const import RAGFLOW, BISHENG, DIFY +from app.config.const import RAGFLOW, BISHENG, DIFY, ENV_CONF_PATH from app.models import KnowledgeModel from app.models.dialog_model import DialogModel from app.models.user_model import UserAppModel from app.models.agent_model import AgentModel from app.models.base_model import SessionLocal, Base +from app.models.resource_model import ResourceModel from app.service.v2.app_register import AppRegisterDao # 鍒涘缓鏁版嵁搴撳紩鎿庡拰浼氳瘽宸ュ巶 @@ -207,9 +210,9 @@ finally: db.close() -def get_rag_user_id(db, tenant_id, app_type): - user = db.query(UserAppModel).filter(UserAppModel.app_type==app_type, UserAppModel.app_id==tenant_id).first() +def get_rag_user_id(db, tenant_id, app_type): + user = db.query(UserAppModel).filter(UserAppModel.app_type == app_type, UserAppModel.app_id == tenant_id).first() if user: return user.user_id return tenant_id @@ -220,30 +223,34 @@ try: if names: query = db.query(Flow.id, Flow.name, Flow.description, Flow.status, Flow.user_id) \ - .filter(Flow.name.in_(names), Flow.status=="1") + .filter(Flow.name.in_(names), Flow.status == "1") else: - query = db.query(Flow.id, Flow.name, Flow.description, Flow.status, Flow.user_id).filter(Flow.status=="1") + query = db.query(Flow.id, Flow.name, Flow.description, Flow.status, Flow.user_id).filter(Flow.status == "1") results = query.all() # print(f"Executing query: {query}") # 鏍煎紡鍖杋d涓篣UID - formatted_results = [{"id":row[0], "name": row[1], "description": row[2], "status": row[3], "user_id": str(row[4]), "mode": "agent-dialog"} for row in results] + formatted_results = [ + {"id": row[0], "name": row[1], "description": row[2], "status": row[3], "user_id": str(row[4]), + "mode": "agent-dialog"} for row in results] return formatted_results finally: db.close() + def get_data_from_ragflow_v2(names: List[str]) -> List[Dict]: db = SessionRagflow() try: if names: query = db.query(Dialog.id, Dialog.name, Dialog.description, Dialog.status, Dialog.tenant_id) \ - .filter( Dialog.name.in_(names), Dialog.status == "1") + .filter(Dialog.name.in_(names), Dialog.status == "1") else: - query = db.query(Dialog.id, Dialog.name, Dialog.description, Dialog.status, Dialog.tenant_id).filter( Dialog.status == "1") + query = db.query(Dialog.id, Dialog.name, Dialog.description, Dialog.status, Dialog.tenant_id).filter( + Dialog.status == "1") results = query.all() formatted_results = [ - {"id": row[0], "name": row[1], "description": row[2], "status": "1" if row[3] == "1" else "2", + {"id": row[0], "name": row[1], "description": row[2], "status": "1" if row[3] == "1" else "2", "user_id": str(row[4]), "mode": "agent-dialog"} for row in results] return formatted_results finally: @@ -255,7 +262,7 @@ try: if names: query = db.query(DfApps.id, DfApps.name, DfApps.description, DfApps.status, DfApps.tenant_id, DfApps.mode) \ - .filter( DfApps.name.in_(names)) + .filter(DfApps.name.in_(names)) else: query = db.query(DfApps.id, DfApps.name, DfApps.description, DfApps.status, DfApps.tenant_id, DfApps.mode) @@ -268,11 +275,10 @@ db.close() - -def update_ids_in_local_v2(data: List[Dict], dialog_type:str): +def update_ids_in_local_v2(data: List[Dict], dialog_type: str): db = SessionLocal() agent_id_list = [] - type_dict = {"1": RAGFLOW,"2": BISHENG,"4": DIFY} + type_dict = {"1": RAGFLOW, "2": BISHENG, "4": DIFY} try: for row in data: agent_id_list.append(row["id"]) @@ -284,7 +290,10 @@ existing_agent.mode = row["mode"] # existing_agent.tenant_id = get_rag_user_id(db, row["user_id"], type_dict[dialog_type]) else: - existing = DialogModel(id=row["id"], status=row["status"], name=row["name"], description=row["description"], tenant_id=get_rag_user_id(db, row["user_id"], type_dict[dialog_type]), dialog_type=dialog_type, mode=row["mode"]) + existing = DialogModel(id=row["id"], status=row["status"], name=row["name"], + description=row["description"], + tenant_id=get_rag_user_id(db, row["user_id"], type_dict[dialog_type]), + dialog_type=dialog_type, mode=row["mode"]) db.add(existing) db.commit() for dialog in db.query(DialogModel).filter_by(dialog_type=dialog_type).all(): @@ -299,18 +308,19 @@ db.close() - def get_data_from_ragflow_knowledge(): db = SessionRagflow() try: - results = db.query(RgKnowledge.id, RgKnowledge.name, RgKnowledge.description, RgKnowledge.status, RgKnowledge.tenant_id, RgKnowledge.doc_num, RgKnowledge.permission).all() + results = db.query(RgKnowledge.id, RgKnowledge.name, RgKnowledge.description, RgKnowledge.status, + RgKnowledge.tenant_id, RgKnowledge.doc_num, RgKnowledge.permission).all() formatted_results = [ {"id": row[0], "name": row[1], "description": row[2], "status": str(row[3]), "user_id": str(row[4]), "doc_num": row[5], "permission": row[6]} for row in results] return formatted_results finally: db.close() + def sync_agents_v2(): db = SessionLocal() @@ -336,6 +346,7 @@ finally: db.close() + def update_ids_in_local_knowledge(data, klg_type): type_dict = {"1": RAGFLOW, "2": BISHENG, "4": DIFY} db = SessionLocal() @@ -348,13 +359,14 @@ existing_agent.name = row["name"] existing_agent.description = row["description"] # existing_agent.tenant_id = get_rag_user_id(db, row["user_id"], type_dict[klg_type]) - existing_agent.permission = row["permission"] - existing_agent.documents = row["doc_num"] - existing_agent.status = row["status"] + existing_agent.permission = row["permission"] + existing_agent.documents = row["doc_num"] + existing_agent.status = row["status"] else: existing = KnowledgeModel(id=row["id"], name=row["name"], description=row["description"], - tenant_id=get_rag_user_id(db, row["user_id"], type_dict[klg_type]),status=row["status"], - knowledge_type=1, permission=row["permission"], documents=row["doc_num"]) + tenant_id=get_rag_user_id(db, row["user_id"], type_dict[klg_type]), + status=row["status"], + knowledge_type=1, permission=row["permission"], documents=row["doc_num"]) db.add(existing) db.commit() for dialog in db.query(KnowledgeModel).filter_by(knowledge_type=klg_type).all(): @@ -367,13 +379,16 @@ finally: db.close() + def get_one_from_ragflow_knowledge(klg_id): db = SessionRagflow() try: - row = db.query(RgKnowledge.id, RgKnowledge.name, RgKnowledge.description, RgKnowledge.status, RgKnowledge.tenant_id, RgKnowledge.doc_num, RgKnowledge.permission).filter(RgKnowledge.id==klg_id).first() + row = db.query(RgKnowledge.id, RgKnowledge.name, RgKnowledge.description, RgKnowledge.status, + RgKnowledge.tenant_id, RgKnowledge.doc_num, RgKnowledge.permission).filter( + RgKnowledge.id == klg_id).first() return {"id": row[0], "name": row[1], "description": row[2], "status": str(row[3]), - "user_id": str(row[4]), "doc_num": row[5], "permission": row[6]} if row else {} + "user_id": str(row[4]), "doc_num": row[5], "permission": row[6]} if row else {} finally: db.close() @@ -405,15 +420,64 @@ db = SessionRagflow() try: if user_id: - db.query(RgUserTenant).filter( RgUserTenant.user_id==user_id, RgUserTenant.role=="invite").update({"role": "normal"}) - db.query(RgUserTenant).filter( RgUserTenant.tenant_id==user_id, RgUserTenant.role=="invite").update({"role": "normal"}) + db.query(RgUserTenant).filter(RgUserTenant.user_id == user_id, RgUserTenant.role == "invite").update( + {"role": "normal"}) + db.query(RgUserTenant).filter(RgUserTenant.tenant_id == user_id, RgUserTenant.role == "invite").update( + {"role": "normal"}) else: - db.query(RgUserTenant).filter(RgUserTenant.role=="invite").update({"role": "normal"}) + db.query(RgUserTenant).filter(RgUserTenant.role == "invite").update({"role": "normal"}) db.commit() finally: db.close() +def import_tree(session: Session, node: dict, parent=None): + resource = ResourceModel( + id=node['id'], + name=node['name'], + url=node['url'], + path=node.get('path'), + perms=node['perms'], + description=node.get('description'), + icon=node.get('icon'), + seq=node['seq'], + target=node.get('target'), + canbdeeleted=node.get('canbdeeleted'), + resource_type_id=node['resource_type_id'], + resource_id=node.get('resource_id'), + status=node['status'], + hidden=node.get('hidden') + ) + if parent: + resource.parent = parent + session.add(resource) + if 'children' in node: + for child in node['children']: + import_tree(session, child, parent=resource) + session.commit() + + +def sync_resources_from_json(): + db = SessionLocal() + try: + if db.query(ResourceModel).count() == 0: + with open(os.path.join(ENV_CONF_PATH, "resource.json"), 'r', encoding='utf-8') as file: + json_data = json.load(file) + + db.query(ResourceModel).delete() + db.commit() + + for node in json_data: + import_tree(db, node) + print("add resources record successfully") + else: + print("sync resources successfully") + except Exception as e: + print(f"Failed to sync resources: {str(e)}") + finally: + db.close() + + if __name__ == "__main__": # a = get_data_from_dify_v2([]) # print(a) diff --git a/main.py b/main.py index 86cb9f0..fc2f567 100644 --- a/main.py +++ b/main.py @@ -24,10 +24,13 @@ from app.api.role import role_router from app.models.base_model import init_db # from app.models.base_model import init_db -from app.task.fetch_agent import sync_agents, initialize_agents, sync_agents_v2, sync_knowledge +from app.task.fetch_agent import sync_agents, initialize_agents, sync_agents_v2, sync_knowledge, \ + sync_resources_from_json from app.init_config.init_run_data import sync_default_data init_db() + + # 浣跨敤 Lifespan 浜嬩欢澶勭悊绋嬪簭 @asynccontextmanager async def lifespan(app: FastAPI): @@ -39,6 +42,7 @@ sync_agents_v2() sync_knowledge() + sync_resources_from_json() yield # 鍦ㄥ簲鐢ㄥ叧闂椂鎵ц娓呯悊鎿嶄綔锛堝鏋滈渶瑕侊級 pass @@ -64,7 +68,6 @@ scheduler.add_job(sync_agents_v2, 'interval', minutes=60, id="sync_resource_data") scheduler.start() - app.include_router(auth_router, prefix='/api/auth', tags=["auth"]) app.include_router(chat_router, prefix='/api/chat', tags=["chat"]) app.include_router(agent_router, prefix='/api/agent', tags=["agent"]) @@ -86,4 +89,5 @@ if __name__ == "__main__": import uvicorn + uvicorn.run(app, host="0.0.0.0", port=9201) -- Gitblit v1.8.0