import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class PortalService {

  constructor(private http : HttpClient) { }

  // 获取portal
  apiGetPortal(product: string, lang: string = 'zh') {
    return this.http.get(`/napi/coloring/mobi/${product}/portal?lang=${lang}`);
  }

  // 获取所有专辑
  apiAlbumAll(product: string, lang: string = 'zh') {
    return this.http.get(`/napi/coloring/mobi/${product}/album/all?lang=${lang}`);
  }

  // 获取专辑详情
  apiAlbumDetail(albumId: string, lang: string = 'zh') {
    return this.http.get(`/napi/coloring/mobi/album/${albumId}?lang=${lang}`);
  }

  // 获取所有收集
  apiCollectionmAll(product: string, lang: string = 'zh') {
    return this.http.get(`/napi/coloring/mobi/${product}/collection/all?lang=${lang}`);
  }

  // 获取收集详情
  apiCollectionDetail(collectionId: string, lang: string = 'zh') {
    return this.http.get(`/napi/coloring/mobi/collection/${collectionId}?lang=${lang}`);
  }

  // 获取daily列表
  apiDailyList(product: string) {
    return this.http.get(`/napi/coloring/mobi/${product}/daily`);
  }

  // 获取banner列表
  apiBannerList() {
    return this.http.get(`/napi/coloring/mobi/list/banner?nocache=1`);
  }

  // v7接口 客户端获取栏目内容
  apiEpgContentList(epgId: string, colId: string) {
    return this.http.get(`/napi/number/v7/list/${epgId}/content?column=${colId}`);
  }

  // banner 表头
  bannerHeaders() {
    return this.http.get('/napi/coloring/web/banner/headers');
  }

  // 获取所有banner
  bannerAll() {
    return this.http.get('/napi/coloring/web/banner/all');
  }

  // 更新banner
  bannerUpdate(data: FormData, id: string) {
    return this.http.patch(`/napi/coloring/web/banner/${id}`, data);
  }

  // 批量更新banner
  batchBannerUpdate(product: string, data: any) {
    return this.http.patch(`/napi/coloring/web/banner/${product}/update`, data);
  }

  // 添加banner
  bannerAdd(data) {
    return this.http.post('/napi/coloring/web/banner/', data);
  }

  // 删除banner
  bannerRemove(id) {
    return this.http.delete(`/napi/coloring/web/banner/${id}`);
  }


  getPortal(product: string) {
    return this.http.get(`/napi/coloring/web/portal/${product}`);
  }

  updatePortal(product: string, data) {
    return this.http.patch(`/napi/coloring/web/portal/${product}`, data);
  }


  translateOptions() {
    return this.http.get('/napi/web/translate/options');
  }

  epgOption() {
    return this.http.get('/napi/web/epg/options');
  }

  epgAll() {
    return this.http.get('/napi/web/epg/all');
  }
}
