import { Injectable } from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {CommonsService} from './commons.service';
import {environment} from '../../environments/environment';

@Injectable({
  providedIn: 'root'
})
export class DeviceOrderService {

  constructor(
      private http: HttpClient,
      private commonsService: CommonsService
  ) { }

  /**
   * 分配设备订单
   * @param paramObject 参数
   * @param callBack
   */
  assignOrder(paramObject: object, callBack) {
    this.http.post(environment.baseUrl + 'deviceOrder/assignOrder?orderNo', paramObject).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 设备订单详情
   * @param paramObject 参数
   * @param callBack
   */
  getOrderDetail(orderNo: string, callBack) {
    this.http.get(environment.baseUrl + 'deviceOrder/getOrderDetail?orderNo' + orderNo).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 设备订单列表
   * @param paramObject 参数
   * @param callBack
   */
  getOrderList(paramObject: object, callBack) {
    this.http.get(environment.baseUrl + 'deviceOrder/getOrderList?' + this.commonsService.getWhereCondition(paramObject)).subscribe(data => {
      callBack(data);
    });
  }
}
