类 TableService

java.lang.Object
net.sohelp.boot.engine.db.table.service.TableService

@Component public class TableService extends Object
表结构服务类,用于操作数据库中的表结构信息。
从以下版本开始:
2024/2/8 10:10
作者:
AaronFung
  • 构造器详细资料

    • TableService

      public TableService()
  • 方法详细资料

    • getInstance

      public static TableService getInstance()
      获取当前Spring容器中TableService实例。
      返回:
      TableService 实例对象
    • get

      public EntityVO get(String tableName) throws SQLException
      根据表名获取对应的实体信息(使用默认数据源)。
      参数:
      tableName - 数据库表名
      返回:
      EntityVO 对应的实体信息对象
      抛出:
      SQLException - SQL执行异常时抛出
    • get

      public EntityVO get(String key, String tableName) throws SQLException
      根据指定的数据源和表名获取对应的实体信息。
      参数:
      key - 数据源标识符
      tableName - 数据库表名
      返回:
      EntityVO 对应的实体信息对象;若不是MySQL数据库则返回null
      抛出:
      SQLException - SQL执行异常时抛出
    • list

      public List<EntityVO> list(String key) throws SQLException
      获取所有表结构信息列表。
      参数:
      key - 数据源标识符
      返回:
      所有表结构组成的列表
      抛出:
      SQLException - SQL执行异常时抛出
    • list

      public List<EntityVO> list() throws SQLException
      使用默认数据源获取所有表结构信息列表。
      返回:
      所有表结构组成的列表
      抛出:
      SQLException - SQL执行异常时抛出
    • create

      public void create(EntityVO entityVO) throws Exception
      创建或更新一个实体结构到数据库中。
      参数:
      entityVO - 待创建/更新的实体结构对象
      抛出:
      Exception - 操作过程中可能发生的异常
    • dropTable

      public void dropTable(String datasourceName, String tableName) throws SQLException, IOException
      删除指定数据源下的某个表结构。
      参数:
      datasourceName - 数据源名称
      tableName - 表名
      抛出:
      SQLException - SQL执行异常时抛出
      IOException - IO操作异常时抛出
    • dropTable

      public void dropTable(String tableName) throws SQLException, IOException
      删除默认数据源下指定的表结构。
      参数:
      tableName - 表名
      抛出:
      SQLException - SQL执行异常时抛出
      IOException - IO操作异常时抛出
    • exist

      public boolean exist(String tableName) throws SQLException
      判断某张表是否存在。
      参数:
      tableName - 表名
      返回:
      true表示存在,false表示不存在
      抛出:
      SQLException - SQL执行异常时抛出
    • exist

      public boolean exist(String tableName, String fieldName) throws SQLException
      判断某张表中是否存在指定字段。
      参数:
      tableName - 表名
      fieldName - 字段名
      返回:
      true表示存在该字段,false表示不存在
      抛出:
      SQLException - SQL执行异常时抛出