import baseAxios from '../index'

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

  /**
   * 新增消息
   * @param data 
   * @returns 
   */
  addNotify(data: {
    content: string,
    notify_type: number,
    title: string
  }) {
    return baseAxios({
      url: '/notify/admin/add',
      method: 'post',
      data,
    })
  }

  /**
   * 删除消息
   * @param uuid 
   * @returns 
   */
  removeNotify(uuid: string) {
    return baseAxios({
      url: '/notify/admin/delete',
      method: 'delete',
      params: {
        uuid
      },
    })
  }

  /**
   * 消息列表
   * @param data 
   * @returns 
   */
  notifyList(data: {
    end_time?: number,
    limit: number,
    notify_status: number,
    notify_type: number,
    offset: number,
    start_time?: number
  }) {
    return baseAxios({
      url: '/notify/admin/list',
      method: 'post',
      data,
    })
  }

  /**
   * 修改消息
   * @param data 
   * @returns 
   */
  modifyNotify(data: {
    content: string,
    notify_type: number,
    title: string,
    uuid: string
  }) {
    return baseAxios({
      url: '/notify/admin/modify',
      method: 'post',
      data,
    })
  }

  /**
   * 修改消息状态
   * @param data 
   * @returns 
   */
  modifyNotifyStatus(data: {
    notify_status: number,
    uuid: string
  }) {
    return baseAxios({
      url: '/notify/admin/modify/status',
      method: 'post',
      data,
    })
  }
}
