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

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

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

  /**
   * 根据商户id，查询门店列表
   * @param paramObject 参数
   * @param callBack
   */
  getStoreListByMer(paramObject: object, callBack) {
    this.http.get(environment.baseUrl + 'store/getStoreListByMer?' + this.commonsService.getWhereCondition(paramObject)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 根据商户id，查询门店列表
   * @param paramObject 参数
   * @param callBack
   */
  disabledStore(paramObject: object, callBack) {
    this.http.post(environment.baseUrl + 'store/disabledStore', paramObject).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 根据门店id 查询门店详情
   * @param storeId 门店id
   * @param callBack
   */
  getStoreDetailById(storeId: number, callBack) {
    this.http.get(environment.baseUrl + 'store/getStoreDetailById?storeId=' + storeId).subscribe(data => {
      callBack(data);
    });
  }

}
