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 GasStaffService {

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

  /**
   * 禁用油品
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public addStaff(param: object, callBack) {
    this.http.post(environment.baseUrl + 'gasStaff/addGasStaff', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 禁用油品
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public updateStaff(param: object, callBack) {
    this.http.post(environment.baseUrl + 'gasStaff/updateGasStaff', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 禁用
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public disabled(param: object, callBack) {
    this.http.post(environment.baseUrl + 'gasStaff/disabled', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 恢复
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public recover(param: object, callBack) {
    this.http.post(environment.baseUrl + 'gasStaff/recover', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 删除
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public delStaff(param: object, callBack) {
    this.http.post(environment.baseUrl + 'gasStaff/delStaff', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 禁用油品
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public getStaffDetail(staffId: number, callBack) {
    this.http.get(environment.baseUrl + 'gasStaff/getStaffDetail?staffId=' + staffId).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 禁用油品
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public getStaffList(param: object, callBack) {
    this.http.get(environment.baseUrl + 'gasStaff/getStaffList?' + this.common.getWhereCondition(param)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 查询二维码
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public queryQrCode(param: object, callBack) {
    this.http.post(environment.baseUrl + 'gasStaff/queryQrCode', param).subscribe(data => {
      callBack(data);
    });
  }
}
