{
const { searchKey, current: pageNo, pageSize } = pagination;
- let res = await getDataSourceList({ searchKey, pageNo, pageSize });
+ const res = await getDataSourceList({ searchKey, pageNo, pageSize });
if (res) {
setDataSource(res?.data ?? []);
+ setPagination({
+ ...pagination,
+ total: res?.total ?? 0,
+ } as any);
}
};
@@ -100,7 +110,6 @@ function DataSourceManagement() {
};
const handleTableChange = (p: any) => {
-
setPagination({
...pagination,
...p,
@@ -110,7 +119,7 @@ function DataSourceManagement() {
const handleAddDataSource = () => {
connectionInfo.current = null;
setShowCreateConnection(true);
- }
+ };
const handleEdit = async (record: IDataSourceVO) => {
const { id } = record;
@@ -118,14 +127,14 @@ function DataSourceManagement() {
return;
}
- let detail = await ConnectionServer.getDetails({ id })
+ const detail = await ConnectionServer.getDetails({ id });
connectionInfo.current = detail;
- setShowCreateConnection(true)
- }
+ setShowCreateConnection(true);
+ };
const handleDelete = async (id?: number) => {
if (isNumber(id)) {
- await deleteDataSource({ id })
+ await deleteDataSource({ id });
message.success(i18n('common.text.successfullyDelete'));
queryDataSourceList();
}
@@ -140,14 +149,12 @@ function DataSourceManagement() {
const isUpdate = isValid(connectionInfo?.current?.id);
const requestApi = isUpdate ? updateDataSource : createDataSource;
try {
- await requestApi({ ...connectionInfo.current })
- message.success(isUpdate ? i18n('common.tips.updateSuccess') : i18n('common.tips.createSuccess'))
- setShowCreateConnection(false)
- queryDataSourceList()
- } catch {
-
- }
- }
+ await requestApi({ ...connectionInfo.current });
+ message.success(isUpdate ? i18n('common.tips.updateSuccess') : i18n('common.tips.createSuccess'));
+ setShowCreateConnection(false);
+ queryDataSourceList();
+ } catch {}
+ };
return (
@@ -163,6 +170,11 @@ function DataSourceManagement() {
{
setDrawerInfo({
...drawerInfo,
- open: false
- })
+ open: false,
+ });
}}
/>
-
+
);
}
diff --git a/chat2db-client/src/pages/main/team/index.less b/chat2db-client/src/pages/main/team/index.less
index 3f464307..f6b05a87 100644
--- a/chat2db-client/src/pages/main/team/index.less
+++ b/chat2db-client/src/pages/main/team/index.less
@@ -1,4 +1,9 @@
.teamWrapper {
height: 100vh;
- padding: 24px 36px;
+ padding: 14px 16px;
+ box-sizing: border-box;
+}
+
+.teamTabsBox{
+ height: 100%;
}
diff --git a/chat2db-client/src/pages/main/team/index.tsx b/chat2db-client/src/pages/main/team/index.tsx
index 84b94d17..9ba1c4f9 100644
--- a/chat2db-client/src/pages/main/team/index.tsx
+++ b/chat2db-client/src/pages/main/team/index.tsx
@@ -33,6 +33,7 @@ const Team = () => {
return (
setActiveKey(activeKey)}
items={tabList.map((tab, index) => {
diff --git a/chat2db-client/src/pages/main/team/team-management/index.tsx b/chat2db-client/src/pages/main/team/team-management/index.tsx
index 8db55191..bfe6bf1d 100644
--- a/chat2db-client/src/pages/main/team/team-management/index.tsx
+++ b/chat2db-client/src/pages/main/team/team-management/index.tsx
@@ -17,7 +17,7 @@ const requireRule = { required: true, message: i18n('common.form.error.required'
function TeamManagement() {
const [form] = Form.useForm();
- const [loadding, setLoading] = useState(false)
+ const [loadding, setLoading] = useState(false);
const [dataSource, setDataSource] = useState([]);
const [pagination, setPagination] = useState({
searchKey: '',
@@ -66,7 +66,7 @@ function TeamManagement() {
...drawerInfo,
open: true,
teamId: record.id,
- type: AffiliationType.TEAM_USER
+ type: AffiliationType.TEAM_USER,
});
}}
>
@@ -79,9 +79,10 @@ function TeamManagement() {
...drawerInfo,
open: true,
teamId: record.id,
- type: AffiliationType.TEAM_DATASOURCE
+ type: AffiliationType.TEAM_DATASOURCE,
});
- }}>
+ }}
+ >
{i18n('team.action.affiliation.datasource')}
{
form.scrollToField(errorInfo.errorFields[0].name);
form.setFields(errorInfo.errorFields);
- })
+ });
}}
onCancel={() => {
form.resetFields();
diff --git a/chat2db-client/src/pages/main/team/user-management/index.tsx b/chat2db-client/src/pages/main/team/user-management/index.tsx
index 967fbc12..b827290d 100644
--- a/chat2db-client/src/pages/main/team/user-management/index.tsx
+++ b/chat2db-client/src/pages/main/team/user-management/index.tsx
@@ -116,6 +116,10 @@ function UserManagement() {
let res = await getUserManagementList({ searchKey, pageNo, pageSize });
if (res) {
setDataSource(res?.data ?? []);
+ setPagination({
+ ...pagination,
+ total: res?.total ?? 0,
+ } as any);
}
};
@@ -178,6 +182,11 @@ function UserManagement() {
> headerConsumer,
- Consumer> rowConsumer,ValueHandler valueHandler) {
- executeSql(connection, sql, headerConsumer, rowConsumer, true,valueHandler);
+ Consumer> rowConsumer, ValueHandler valueHandler) {
+ executeSql(connection, sql, headerConsumer, rowConsumer, true, valueHandler);
}
public void executeSql(Connection connection, String sql, Consumer> headerConsumer,
- Consumer> rowConsumer, boolean limitSize,ValueHandler valueHandler) {
+ Consumer> rowConsumer, boolean limitSize, ValueHandler valueHandler) {
Assert.notNull(sql, "SQL must not be null");
log.info("execute:{}", sql);
try (Statement stmt = connection.createStatement();) {
@@ -147,8 +143,8 @@ public class SQLExecutor {
* @return
* @throws SQLException
*/
- public ExecuteResult execute(final String sql, Connection connection,ValueHandler valueHandler) throws SQLException {
- return execute(sql, connection, true, null, null,valueHandler);
+ public ExecuteResult execute(final String sql, Connection connection, ValueHandler valueHandler) throws SQLException {
+ return execute(sql, connection, true, null, null, valueHandler);
}
public ExecuteResult executeUpdate(final String sql, Connection connection, int n)
@@ -162,7 +158,7 @@ public class SQLExecutor {
if (affectedRows != n) {
executeResult.setSuccess(false);
executeResult.setMessage("Update error " + sql + " update affectedRows = " + affectedRows + ", Each SQL statement should update no more than one record. Please use a unique key for updates.");
- // connection.rollback();
+ // connection.rollback();
}
}
return executeResult;
@@ -270,12 +266,12 @@ public class SQLExecutor {
* @return
* @throws SQLException
*/
- public ExecuteResult execute(Connection connection, String sql,ValueHandler valueHandler) throws SQLException {
- return execute(sql, connection, true, null, null,valueHandler);
+ public ExecuteResult execute(Connection connection, String sql, ValueHandler valueHandler) throws SQLException {
+ return execute(sql, connection, true, null, null, valueHandler);
}
public ExecuteResult execute(Connection connection, String sql) throws SQLException {
- return execute(sql, connection, true, null, null,new DefaultValueHandler());
+ return execute(sql, connection, true, null, null, new DefaultValueHandler());
}
/**
@@ -342,8 +338,33 @@ public class SQLExecutor {
*/
public List tables(Connection connection, String databaseName, String schemaName, String tableName,
String types[]) {
- try (ResultSet resultSet = connection.getMetaData().getTables(databaseName, schemaName, tableName,
- types)) {
+
+ try {
+ DatabaseMetaData metadata = connection.getMetaData();
+ ResultSet resultSet = metadata.getTables(databaseName, schemaName, tableName,
+ types);
+ // 如果connection为mysql
+ if ("MySQL".equalsIgnoreCase(metadata.getDatabaseProductName())) {
+ // 获取mysql表的comment
+ List tables = ResultSetUtils.toObjectList(resultSet, Table.class);
+ if (CollectionUtils.isNotEmpty(tables)) {
+ for (Table table : tables) {
+ String sql = "show table status where name = '" + table.getName() + "'";
+ try (Statement stmt = connection.createStatement()) {
+ boolean query = stmt.execute(sql);
+ if (query) {
+ try (ResultSet rs = stmt.getResultSet();) {
+ while (rs.next()) {
+ table.setComment(rs.getString("Comment"));
+ }
+ }
+ }
+ }
+ }
+
+ return tables;
+ }
+ }
return ResultSetUtils.toObjectList(resultSet, Table.class);
} catch (SQLException e) {
throw new RuntimeException(e);