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

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


  /**
   * 批量增加任务
   *
   * @param  paramsObject   对象
   * @param  callBack   回调
   */
  public batchAddTask(paramsObject: object, callBack) {
    this.http.post(environment.baseUrl + 'gasOilPriceTask/batchAddTask', paramsObject).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 删除任务
   *
   * @param  id         任务id
   * @param  callBack   回调
   */
  public delTask(id: number, callBack) {
    this.http.post(environment.baseUrl + 'gasOilPriceTask/delTask', { taskId: id }).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 批量增加任务
   *
   * @param  paramsObject   对象
   * @param  callBack   回调
   */
  public getTaskDetail(id: number, callBack) {
    this.http.get(environment.baseUrl + 'gasOilPriceTask/getTaskDetail?taskId=' + id).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 批量增加任务
   *
   * @param  paramsObject   对象
   * @param  callBack   回调
   */
  public getTaskList(param: object, callBack) {
    this.http.get(environment.baseUrl + 'gasOilPriceTask/getTaskList?' + this.common.getWhereCondition(param)).subscribe(data => {
      callBack(data);
    });
  }
}
