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

@Injectable()
export class SystemService {

    constructor(private http: HttpClient,private toTree:ToTree) {
    }

    //角色列表
    role(): Observable<any>{
        return this.http.get(SERVER_API_URL + '/role');
    }

    //编辑角色
    editRole(data): Observable<any>{
        return this.http.put(SERVER_API_URL + '/role',data);
    }

    //新增角色
    addRole(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/role',data);
    }

    //删除用户
    deleteRole(params): Observable<any>{
        return this.http.delete(SERVER_API_URL + '/role/' +params);
    }

    //用户列表
    user(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/user/findUsers',data);
    }

    //新增用户
    adduser(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/user',data);
    }

    //删除用户
    deleteUser(params){
        return this.http.delete(SERVER_API_URL + '/user/'+ params);
    }

    //组织结构列表
    organization(): Observable<any>{
        return this.http.get(SERVER_API_URL + '/organization',);
    }

    //创建组织结构
    createOrg(data): Observable<any>{
        return this.http.post(SERVER_API_URL + '/organization',data);
    }

    //三员分立列表
    separationPowers(): Observable<any>{
        return this.http.get(SERVER_API_URL + '/approval/separationPowers',);
    }

}