2026-03-14 21:37:07 +08:00
|
|
|
/*
|
|
|
|
|
* 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';
|
2026-04-14 17:27:31 +08:00
|
|
|
import type { Scenario, ScenarioDetailsResponse, ScenarioPageableResponse, ScenarioRequest, CommunicationRelationsResponse } from './types';
|
2026-03-16 22:43:12 +08:00
|
|
|
import type { PlatformWithComponentsResponse } from '../types';
|
2026-03-14 21:37:07 +08:00
|
|
|
import type { BasicResponse } from '@/types';
|
2026-04-14 15:09:50 +08:00
|
|
|
import type { BehaviorTree } from '../designer/tree';
|
2026-03-14 21:37:07 +08:00
|
|
|
|
|
|
|
|
const req = HttpRequestClient.create<BasicResponse>({
|
|
|
|
|
baseURL: '/api',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export const findScenarioByQuery = (_query: Partial<ScenarioRequest> = {}): Promise<ScenarioPageableResponse> => {
|
2026-03-31 11:10:43 +08:00
|
|
|
return req.get<ScenarioPageableResponse>('/system/scene/list', _query);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const findOneScenarioById = (id: number): Promise<ScenarioDetailsResponse> => {
|
|
|
|
|
return req.get<ScenarioDetailsResponse>(`/system/scene/${id}`);
|
2026-03-14 21:37:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const deleteOneScenarioById = (id: number): Promise<BasicResponse> => {
|
2026-03-31 11:10:43 +08:00
|
|
|
return req.delete<BasicResponse>(`/system/behaviortree/${id}`);
|
2026-03-14 22:35:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const findPlatformWithComponents = (id: number): Promise<PlatformWithComponentsResponse> => {
|
2026-03-31 11:10:43 +08:00
|
|
|
return req.get<PlatformWithComponentsResponse>(`/system/firerule/platforms/${id}`);
|
2026-03-15 19:32:20 +08:00
|
|
|
};
|
|
|
|
|
|
2026-04-14 17:27:31 +08:00
|
|
|
/**
|
|
|
|
|
* 获取场景的所有通信关系
|
|
|
|
|
* @param id 场景ID
|
|
|
|
|
* @returns 通信关系列表
|
|
|
|
|
*/
|
|
|
|
|
export const findRelations = (id: number): Promise<CommunicationRelationsResponse> => {
|
|
|
|
|
return req.get<CommunicationRelationsResponse>(`/system/scene/getAllRelation/${id}`);
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-15 19:32:20 +08:00
|
|
|
export const saveScenario = (scenario: Scenario): Promise<BasicResponse> => {
|
2026-03-31 11:10:43 +08:00
|
|
|
return req.postJson<BasicResponse>(`/system/scene/saveSceneConfig`,scenario);
|
2026-04-14 15:09:50 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 获取场景下的所有行为树列表
|
|
|
|
|
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);
|
2026-03-14 21:37:07 +08:00
|
|
|
};
|