import { CommonContentApi, GetContentListItem, GetContentListParams } from '../CommonContent';

export class CalendarListItem extends GetContentListItem {
  constructor() {
    super();

    this._nameMapperServer = {
      lunar: 'date',
      lunar_date: 'dateString',
    }
    const old = this._afterSolveServer;
    this._afterSolveServer = (data) => {
      old?.(data);
      const date = new Date(this.date);
      this.dateObj = date;
      this.dateYear = date.getFullYear();
      this.dateMonth = date.getMonth() + 1;
    }
  }
  date = '';
  dateString = '';
  dateObj = new Date();
  dateYear = 0;
  dateMonth = 0;
}

export class CalendarContentApi extends CommonContentApi {

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

  getCalendarList(params: GetContentListParams, page: number, pageSize?: number) {
    return super.getContentList<CalendarListItem>(params, page, pageSize, CalendarListItem);
  }
}

export default new CalendarContentApi();
