🔨 优化主机逻辑.

This commit is contained in:
lijiahang
2025-03-28 14:34:51 +08:00
parent 6b5c7fd409
commit 986f0974db
29 changed files with 1569 additions and 1051 deletions

View File

@@ -1,5 +1,6 @@
import type { DataGrid, OrderDirection, Pagination } from '@/types/global';
import type { HostSpecExtraModel } from './host-extra';
import type { TableData } from '@arco-design/web-vue';
import type { DataGrid, OrderDirection, Pagination } from '@/types/global';
import axios from 'axios';
import qs from 'query-string';
@@ -10,15 +11,15 @@ export type HostType = 'SSH' | string | undefined;
* 主机创建请求
*/
export interface HostCreateRequest {
type?: string;
types?: Array<string>;
osType?: string;
archType?: string;
name?: string;
code?: string;
address?: string;
port?: number;
description?: string;
tags?: Array<number>;
groupIdList?: Array<number>;
description?: string;
}
/**
@@ -36,14 +37,6 @@ export interface HostUpdateStatusRequest {
status: string;
}
/**
* 主机更新配置请求
*/
export interface HostUpdateConfigRequest {
id: number;
config: string;
}
/**
* 主机查询请求
*/
@@ -52,12 +45,15 @@ export interface HostQueryRequest extends Pagination, OrderDirection {
id?: number;
type?: string;
osType?: string;
archType?: string;
name?: string;
code?: string;
address?: string;
status?: string;
tags?: Array<number>;
queryTag?: boolean;
queryGroup?: boolean;
querySpec?: boolean;
description?: string;
}
@@ -66,13 +62,14 @@ export interface HostQueryRequest extends Pagination, OrderDirection {
*/
export interface HostQueryResponse extends TableData, HostQueryResponseExtra {
id: number;
type: string;
osType?: string;
types: Array<string>;
osType: string;
archType: string;
name: string;
code: string;
address: string;
port: string;
status: string;
description: string;
createTime: number;
updateTime: number;
creator: string;
@@ -82,7 +79,7 @@ export interface HostQueryResponse extends TableData, HostQueryResponseExtra {
color: string;
tags: Array<{ id: number, name: string }>;
groupIdList: Array<number>;
description: string;
spec: HostSpecExtraModel;
}
/**
@@ -92,22 +89,15 @@ export interface HostQueryResponseExtra {
editable: boolean;
loading: boolean;
modCount: number;
extra?: Record<string, any>;
}
/**
* 主机 配置查询响应
* 主机测试连接请求
*/
export interface HostConfigQueryResponse extends HostConfigQueryResponseExtra {
export interface HostTestConnectRequest {
id: number;
type: string;
config: Record<string, any>;
}
/**
* 主机配置拓展
*/
export interface HostConfigQueryResponseExtra {
current: number;
}
/**
@@ -131,13 +121,6 @@ export function updateHostStatus(request: HostUpdateStatusRequest) {
return axios.put('/asset/host/update-status', request);
}
/**
* 通过 id 更新主机配置
*/
export function updateHostConfig(request: HostUpdateConfigRequest) {
return axios.put('/asset/host/update-config', request);
}
/**
* 查询主机
*/
@@ -152,13 +135,6 @@ export function getHostList(type: HostType) {
return axios.get<Array<HostQueryResponse>>('/asset/host/list', { params: { type } });
}
/**
* 通过 id 查询主机配置
*/
export function getHostConfig(id: number) {
return axios.get<HostConfigQueryResponse>('/asset/host/get-config', { params: { id } });
}
/**
* 分页查询主机
*/
@@ -191,3 +167,10 @@ export function batchDeleteHost(idList: Array<number>) {
}
});
}
/**
* 测试连接主机
*/
export function testHostConnect(request: HostTestConnectRequest) {
return axios.post('/asset/host/test-connect', request, { timeout: 60000 });
}