import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs/Rx';
import {Injectable} from '@angular/core';
import {SERVER_API_URL} from '../app.constants';

@Injectable()
export class TopologyService {

    constructor(private http: HttpClient) {
    }

    //查询所有拓扑图
    findAll(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/sysmapJson/findAll');
    }

    //根据拓扑图ID查询
    findItem(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/sysmapJson/find/' + params);
    }

    //创建拓扑图
    create(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/sysmapJson/create' , data);
    }

    //修改拓扑图
    update(data): Observable<any> {
        return this.http.put(SERVER_API_URL + '/sysmapJson/update' , data);
    }

    //删除拓扑图
    delete(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/sysmapJson/delete/' + params);
    }


    getJson():Observable<any>{
        return this.http.get("./network.json ");
    }
}