import { http } from './http'

// 上报锁定屏幕时间
export interface LockScreenTime {
  simSerialNumber: string
  lockFlag: 0 | 1 // 0-解锁 1-锁定
}

// 上报视频播放时间
export interface VideoPlayTime {
  resourceType: 0 | 1 | 2 | 3 // 0-自由学 1-AI精准学 2-错题本 3-举一反三
  origin: 1 | 2 // 1-章节 2-知识点
  subjectId: string
  playDuration: number // 视频最后播放位置
  userId: string
  videoId: string
  videoName: string
  endTime: number | ''
  startTime: number | ''
}

// 上报学习时长
export interface StudyTime {
  resourceType: 0 | 1 | 2 | 3 // 0-自由学 1-AI精准学 2-错题本 3-举一反三
  studyTime: number
  subjectId: string
  userId: string
  endTime: number
  startTime: number
}

const logApi = {
  reportLockScreenTime: (data: LockScreenTime) =>
    http.request({
      url: '/deviceTimeControl/update/timeStamp',
      method: 'post',
      data,
    }),

  reportVideoPlayTime: (data: VideoPlayTime) =>
    http.request({
      url: '/userVideo',
      method: 'put',
      data,
    }),

  reportStudyTime: (data: StudyTime) =>
    http.request({
      url: '/userSubjectReport',
      method: 'put',
      data,
    }),
}

export default logApi
