import baseAxios from '../index'
const prefix = '/activity/admin'
import { eActivityItem } from "./type"

export default class ActivityService {
  static instance: ActivityService
  static getInstance() {
    if (!ActivityService.instance) {
      ActivityService.instance = new ActivityService()
    }
    return ActivityService.instance
  }

  addActivity(
    data: {
      content: string
      file_name: string
      title: string
    }
  ) {
    return baseAxios({
      url: prefix + '/add',
      method: 'POST',
      data,
    })
  }

  queryActivityList(
    data: {
      activity_status: number
      end_time?: number
      limit?: number
      offset?: number
      start_time?: number
    }
  ) {
    return baseAxios<{
      count: number,
      items: eActivityItem[],
      total: number
    }>({
      url: prefix + '/list',
      method: 'POST',
      data,
    })
  }

  queryActivityInfo(uuid: string) {
    return baseAxios<{
      count: number,
      items: eActivityItem[],
      total: number
    }>({
      url: '/activity/query/info?uuid='+uuid,
      method: 'GET',
    })
  }

  modifyActivity(data: {
    content: string
    file_name: string
    title: string
    uuid:string
  }) {
    return baseAxios({
      url: prefix + '/modify',
      method: 'POST',
      data,
    })
  }

  modifyActivityStatus(data: {
    activity_status: number,
    uuid: string,
  }) {
    return baseAxios({
      url: prefix + '/modify/status',
      method: 'POST',
      data,
    })
  }

  deleteActivity(uuid: string) {
    return baseAxios({
      url: prefix + '/delete?uuid=' + uuid,
      method: 'DELETE',
    })
  }


}