import NewAxiosInstanceFunc from '../Service/NewAxiosInstance'
import { INewResponse } from '../Service/INewResponse'
import { IAuthInfo, IIndustryVideo } from 'Indepth/Indepth.service'
import { IPaging } from 'Material/Material.service'
import { IPermissionItem } from 'Activity/Activity.service'
/*
微路演模块
*/

export interface IGetRoadshowListParams {
  PageSize: number // 每页数据条数
  CurrentIndex: number // 当前页页码，从1开始
  KeyWord?: string
  Filter?: string // 1 视频 2 音频，多个用逗号隔开
  ChartPermissionIds?: string // 行业ID，多个用逗号隔开
  SearchType?: string // 搜索类型: 1-路演回放; 2-问答系列； 3-调研反馈 多个用 , 隔开
}
export interface IRoadshowResponse {
  List: IRoadshowistItem[]
  Paging: IPaging
}

export interface IRoadshowistItem {
  ActivityId: number //活动ID
  AuthInfo: IAuthInfo
  BackgroundImg: string //背景图片
  ChartPermissionId: number //行业ID
  ChartPermissionName: string //行业名称
  CollectTime: string
  CreateTime: string
  Id: number //ID
  IndustrialManagementId: number
  IndustryName: string //产业名称
  IsCollect: boolean //是否收藏
  PlaySeconds: string //时长
  PublishTime: string //发布时间
  ResourceUrl: string // 音频、视频 URL地址
  ShareImg: string // 分享图片
  SourceId: number //来源ID(可能是活动ID、音频ID、视频ID)
  Title: string //标题
  Type: number // 类型  1-音频; 2-活动视频; 3-产业视频
  IndustryId: number // 产业ID(小程序使用的)
  LabelType: number // 标签类型 1-路演回放; 2-问答系列；3-产业视频; 4-问答系列
}
export interface IRoadshowPermissionRes {
  List: IPermissionItem[]
}
export const MicroRoadshowService = {
  getRoadshowList: (params: IGetRoadshowListParams): INewResponse<IRoadshowResponse> =>
    NewAxiosInstanceFunc({
      url: `/micro_roadshow/list`,
      method: 'get',
      params: { ...params }
    }),
  getPermissionList: (): INewResponse<IRoadshowPermissionRes> =>
    NewAxiosInstanceFunc({
      url: `/permission/noyx`,
      method: 'get'
    }),
  getVideoInfo: (VideoId: number): INewResponse<{ IndustryVideo: IIndustryVideo; AuthInfo: IAuthInfo }> =>
    NewAxiosInstanceFunc({
      url: `/micro_roadshow/detail`,
      method: 'get',
      params: { VideoId }
    }),
  postRoadshowComment: (SourceId: number, SourceType: number, Content: string): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/micro_roadshow/comment/add`,
      method: 'post',
      data: { SourceId, SourceType, Content } // SourceType-视频来源: 1-音频; 2-活动视频; 3-微路演视频
    }),
  postRoadshowCollect: (SourceId: number, SourceType: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/micro_roadshow/collect`,
      method: 'post',
      data: { SourceId, SourceType } // SourceType-视频来源: 1-音频; 2-活动视频; 3-微路演视频
    }),
  postVideoHistory: (SourceId: number, SourceType: number, PlaySeconds?: number): INewResponse =>
    NewAxiosInstanceFunc({
      url: `/micro_roadshow/videoHistory/add`,
      method: 'post',
      data: { SourceId, SourceType, PlaySeconds }
    })
}
