57 lines
2.2 KiB
TypeScript
57 lines
2.2 KiB
TypeScript
/*
|
|
* This file is part of the kernelstudio package.
|
|
*
|
|
* (c) 2014-2026 zlin <admin@kernelstudio.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE file
|
|
* that was distributed with this source code.
|
|
*/
|
|
|
|
import { HttpRequestClient } from '@/utils/request';
|
|
import type { Scenario, ScenarioDetailsResponse, ScenarioPageableResponse, ScenarioRequest, CommunicationRelationsResponse } from './types';
|
|
import type { PlatformWithComponentsResponse } from '../types';
|
|
import type { BasicResponse } from '@/types';
|
|
import type { BehaviorTree } from '../designer/tree';
|
|
|
|
const req = HttpRequestClient.create<BasicResponse>({
|
|
baseURL: '/api',
|
|
});
|
|
|
|
export const findScenarioByQuery = (_query: Partial<ScenarioRequest> = {}): Promise<ScenarioPageableResponse> => {
|
|
return req.get<ScenarioPageableResponse>('/system/scene/list', _query);
|
|
};
|
|
|
|
export const findOneScenarioById = (id: number): Promise<ScenarioDetailsResponse> => {
|
|
return req.get<ScenarioDetailsResponse>(`/system/scene/${id}`);
|
|
};
|
|
|
|
export const deleteOneScenarioById = (id: number): Promise<BasicResponse> => {
|
|
return req.delete<BasicResponse>(`/system/behaviortree/${id}`);
|
|
};
|
|
|
|
export const findPlatformWithComponents = (id: number): Promise<PlatformWithComponentsResponse> => {
|
|
return req.get<PlatformWithComponentsResponse>(`/system/firerule/platforms/${id}`);
|
|
};
|
|
|
|
/**
|
|
* 获取场景的所有通信关系
|
|
* @param id 场景ID
|
|
* @returns 通信关系列表
|
|
*/
|
|
export const findRelations = (id: number): Promise<CommunicationRelationsResponse> => {
|
|
return req.get<CommunicationRelationsResponse>(`/system/scene/getAllRelation/${id}`);
|
|
};
|
|
|
|
export const saveScenario = (scenario: Scenario): Promise<BasicResponse> => {
|
|
return req.postJson<BasicResponse>(`/system/scene/saveSceneConfig`,scenario);
|
|
};
|
|
|
|
// 获取场景下的所有行为树列表
|
|
export const getAllBehaviorTreesBySceneId = (sceneId: number): Promise<{ code: number; msg: string; data: BehaviorTree[] }> => {
|
|
return req.get<{ code: number; msg: string; data: BehaviorTree[] }>(`/system/scene/getAllTree/${sceneId}`);
|
|
};
|
|
|
|
// 更新行为树(挂载到平台)
|
|
export const updateBehaviorTree = (behaviorTree: BehaviorTree): Promise<BasicResponse> => {
|
|
return req.putJson<BasicResponse>(`/system/behaviortree`, behaviorTree);
|
|
}; |