12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import { Injectable } from '@nestjs/common'
- import { ServiceResponse } from '@/response/response.interface'
- import { HttpClientService } from '@/shared/http-client/http-client.service'
- @Injectable()
- export class AgentListHttpService {
- private readonly baseUrl = 'http://192.168.206.189:8083/api'
- constructor(private readonly httpClientService: HttpClientService) {}
- private async makeRequest<T>(
- endpoint: string,
- params?: Record<string, any>
- ): Promise<ServiceResponse<T>> {
- const url = `${this.baseUrl}/${endpoint}`
- return this.httpClientService.get<T>(url, params)
- }
- async makeRequestPost<T>(
- endpoint: string,
- params?: Record<string, any>
- ): Promise<ServiceResponse<T>> {
- const url = `${this.baseUrl}/${endpoint}`
- return this.httpClientService.post<T>(url, params)
- }
- async getNativeAgentList(
- params: Record<string, any>
- ): Promise<ServiceResponse<AgentListType[]>> {
- return this.makeRequest<AgentListType[]>('getNativeAgentList', params)
- }
- async getNativeAgentConfiguration(
- agent_id: string
- ): Promise<ServiceResponse<AgentConfigurationType[]>> {
- return this.makeRequest<AgentConfigurationType[]>(
- 'getNativeAgentConfiguration',
- { agent_id }
- )
- }
- async saveNativeAgentConfiguration(
- params: SaveAgentConfigurationType
- ): Promise<ServiceResponse<SaveAgentConfigurationType>> {
- console.log(params)
- return this.makeRequestPost<SaveAgentConfigurationType>(
- 'saveNativeAgentConfiguration',
- params
- )
- }
- async getToolList(): Promise<ServiceResponse<any>> {
- return this.makeRequest<any>('getToolList')
- }
- async deleteNativeAgentConfiguration(
- agent_id: number
- ): Promise<ServiceResponse<any>> {
- return this.makeRequestPost<any>('deleteNativeAgentConfiguration', {
- agent_id
- })
- }
- }
|