类 SohelpBootResourceDBServiceImpl

java.lang.Object
net.sohelp.boot.admin.core.service.resource.SohelpBootResourceDBServiceImpl
所有已实现的接口:
ISohelpBootResourceService

public class SohelpBootResourceDBServiceImpl extends Object implements ISohelpBootResourceService
资源数据库服务实现类
从以下版本开始:
2024/7/17 16:40
作者:
AaronFung
  • 构造器详细资料

    • SohelpBootResourceDBServiceImpl

      public SohelpBootResourceDBServiceImpl()
  • 方法详细资料

    • importAll

      public void importAll(List<Map<String,Object>> list) throws BusiException
      从数据库导出所有文件资源信息

      执行SQL查询语句,从pb_sohelp_boot_file表中获取所有文件的路径和内容, 并按文件路径升序排列后返回结果集

      指定者:
      importAll 在接口中 ISohelpBootResourceService
      参数:
      list -
      抛出:
      BusiException
    • exportAll

      public List<Map<String,Object>> exportAll()
      导出所有文件资源信息

      从数据库中查询所有文件路径和文件内容,并按文件路径排序后返回

      指定者:
      exportAll 在接口中 ISohelpBootResourceService
      返回:
      包含文件路径和文件内容的列表,每个元素是一个Map,键为"file_path"和"file_content"
    • exists

      @Comment("\u5224\u65ad\u6587\u4ef6\u662f\u5426\u5b58\u5728") public boolean exists(String filePath)
      判断文件是否存在
      指定者:
      exists 在接口中 ISohelpBootResourceService
      参数:
      filePath - 文件路径
      返回:
      如果文件存在返回true,否则返回false
    • getByPath

      @Comment("\u6839\u636e\u6587\u4ef6\u540d\u83b7\u53d6\u6587\u4ef6\u5185\u5bb9") public com.alibaba.fastjson.JSONObject getByPath(String path)
      根据文件名获取文件内容
      指定者:
      getByPath 在接口中 ISohelpBootResourceService
      参数:
      path - 文件路径
      返回:
      包含文件内容的 JSONObject 对象,如果文件不存在则返回 null
    • getByPath

      @Comment("\u6839\u636e\u8def\u5f84\u83b7\u53d6\u5bf9\u8c61") public <T> T getByPath(String filePath, Class<T> cls) throws BusiException, SQLException
      根据路径获取对象
      指定者:
      getByPath 在接口中 ISohelpBootResourceService
      类型参数:
      T - 目标对象的类型
      参数:
      filePath - 文件路径
      cls - 目标对象的类型
      返回:
      目标对象
      抛出:
      BusiException - 业务异常
      SQLException - SQL异常
    • save

      @Comment("\u4fdd\u5b58\u914d\u7f6e\u8d44\u6e90") public Map<String,Object> save(String filePath, Map<String,Object> formMap) throws SQLException, BusiException
      保存配置资源
      指定者:
      save 在接口中 ISohelpBootResourceService
      参数:
      filePath - 配置文件的路径
      formMap - 表单数据,以键值对的形式存储
      返回:
      保存后的配置资源,以键值对的形式返回
      抛出:
      SQLException - 数据库操作异常
      BusiException - 业务异常
    • save

      @Comment("\u4fdd\u5b58\u914d\u7f6e\u8d44\u6e90") public Map<String,Object> save(String filePath, String fileJson) throws SQLException, BusiException
      保存配置资源。
      指定者:
      save 在接口中 ISohelpBootResourceService
      参数:
      filePath - 文件路径
      fileJson - 文件内容,以JSON格式表示
      返回:
      包含操作结果的Map对象,包括是否成功等信息
      抛出:
      SQLException - 如果数据库操作出现异常,则抛出此异常
      BusiException - 如果业务逻辑处理出现异常,则抛出此自定义异常
    • add

      @Comment("\u521b\u5efa\u914d\u7f6e\u8d44\u6e90") public Map<String,Object> add(String filePath, String fileContent) throws SQLException, BusiException
      创建配置资源
      指定者:
      add 在接口中 ISohelpBootResourceService
      参数:
      filePath - 资源文件的路径
      fileContent - 资源文件的内容
      返回:
      返回包含资源信息的Map对象
      抛出:
      SQLException - 数据库异常
      BusiException - 业务异常
    • renamePath

      @Comment("\u4fee\u6539\u8def\u5f84") public void renamePath(String srcFilePath, String newFilePath) throws SQLException, BusiException
      修改路径
      指定者:
      renamePath 在接口中 ISohelpBootResourceService
      参数:
      srcFilePath - 原路径
      newFilePath - 新路径
      抛出:
      SQLException - SQL异常
      BusiException - 业务异常
    • updateByPath

      @Comment("\u66f4\u65b0\u914d\u7f6e\u8d44\u6e90") public Map<String,Object> updateByPath(String filePath, String fileContent) throws SQLException, BusiException
      更新配置资源
      指定者:
      updateByPath 在接口中 ISohelpBootResourceService
      参数:
      filePath - 配置资源的路径,例如: filePath=/datasource/32932032009329
      fileContent - 配置资源的内容
      返回:
      更新后的数据映射,包含file_path和file_content
      抛出:
      SQLException - 如果数据库操作出现异常
      BusiException - 如果资源设置为只读模式,抛出异常
    • listByRegex

      public List<com.alibaba.fastjson.JSONObject> listByRegex(String filePath, String regex) throws SQLException
      通过正则表达式从指定路径下筛选出符合条件的JSON对象列表
      指定者:
      listByRegex 在接口中 ISohelpBootResourceService
      参数:
      filePath - 指定路径
      regex - 正则表达式
      返回:
      符合正则表达式的JSON对象列表
      抛出:
      SQLException - SQL异常
    • listByPath

      @Comment("\u8bfb\u53d6\u914d\u7f6e\u8d44\u6e90") public List<com.alibaba.fastjson.JSONObject> listByPath(String filePath)
      读取配置资源,列出当前目录的资源
      指定者:
      listByPath 在接口中 ISohelpBootResourceService
      参数:
      filePath - 资源路径
      返回:
      返回资源列表,每个资源为一个JSONObject对象
    • listByPath

      @Comment("\u8bfb\u53d6\u914d\u7f6e\u8d44\u6e90") public <T> List<T> listByPath(String filePath, Class<T> cls) throws SQLException
      根据给定的文件路径和类类型读取配置资源,并将其转换为指定类型的对象列表。
      指定者:
      listByPath 在接口中 ISohelpBootResourceService
      类型参数:
      T - 返回对象列表的类型
      参数:
      filePath - 文件路径
      cls - 要转换成的类类型
      返回:
      指定类型的对象列表
      抛出:
      SQLException - 如果读取文件或转换对象时发生SQL异常
    • listByRegex

      @Comment("\u6839\u636e\u7ed9\u5b9a\u7684\u6587\u4ef6\u8def\u5f84\u548c\u7c7b\u7c7b\u578b\u8bfb\u53d6\u914d\u7f6e\u8d44\u6e90\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u6307\u5b9a\u7c7b\u578b\u7684\u5bf9\u8c61\u5217\u8868\u3002") public <T> List<T> listByRegex(String filePath, String regex, Class<T> cls) throws SQLException
      根据给定的文件路径、正则表达式和类类型读取配置资源,并将其转换为指定类型的对象列表。
      指定者:
      listByRegex 在接口中 ISohelpBootResourceService
      类型参数:
      T - 返回对象列表的类型
      参数:
      filePath - 文件路径
      regex - 正则表达式
      cls - 要转换成的类类型
      返回:
      指定类型的对象列表
      抛出:
      SQLException - 如果读取文件或转换对象时发生SQL异常
    • deleteByPath

      @Comment("\u6839\u636e\u6587\u4ef6\u8def\u5f84\u5220\u9664\u914d\u7f6e\u8d44\u6e90") public void deleteByPath(String filePath) throws BusiException
      根据文件路径删除配置资源。
      指定者:
      deleteByPath 在接口中 ISohelpBootResourceService
      参数:
      filePath - 文件路径
      抛出:
      BusiException - 如果删除过程中发生业务异常,则抛出此异常
    • deleteBatch

      @Comment("\u8981\u5220\u9664\u8d44\u6e90\u7684\u8def\u5f84\u524d\u7f00") public void deleteBatch(String filePath) throws BusiException
      删除所有匹配的资源
      指定者:
      deleteBatch 在接口中 ISohelpBootResourceService
      参数:
      filePath - 要删除资源的路径前缀
      抛出:
      BusiException - 如果发生业务异常时抛出