Quellcode durchsuchen

新增数据库管理服务接口

周浩 vor 9 Jahren
Ursprung
Commit
72daae9e69

+ 35 - 0
hsweb-web-service-interface/src/main/java/org/hsweb/web/service/system/DataBaseManagerService.java

@@ -0,0 +1,35 @@
+package org.hsweb.web.service.system;
+
+import org.hsweb.web.bean.common.database.TableField;
+
+import java.util.List;
+
+/**
+ * 数据库管理服务,用于获取数据库中的表结构等操作
+ * Created by zhouhao on 16-4-21.
+ */
+public interface DataBaseManagerService {
+
+    /**
+     * 获取当前数据源中所有的表名
+     *
+     * @return 表名集合
+     */
+    List<String> getTableNameList();
+
+    /**
+     * 获取数据库表的字段信息
+     *
+     * @param tableName 数据库表名
+     * @return 字段集合
+     */
+    List<TableField> getFieldList(String tableName);
+
+    /**
+     * 执行sql语句,多条sql语句使用[;\n]分割
+     *
+     * @param sql     sql语句
+     * @param process 执行过程回调,每执行一个sql都应该调用对应的回调方法
+     */
+    void executeSQL(String sql, SqlExecuteProcess process) throws Exception;
+}

+ 30 - 0
hsweb-web-service-interface/src/main/java/org/hsweb/web/service/system/SqlExecuteProcess.java

@@ -0,0 +1,30 @@
+package org.hsweb.web.service.system;
+
+/**
+ * SQL执行过程
+ * Created by zhouhao on 16-4-21.
+ */
+public interface SqlExecuteProcess {
+    /**
+     * 执行sql前
+     *
+     * @param sql
+     */
+    void before(String sql);
+
+    /**
+     * 执行sql后
+     *
+     * @param sql    被执行的sql语句
+     * @param result 执行结果
+     */
+    void after(String sql, Object result);
+
+    /**
+     * 执行sql失败
+     *
+     * @param sql       被执行的sql语句
+     * @param throwable 执行失败异常信息
+     */
+    void error(String sql, Throwable throwable);
+}