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

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

  /**
   * 编辑班组
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public editClassGroup(param: object, callBack) {
    this.http.post(environment.baseUrl + 'gasClassGroup/editClassGroup', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 删除班组
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public delClassGroup(groupId: number, callBack) {
    this.http.post(environment.baseUrl + 'gasClassGroup/delClassGroup', { id: groupId}).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 根据id查询详情
   *
   * @param  groupId   班组id
   * @param  callBack   回调
   */
  public getClassGroupById(groupId: number, callBack) {
    this.http.get(environment.baseUrl + 'gasClassGroup/getClassGroupById?groupId=' + groupId).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 查询班组列表
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public getClassGroupList(param: Object, callBack) {
    this.http.get(environment.baseUrl + 'gasClassGroup/getClassGroupList?' + this.common.getWhereCondition(param)).subscribe(data => {
      callBack(data);
    });
  }
}
