import { schoolMainFetch, ResponseDataEntity } from '.';

class Parmas {
  campusId: number;
  customerId: number;
}
export class SectionItem {
  id: number;
  styleType: string;
  name: string;
  titleTypeRemark: string;
  titleType: string;
  titleContent: string;
  sort: number;
  updateTime: number;
  itemsCount: number;
  items: AnnItem[];
}
class Response {
  campusId: number;
  sections: SectionItem[];
}
export const fetchAnn = (data: Parmas) =>
  schoolMainFetch({
    url: '/dcxy/wechat/homepage/campus/publishedSections',
    data: data,
  }).then((res: ResponseDataEntity<Response>) => {
    const data = res.data;
    return data.sections.find(item => item.styleType == 'ANNOUNCEMENT');
  });

class AllParmas {
  campusId: number;
  sectionId: number;
}
export class AnnItem {
  id: number;
  title: string;
  multiImageType: '';
  source: string;
  linkUrls: string[];
  linkType: 'DEFAULT';
  jumpUrl: string;
  urlParameters: {};
  sort: number;
  enabled?: boolean;
  loadAd: boolean;
  mandatoryPrompt: boolean;
  effectTime?: number;
  expirationTime?: number;
  createTime: string;
  updateTime: string;
}
class AllResponse {
  pageNum: number;
  pageSize: number;
  pages: number;
  total: number;
  list: AnnItem[];
  attached: null;
}
export const fetchAllAnn = (
  data: AllParmas,
): Promise<ResponseDataEntity<AllResponse>> =>
  schoolMainFetch({
    url: '/dcxy/wechat/homepage/campus/publishedItems',
    data: data,
  });
