更新新增三个模块
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -57,14 +57,23 @@ def _push_task_event(task_id, event):
|
||||
|
||||
|
||||
def _expand_folder_xlsx(folder_path):
|
||||
"""返回文件夹下所有 .xlsx 文件的绝对路径列表"""
|
||||
"""返回文件夹下所有 .xlsx 文件的绝对路径和相对路径列表(递归)"""
|
||||
if not folder_path or not os.path.isdir(folder_path):
|
||||
return []
|
||||
paths = []
|
||||
for name in os.listdir(folder_path):
|
||||
if name.endswith('.xlsx') or name.endswith('.XLSX'):
|
||||
paths.append(os.path.normpath(os.path.join(folder_path, name)))
|
||||
return paths
|
||||
items = []
|
||||
root = os.path.normpath(folder_path)
|
||||
for current_root, _, filenames in os.walk(root):
|
||||
for name in filenames:
|
||||
if not (name.endswith('.xlsx') or name.endswith('.XLSX')):
|
||||
continue
|
||||
absolute_path = os.path.normpath(os.path.join(current_root, name))
|
||||
relative_path = os.path.relpath(absolute_path, root).replace('\\', '/')
|
||||
items.append({
|
||||
'absolutePath': absolute_path,
|
||||
'relativePath': relative_path,
|
||||
})
|
||||
items.sort(key=lambda item: item['relativePath'])
|
||||
return items
|
||||
|
||||
|
||||
def _upload_local_xlsx_to_oss(local_path, user_id):
|
||||
@@ -478,8 +487,8 @@ def api_brand_expand_folder():
|
||||
folder = (data.get('folder') or '').strip()
|
||||
if not folder:
|
||||
return jsonify({'success': False, 'error': '请提供 folder 路径'}), 400
|
||||
paths = _expand_folder_xlsx(folder)
|
||||
return jsonify({'success': True, 'paths': paths})
|
||||
items = _expand_folder_xlsx(folder)
|
||||
return jsonify({'success': True, 'items': items})
|
||||
except Exception as e:
|
||||
return jsonify({'success': False, 'error': str(e)}), 500
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ class WindowAPI:
|
||||
)
|
||||
return result[0] if result else ''
|
||||
|
||||
def upload_file_to_java(self, file_path):
|
||||
def upload_file_to_java(self, file_path, relative_path=None):
|
||||
"""按本地路径读取文件并上传到 Java 后端临时目录。"""
|
||||
if not file_path or not str(file_path).strip():
|
||||
return {'success': False, 'error': '文件路径为空'}
|
||||
@@ -157,6 +157,7 @@ class WindowAPI:
|
||||
response = requests.post(
|
||||
f"{JAVA_API_BASE}/api/files/upload",
|
||||
files={'file': (os.path.basename(normalized_path), file_obj)},
|
||||
data={'relativePath': str(relative_path).strip()} if relative_path else None,
|
||||
timeout=120,
|
||||
)
|
||||
response.raise_for_status()
|
||||
|
||||
Reference in New Issue
Block a user