import type { NewDataModel } from '@imengyu/js-request-transform';
import type { QueryParams } from '@imengyu/imengyu-utils';
import { CommonContentApi, GetContentListParams } from '../CommonContent';
import VillageApi from '../inhert/VillageApi';

export class VillageContentApi extends CommonContentApi {

  constructor() {
    super(undefined, 18, "闽南节庆日历", 272);
  }

  async getContentList(params: GetContentListParams, page: number, pageSize?: number, modelClassCreator?: NewDataModel, querys?: QueryParams) {
    const res = await this.getCategoryList(151);
    const it2 = res.find(p => p.title == '省级');
    if (it2) it2.title = '传统村落';
    const list = page == 1 ? await VillageApi.getVallageList(it2?.id) : [];
    const searchText = params.keywords;
    list.filter((p) => !searchText || p.title.includes(searchText)).forEach((p) => {
      p.desc = p.desc;
      p.badge = p.district;
      p.bottomTags = [
        p.levelText, 
        p.batchText,
        p.historyLevelText,
      ];
    })
    return { list: list as any, total: list.length }
  }
}

export default new VillageContentApi();
