public class SohelpBootResourceFileServiceImpl extends Object implements ISohelpBootResourceService
| 构造器和说明 |
|---|
SohelpBootResourceFileServiceImpl() |
| 限定符和类型 | 方法和说明 |
|---|---|
Map<String,Object> |
add(String path,
String content)
创建新的资源文件
|
void |
deleteBatch(String path)
批量删除指定路径下的资源文件
|
void |
deleteByPath(String path)
删除指定路径的资源文件
|
boolean |
exists(String path)
判断指定路径下的资源是否已存在
|
List<Map<String,Object>> |
exportAll()
导出指定目录下的所有文件信息
函数首先从配置中获取资源目录路径,然后遍历该目录下的所有文件(忽略子目录),
将每个文件的文件名和内容读取后存入Map,最终返回包含所有文件信息的List。
|
com.alibaba.fastjson.JSONObject |
getByPath(String path)
根据文件路径读取并解析为JSONObject对象
|
<T> T |
getByPath(String path,
Class<T> cls)
根据文件路径读取并反序列化为指定类型的Java对象
|
String |
getResourcePath(String path)
获取资源的完整路径(拼接基础路径与传入路径)
|
void |
importAll(List<Map<String,Object>> list)
批量导入所有资源文件数据
|
List<com.alibaba.fastjson.JSONObject> |
listByPath(String path)
根据指定路径读取该目录下所有资源文件,并封装成JSONObject列表
|
<T> List<T> |
listByPath(String filePath,
Class<T> cls)
根据指定路径读取资源文件,并将其转换为目标类型的对象列表
|
List<com.alibaba.fastjson.JSONObject> |
listByRegex(String filePath,
String regex)
使用正则表达式过滤符合规则的资源文件并返回其对应的JSONObject列表
|
<T> List<T> |
listByRegex(String filePath,
String regex,
Class<T> cls)
使用正则表达式过滤符合规则的资源文件,并将其转换为目标类型的对象列表
|
void |
renamePath(String srcFilePath,
String newFilePath)
重命名资源文件路径
|
Map<String,Object> |
save(String path,
Map<String,Object> formMap)
将表单数据保存到指定路径对应的资源文件中
|
Map<String,Object> |
save(String path,
String context)
保存资源文件:若文件存在则更新,否则新增
|
Map<String,Object> |
updateByPath(String path,
String content)
更新已有资源文件的内容
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconvertClass, formatFilePath, readOnlypublic String getResourcePath(String path)
path - 相对于资源根目录的相对路径@Comment(value="\u6839\u636e\u6587\u4ef6\u540d\u83b7\u53d6\u6587\u4ef6\u5185\u5bb9") public com.alibaba.fastjson.JSONObject getByPath(String path)
getByPath 在接口中 ISohelpBootResourceServicepath - 文件路径BusiException - 业务异常@Comment(value="\u6839\u636e\u8def\u5f84\u83b7\u53d6\u5bf9\u8c61") public <T> T getByPath(String path, Class<T> cls) throws SQLException
getByPath 在接口中 ISohelpBootResourceServiceT - 泛型参数表示目标类类型path - 文件路径cls - 反序列化的目标类类型SQLException - 数据库访问异常@Comment(value="\u4fdd\u5b58\u914d\u7f6e\u8d44\u6e90") public Map<String,Object> save(String path, Map<String,Object> formMap) throws SQLException, BusiException
save 在接口中 ISohelpBootResourceServicepath - 资源文件路径formMap - 表单数据映射SQLException - 数据库访问异常BusiException - 业务逻辑异常public void importAll(List<Map<String,Object>> list) throws BusiException
importAll 在接口中 ISohelpBootResourceServicelist - 包含资源文件数据的Map列表,每个Map代表一个资源文件的属性键值对BusiException - 当导入过程中出现业务异常时抛出public List<Map<String,Object>> exportAll()
函数首先从配置中获取资源目录路径,然后遍历该目录下的所有文件(忽略子目录), 将每个文件的文件名和内容读取后存入Map,最终返回包含所有文件信息的List。
exportAll 在接口中 ISohelpBootResourceService@Comment(value="\u5224\u65ad\u8d44\u6e90\u662f\u5426\u5b58\u5728") public boolean exists(String path)
exists 在接口中 ISohelpBootResourceServicepath - 资源路径@Comment(value="\u4fdd\u5b58\u914d\u7f6e\u8d44\u6e90") public Map<String,Object> save(String path, String context) throws SQLException, BusiException
save 在接口中 ISohelpBootResourceServicepath - 资源路径context - 写入的内容SQLException - 数据库访问异常BusiException - 业务逻辑异常@Comment(value="\u521b\u5efa\u914d\u7f6e\u8d44\u6e90") public Map<String,Object> add(String path, String content) throws SQLException, BusiException
add 在接口中 ISohelpBootResourceServicepath - 资源路径content - 文件内容SQLException - 数据库访问异常BusiException - 业务逻辑异常(如只读模式、文件已存在等)@Comment(value="\u91cd\u547d\u540d\u8def\u5f84") public void renamePath(String srcFilePath, String newFilePath) throws SQLException, BusiException
renamePath 在接口中 ISohelpBootResourceServicesrcFilePath - 原始文件路径newFilePath - 新文件路径SQLException - 数据库访问异常BusiException - 业务逻辑异常(如只读模式)@Comment(value="\u66f4\u65b0\u6587\u4ef6\u5185\u5bb9") public Map<String,Object> updateByPath(String path, String content) throws SQLException, BusiException
updateByPath 在接口中 ISohelpBootResourceServicepath - 文件路径content - 需要更新的文件内容SQLException - 数据库访问异常BusiException - 业务逻辑异常(如只读模式)@Comment(value="\u6839\u636e\u6307\u5b9a\u8def\u5f84\u8bfb\u53d6\u914d\u7f6e\u8d44\u6e90\u5217\u8868") public List<com.alibaba.fastjson.JSONObject> listByPath(String path)
listByPath 在接口中 ISohelpBootResourceServicepath - 指定的资源目录路径@Comment(value="\u8bfb\u53d6\u914d\u7f6e\u8d44\u6e90\u5217\u8868") public <T> List<T> listByPath(String filePath, Class<T> cls) throws SQLException
listByPath 在接口中 ISohelpBootResourceServiceT - 泛型参数表示目标类型filePath - 指定的资源目录路径cls - 目标类型Class对象SQLException - 数据库访问异常public List<com.alibaba.fastjson.JSONObject> listByRegex(String filePath, String regex) throws SQLException
listByRegex 在接口中 ISohelpBootResourceServicefilePath - 指定的资源目录路径regex - 过滤用的正则表达式SQLException - 数据库访问异常public <T> List<T> listByRegex(String filePath, String regex, Class<T> cls) throws SQLException
listByRegex 在接口中 ISohelpBootResourceServiceT - 泛型参数表示目标类型filePath - 指定的资源目录路径regex - 过滤用的正则表达式cls - 目标类型Class对象SQLException - 数据库访问异常@Comment(value="\u5220\u9664\u914d\u7f6e\u8d44\u6e90") public void deleteByPath(String path) throws BusiException
deleteByPath 在接口中 ISohelpBootResourceServicepath - 待删除的资源文件路径BusiException - 业务逻辑异常(如只读模式)@Comment(value="\u6279\u91cf\u5220\u9664\u914d\u7f6e") public void deleteBatch(String path) throws BusiException
deleteBatch 在接口中 ISohelpBootResourceServicepath - 待删除的资源目录路径BusiException - 业务逻辑异常(如只读模式、路径格式错误)Copyright © 2026. All rights reserved.