import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class ApiService {
  // API基础URL
  private baseUrl = 'http://your-api-base-url';

  constructor(private http: HttpClient) { }

  // GET请求示例
  getData(): Observable<any> {
    return this.http.get(`${this.baseUrl}/endpoint`);
  }

  // POST请求示例
  postData(data: any): Observable<any> {
    return this.http.post(`${this.baseUrl}/endpoint`, data);
  }

  // PUT请求示例
  updateData(id: string, data: any): Observable<any> {
    return this.http.put(`${this.baseUrl}/endpoint/${id}`, data);
  }

  // DELETE请求示例
  deleteData(id: string): Observable<any> {
    return this.http.delete(`${this.baseUrl}/endpoint/${id}`);
  }
}