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

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

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

  /**
   * 导入设备
   * @param paramObject 参数
   * @param callBack
   */
  importDevice(paramObject: object, callBack) {
    this.http.post(environment.baseUrl + 'device/importDevice', paramObject).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 分配公司
   * @param paramObject 参数
   * @param callBack
   */
  assignCompany(paramObject: object, callBack) {
    this.http.post(environment.baseUrl + 'device/assignCompany', paramObject).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 分配代理商
   * @param paramObject 参数
   * @param callBack
   */
  assignAgent(paramObject: object, callBack) {
    this.http.post(environment.baseUrl + 'device/assignAgent', paramObject).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 分配业务员
   * @param paramObject 参数
   * @param callBack
   */
  assignSalesman(paramObject: object, callBack) {
    this.http.post(environment.baseUrl + 'device/assignSalesman', paramObject).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 解绑门店
   * @param paramObject 参数
   * @param callBack
   */
  unbindStore(paramObject: object, callBack) {
    this.http.post(environment.baseUrl + 'device/unbindStore', paramObject).subscribe(data => {
      callBack(data);
    });
  }

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

  /**
   * 删除设备
   * @param paramObject 参数
   * @param callBack
   */
  delDevice(paramObject: object, callBack) {
    this.http.post(environment.baseUrl + 'device/delDevice', paramObject).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 启用设备
   * @param paramObject 参数
   * @param callBack
   */
  enableDevice(paramObject: object, callBack) {
    this.http.post(environment.baseUrl + 'device/enableDevice', paramObject).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 停用设备
   * @param paramObject 参数
   * @param callBack
   */
  disableDevice(paramObject: object, callBack) {
    this.http.post(environment.baseUrl + 'device/disableDevice', paramObject).subscribe(data => {
      callBack(data);
    });
  }

}
