= props => {
+ return ;
};
export default IconFont;
diff --git a/threadpool/console-new/src/components/with-button/index.tsx b/threadpool/console-new/src/components/with-button/index.tsx
new file mode 100644
index 00000000..0ec5c460
--- /dev/null
+++ b/threadpool/console-new/src/components/with-button/index.tsx
@@ -0,0 +1,27 @@
+import { Button, ButtonProps } from 'antd';
+import React from 'react';
+import { SearchOutlined, PlusOutlined, RedoOutlined } from '@ant-design/icons';
+
+function withSearchIconButton(WrappedComponent: React.ComponentType
) {
+ return function EnhancedComponent(props: P) {
+ return } {...props} />;
+ };
+}
+
+function withAddIconButton(WrappedComponent: React.ComponentType
) {
+ return function EnhancedComponent(props: P) {
+ return } {...props}>
;
+ };
+}
+
+function withResetIconButton
(WrappedComponent: React.ComponentType
) {
+ return function EnhancedComponent(props: P) {
+ return }>;
+ };
+}
+
+export const SearchButton = withSearchIconButton(Button);
+
+export const AddButton = withAddIconButton(Button);
+
+export const ResetButton = withResetIconButton(Button);
diff --git a/threadpool/console-new/src/page/thread-pool/index.tsx b/threadpool/console-new/src/page/thread-pool/index.tsx
index ed2dc227..813e31d7 100644
--- a/threadpool/console-new/src/page/thread-pool/index.tsx
+++ b/threadpool/console-new/src/page/thread-pool/index.tsx
@@ -1,14 +1,18 @@
-import { Button, Form, Select, Space, Table, Typography } from 'antd';
+import { Form, Select, Space, Table, Typography } from 'antd';
import { useFormStateToUrl, useTran } from '@/hooks';
import { STR_MAP } from '@/config/i18n/locales/constants';
import { ColumnProps } from 'antd/es/table';
+import { SearchButton, AddButton } from '@/components/with-button';
+import { useAntdTable } from 'ahooks';
+import service, { Result, ThreadPoolTableBody } from './service';
const { Title } = Typography;
const { Item } = Form;
+const paramsType = { project: 0, thpool: 0 };
-const params = { project: 0, thpool: 0 };
const ThreadPoll = () => {
const [form] = Form.useForm();
- const { handleSetUrlState } = useFormStateToUrl<{ project: number; thpool: number }>(form, params);
+
+ const { handleSetUrlState } = useFormStateToUrl<{ project: number; thpool: number }>(form, paramsType);
const columns: ColumnProps[] = [
{
title: useTran(STR_MAP.SERIAL_NUMBER),
@@ -44,7 +48,7 @@ const ThreadPoll = () => {
},
{
title: useTran(STR_MAP.ALARM_OR_NOT),
- dataIndex: 'tenantry',
+ dataIndex: 'allowCoreThreadTimeOut',
},
{
title: useTran(STR_MAP.CREATION_TIME),
@@ -60,14 +64,29 @@ const ThreadPoll = () => {
},
];
- const handleSubmit = () => {
- handleSetUrlState();
+ const getTableData = (): Promise => {
+ return service.fetchThreadPoolTable({
+ current: 1,
+ size: 10,
+ tpId: '',
+ itemId: '',
+ });
};
+ const { tableProps, search } = useAntdTable(getTableData, {
+ defaultPageSize: 5,
+ form: form,
+ });
+
+ const { submit } = search;
+
return (
{useTran(STR_MAP.THREAD_POOL)}
-
+
);
};
diff --git a/threadpool/console-new/src/page/thread-pool/service.ts b/threadpool/console-new/src/page/thread-pool/service.ts
new file mode 100644
index 00000000..528a36ea
--- /dev/null
+++ b/threadpool/console-new/src/page/thread-pool/service.ts
@@ -0,0 +1,16 @@
+import request from '@/utils';
+
+const fetchThreadPoolTable = async (body: ThreadPoolTableBody): Promise => {
+ const { data } = await request('/hippo4j/v1/cs/thread/pool/query/page', {
+ method: 'POST',
+ body,
+ });
+ return {
+ total: data?.total,
+ list: data?.records,
+ };
+};
+
+export default {
+ fetchThreadPoolTable,
+};
diff --git a/threadpool/console-new/src/page/thread-pool/type.ts b/threadpool/console-new/src/page/thread-pool/type.ts
new file mode 100644
index 00000000..f7288bfc
--- /dev/null
+++ b/threadpool/console-new/src/page/thread-pool/type.ts
@@ -0,0 +1,123 @@
+import { Params } from 'ahooks/lib/useAntdTable/types';
+
+// body
+export interface ThreadPoolTableBody extends Params {
+ /**
+ * current page
+ */
+ current: number;
+ /**
+ * project id
+ */
+ itemId?: string;
+ /**
+ * page size
+ */
+ size: number;
+ /**
+ *tenant Id
+ */
+ tenantId?: string;
+ /**
+ * thread pool ID
+ */
+ tpId?: string;
+}
+
+export interface Record {
+ /**
+ * 是否超时
+ */
+ allowCoreThreadTimeOut?: number;
+ /**
+ * 队列容量
+ */
+ capacity?: number;
+ /**
+ * 容量报警
+ */
+ capacityAlarm?: number;
+ /**
+ * 核心线程数
+ */
+ coreSize?: number;
+ /**
+ * 执行超市
+ */
+ executeTimeOut?: number;
+ /**
+ * 创建时间
+ */
+ gmtCreate?: string;
+ /**
+ * 修改时间
+ */
+ gmtModified?: string;
+ /**
+ * ID
+ */
+ id?: string;
+ /**
+ * 是否报警
+ */
+ isAlarm?: number;
+ /**
+ * 项目ID
+ */
+ itemId?: string;
+ /**
+ * 空闲回收
+ */
+ keepAliveTime?: number;
+ /**
+ * 活跃度报警
+ */
+ livenessAlarm?: number;
+ /**
+ * 最大线程数
+ */
+ maxSize?: number;
+ /**
+ * 队列名称
+ */
+ queueName?: null;
+ /**
+ * 队列类型
+ */
+ queueType?: number;
+ /**
+ * 拒绝策略类型
+ */
+ rejectedType?: number;
+ /**
+ * 租户ID
+ */
+ tenantId?: string;
+ /**
+ * 线程池ID
+ */
+ tpId?: string;
+}
+
+export interface ThreadPoolTableRes {
+ countId: null;
+ current: number;
+ desc: boolean;
+ hitCount: boolean;
+ itemId: string;
+ maxLimit: null;
+ optimizeCountSql: boolean;
+ orders: string[];
+ pages: number;
+ records: Record[];
+ searchCount: boolean;
+ size: number;
+ tenantId: string;
+ total: number;
+ tpId: string;
+}
+
+export interface Result {
+ total: number;
+ list: Record[];
+}
diff --git a/threadpool/console-new/src/utils/request/index.ts b/threadpool/console-new/src/utils/request/index.ts
index 7a537a87..314c7aa1 100644
--- a/threadpool/console-new/src/utils/request/index.ts
+++ b/threadpool/console-new/src/utils/request/index.ts
@@ -24,7 +24,7 @@ interface RequestOptions {
type Response = {
success: boolean;
- data?: T;
+ data: T;
module?: T;
msg?: string;
status?: number;
@@ -41,8 +41,11 @@ const inital: RequestOptions = {
headers: {
'Content-Type': 'application/json',
Authorization:
- 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxMCxiYW94aW55aV91c2VyIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTU3MzAwNzYsImlhdCI6MTY5NTEyNTI3Niwicm9sIjoiUk9MRV9VU0VSIn0.4cWyhllP7u-aoRAIHs3nMggsgl4-LUCVBas8WE0FJYIe-YNS0wGf1_0RJq3TUGw00KmSaSRPKdoPgRTFqEphZA',
+ 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxMCxiYW94aW55aV91c2VyIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTU4MjY1ODQsImlhdCI6MTY5NTIyMTc4NCwicm9sIjoiUk9MRV9VU0VSIn0.HQx33P1hlZK2-0omlUt58kpa77OxiGdW-jLV4GWbbLIFf86y8-0IOdeu8gzMwMWUTRtrwp2_YWMl_05TVlDJbA',
+ cookie:
+ 'Admin-Token=Bearer%20eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3LGJhb3hpbnlpX2FkbWluIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTUzOTg4NDksImlhdCI6MTY5NDc5NDA0OSwicm9sIjoiUk9MRV9BRE1JTiJ9.syRDshKpd-xETsSdeMPRtk956f4BJkPt4utVsUl4smgH71Woj8SUq4w2RX1YtGTC4aTZRJYdKOfkTqwK0g_dHQ; userName=baoxinyi_admin',
},
+ // headers,
credentials: true,
responseType: 'JSON',
cache: 'no-cache',
@@ -85,7 +88,10 @@ function request(url: string, config: RequestOptions): Promise> {
}
if (config.headers && isPlainObject(config.headers)) {
config.headers = Object.assign({}, inital.headers, config.headers);
+ } else {
+ config.headers = inital.headers;
}
+
let { method, params, body, headers, credentials, responseType } = Object.assign({}, inital, config) as any;
if (typeof url !== 'string') throw new TypeError('url is not an string');
if (!/^http(s?):\/\//i.test(url)) url = baseURL + url;