import NewAxiosInstanceFunc from '../Service/NewAxiosInstance'
import { INewResponse } from '../Service/INewResponse'
import { IHomeArticleListItem, IPaging } from 'Material/Material.service'
import { ICommunityArticleList } from 'Community/Community.service'
import { IMeetingreviewListSubject } from 'Newest/Newest.service'

export interface IPermissionListItem {
  ChartPermissionId: number
  PermissionName: string
}
export interface IIndustryListParams {
  ChartPermissionId?: number // 分类ID(榜单没有ID)
  CurrentIndex: number
  PageSize: number
  IsBillboard: boolean // 是否属于榜单 是true 否 false
  DeepCover?: number // 是否选择深度覆盖，1是，0否 不填默认为0
  RecommendFocus?: number // 是否选择推荐关注，1是，0否 不填默认为0
}
export interface IIndustyListItem {
  ArticleId: number
  ArticleReadNum: number // 文章阅读数量
  ChartPermissionId: number
  ChartPermissionName: string
  IndustrialManagementId: number // 产业id
  IndustrialSubjectList: IIndustrialSubjectList[]
  IndustryName: string
  IsFollow: boolean // 是否关注
  IsHot: boolean // 是否是热门
  IsNew: boolean // 是否展示 NEW 标签
  IsRed: boolean // 是否标记红点
  IsShowRoadshow: boolean // 是否展示 微路演 标签
  Source: number // 来源  1是弘则资源包，2是研选资源包
  UpdateTime: string // 更新时间
  LayoutTime: string
  MinReportTime: string
  IndustryVideo: IIndustryVideo
  AuthInfo: IAuthInfo
  FllowNum: number // 关注数量
  PublishDate: string //发布时间、更新时间
}
export interface IIndustrialSubjectList {
  ArticleId: number
  ChartPermissionId: number
  IndustrialManagementId: number // 产业id
  IndustrialSubjectId: number // 标的id
  IndustryName: string // 产业名称
  IsResearch: boolean // 是否属于研选
  SubjectName: string // 标的名称
}
export interface IAuthInfo {
  HasPermission: number //1:有该行业权限,正常展示，2：无该行业权限，不存在权益客户下，3:无该品类权限,已提交过申请，4：无该行业权限,未提交过申请，5：潜在客户，未提交过申请，6：潜在客户,已提交过申请
  SellerMobile: string //销售手机号
  SellerName: string //销售名称
  OperationMode: string
  PopupMsg: string // 提示文案
}
export interface IIndustryVideo {
  ActivityId?: number // 活动视频的活动ID
  Id: number
  Title: string
  ResourceUrl: string
  BackgroundImg: string
  PlaySeconds: number
  DetailImgUrl: string
  ChartPermissionId: number
  ChartPermissionName: string
  Type: number // 1:音频 2:活动视频 3:产业视频
}
export interface ITradeListItem {
  CategoryId: number
  IsFollow: boolean
  IsRed: boolean
  IsHot: boolean
  ListArticle: IIndepthArticleItem[]
  MatchTypeName: string // 匹配类型
  Readnum: number // 阅读数量
  UpdateTime: string
}
export interface ITacticsItem {
  TimeLineId: number //ID
  PublishTime: string //发布时间
  Status: number //状态
  Content: string //内容
  ArticleId: number //文章ID
  ChartId: number //图表ID
  Link: string //文章或图表链接
}
export interface ISearchReportItem extends IHomeArticleListItem {
  List: IReportBillboardIndustryItem[]
  ListSubject: IIndustrialSubjectList[]
}
export interface IToArticleCategoryListRes {
  IndustrialManagementId: number
  IndustryName: string
  LayoutTime: string
  List: IIndustryMenu[]
  ListSubject: IIndustrialSubjectList[]
  IndustryVideo: IIndustryVideo
  AuthInfo: IAuthInfo
}
export interface IIndustryMenu {
  CategoryId: number
  IsRed: boolean
  MatchTypeName: string
}
export interface IListHzReportItem {
  Abstract: string
  Annotation: string
  ArticleId: number
  Body: string
  CategoryId: string
  CategoryName: string
  CollectNum: number
  DepartmentId: number
  HttpUrl: string
  ImgUrlPc: string
  IsCollect: boolean
  IsNeedJump: boolean
  IsResearch: boolean
  List: [
    {
      ChartPermissionId: number
      IndustrialManagementId: number
      IndustryName: string
    }
  ]
  MyCollectNum: number
  NickName: string
  PublishDate: string
  Pv: number
  Source: number
  SubCategoryName: string
  Title: string
}
export interface ICompanyItem {
  ArticleId: number
  Cover: string
  ComapnyList: {
    ComapnyName: string
  }[]
}
export interface IBillBoardItem {
  Abstract: string //摘要
  Annotation: string //核心观点
  ArticleId: number //文章id
  ArticleTypeId: number
  Body: string //内容
  BodyImg: string
  CategoryId: number //文章分类
  ChartPermissionName: string //权限名称
  CollectNum: number
  Cover: string // 封面
  DepartmentId: number
  ExpertBackground: string //专家背景
  HttpUrl: string //文章链接跳转地址
  ImgUrlPc: string //图片链接
  IsCollect: boolean
  IsNeedJump: boolean //是否需要跳转链接地址
  IsRed: boolean
  IsResearch: boolean //是否属于研选
  List: IReportBillboardIndustryItem[]
  NickName: string
  PublishDate: string //发布时间
  Pv: number //PV
  Source: number //来源  1:文章, 2:图表
  Title: string //标题
  TitleEn: string //英文标题
  Resource?: number
  BodyHighlight: string[] // 搜索报告的内容
  LabelKeywordImgLink: string // 标签关键词图片链接
}
export interface IReportBillboardIndustryItem {
  IndustrialManagementId: number //产业Id
  IndustryName: string //产业名称
  SubjectName: string //标的名称
  ArticleId: number //文章ID
  IsResearch: boolean //是否属于研选
  ChartPermissionId: number //权限id
}
export interface ITimelineItem {
  ArticleId: number // 文章ID/产品内测
  Content: string
  Id: number // 视频Id
  ImgUrlPc: string
  IsHaveVideo: boolean
  IsRed: boolean
  LinkArticleId: number
  ListSubject: IMeetingreviewListSubject[]
  PublishDate: string
  Readnum: number
  // ReportLink: string
  Resource: number // 1:文章、2:  产品内测、3: 晨报点评 4:  活动回放、5：音频
  SubCategoryName: string
  Title: string
  Type: number
  VideoUrl: string
  VoiceUrl: string
}
export interface IIndepthArticleItem {
  Abstract: string
  Annotation: string
  ArticleId: number
  ArticleTypeId: number
  Body: string
  BodyHtml: string
  CategoryId: string
  CategoryName: string
  CollectNum: number
  HomeType: number
  HttpUrl: string // 文章链接跳转地址
  ImgUrlPc: string
  IsCollect: boolean
  IsNeedJump: boolean
  IsRed: boolean
  IsResearch: boolean //是否属于研选
  List: IReportBillboardIndustryItem[]
  MicroAudio: {
    AudioActivityId: number
    AudioChartPermissionId: number
    AudioChartPermissionName: string
    AudioImgUrl: string
    AudioPlaySeconds: string
    AudioPublishTime: string
    AudioResourceUrl: string
    AudioShareImg: string
    AudioTitle: string
    AudioType: number
    AuthInfo: IAuthInfo
    Id: number
  }
  PublishDate: string
  Pv: number
  Readnum: number
  Resource: number //  1报告  2产品内测
  Source: number // 来源  1:文章, 2:图表
  SubCategoryName: string
  Title: string
  TitleEn: string
}
export interface IIndepthBannerList {
  Title: string // 标题
  IndexImg: string // 路径
  Path: string
  IsShowSustainable: boolean // 是否展示限免标签
}

export const IndepthService = {
  getPermissionListByReport: (): INewResponse<{ List: IPermissionListItem[] }> =>
    NewAxiosInstanceFunc({
      url: `/permission/listByReport`,
      method: 'get'
    }),
  getIndustryList: (params: IIndustryListParams): INewResponse<{ List: IIndustyListItem[]; Paging: IPaging }> =>
    NewAxiosInstanceFunc({
      url: `/report/industryList`,
      method: 'get',
      params: { ...params }
    }),
  getTradeList: (ChartPermissionId: number): INewResponse<{ List: ITradeListItem[] }> =>
    NewAxiosInstanceFunc({
      url: `/report/tradeList`,
      method: 'get',
      params: { ChartPermissionId }
    }),
  getTacticsTimeLine: (
    CurrentIndex: number,
    pageSize: number
  ): INewResponse<{ List: ITacticsItem[]; Paging: IPaging }> =>
    NewAxiosInstanceFunc({
      url: `/tactics/tacticsTimeLine/list`,
      method: 'get',
      params: { CurrentIndex, pageSize }
    }),
  getArticleListByCategoryId: (
    CategoryId: number,
    CurrentIndex: number,
    PageSize: number,
    IndustrialManagementId?: number
  ): INewResponse<{ List: IIndepthArticleItem[]; CategoryImgUrlPc: string; MatchTypeName: string; Paging: IPaging }> =>
    NewAxiosInstanceFunc({
      url: `/report/articleList/byCategoryId`,
      method: 'get',
      params: { CategoryId, CurrentIndex, PageSize, IndustrialManagementId }
    }),
  getListByCategoryId: (
    CategoryId: number,
    CurrentIndex: number,
    PageSize: number,
    IndustrialManagementId?: number
  ): INewResponse<{ List: IIndepthArticleItem[]; CategoryImgUrlPc: string; MatchTypeName: string; Paging: IPaging }> =>
    NewAxiosInstanceFunc({
      url: `/report/tactics/list`,
      method: 'get',
      params: { CategoryId, CurrentIndex, PageSize, IndustrialManagementId }
    }),
  getArticleCategoryListByIndustry: (IndustrialManagementId: number): INewResponse<IToArticleCategoryListRes> =>
    NewAxiosInstanceFunc({
      url: `/report/toArticleCategoryList`,
      method: 'get',
      params: { IndustrialManagementId }
    }),
  getSearchReport: (
    KeyWord: string,
    ArticleType: string,
    IsAll: boolean,
    CurrentIndex: number,
    PageSize: number
  ): INewResponse<{ ListHz: ICommunityArticleList[]; ListYx: ICommunityArticleList[]; Paging: IPaging }> =>
    NewAxiosInstanceFunc({
      url: `/report/searchReport`,
      method: 'get',
      params: { KeyWord, ArticleType, IsAll, CurrentIndex, PageSize }
    }),
  getSearchResource: (KeyWord: string): INewResponse<{ ListHz: IIndustyListItem[]; ListYx: IIndustyListItem[] }> =>
    NewAxiosInstanceFunc({
      url: `/report/searchResource`,
      method: 'get',
      params: { KeyWord }
    }),
  // 废弃接口
  getSearchReportAndResource: (
    KeyWord: string,
    PageSize: number,
    CurrentIndex: number,
    SearchType: number // 1：综合，2：全部
  ): INewResponse<{ ListHzReport: IListHzReportItem[]; ListHzResource: IIndustyListItem[] }> =>
    NewAxiosInstanceFunc({
      url: `/report/searchReportAndResource`,
      method: 'get',
      params: { KeyWord, PageSize, CurrentIndex, SearchType }
    }),
  getCompanyList: (ChartPermissionId?: number): INewResponse<{ List: ICompanyItem[] }> =>
    NewAxiosInstanceFunc({
      url: `/report/companyList`,
      method: 'get',
      params: { ChartPermissionId }
    }),
  getReportBillboard: (
    Source: number, // Source 来源 1：阅读飙升 ，2：报告收藏
    PageSize?: number,
    ChartPermissionId?: number
  ): INewResponse<{ List: IBillBoardItem[] }> =>
    NewAxiosInstanceFunc({
      url: `/report_billboard/list`,
      method: 'get',
      params: { Source, PageSize, ChartPermissionId }
    }),
  getTimeline: (
    IndustrialManagementId: number,
    CurrentIndex: number,
    PageSize: number
  ): INewResponse<{ List: ITimelineItem[]; CategoryImgUrlPc: string; MatchTypeName: string; Paging: IPaging }> =>
    NewAxiosInstanceFunc({
      url: `/report/timeline`,
      method: 'get',
      params: { IndustrialManagementId, CurrentIndex, PageSize }
    }),

  getIndepthBanner: (): INewResponse<{ ListA: IIndepthBannerList[]; ListB: IIndepthBannerList }> =>
    NewAxiosInstanceFunc({
      url: `/collection/banner/list`,
      method: 'get'
    }),
  getApplyCollectionClick: (): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/collection/detail`,
      method: 'get'
    }),
  postIndustrialFllow: (IndustrialManagementId: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/report/industrial/fllow`,
      method: 'post',
      data: { IndustrialManagementId }
    }),
  postCategoryFllow: (CategoryId: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/report/category/fllow`,
      method: 'post',
      data: { CategoryId }
    }),
  postTacticsTimeLineHistory: (TimeLineId: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/tactics/tacticsTimeLine/history`,
      method: 'post',
      data: { TimeLineId }
    }),
  postApplyCollection: (Content: string): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/collection/apply/add`,
      method: 'post',
      data: { Content }
    })
}
