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

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

  /**
   * 编辑版本
   * @param object
   * @param callBack
   */
  editVersion(object: object, callBack) {
    this.http.post(environment.baseUrl + 'sysVersion/editVersion', object).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 发布版本
   * @param id
   * @param callBack
   */
  releaseVersion(id: number, callBack) {
    this.http.get(environment.baseUrl + 'sysVersion/releaseVersion?id=' + id).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 删除版本
   * @param id
   * @param callBack
   */
  delVersion(id: number, callBack) {
    this.http.get(environment.baseUrl + 'sysVersion/delVersion?id=' + id).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 查询版本列表
   * @param paramObject
   * @param callBack
   */
  getVersionList(paramObject: object, callBack) {
    this.http.get(environment.baseUrl + 'sysVersion/getVersionList?' + this.commonsService.getWhereCondition(paramObject)).subscribe(data => {
      callBack(data);
    });
  }

}
