import type { RenewProps } from '../common'

import { get, post, postMultipart } from '#/api/http'
import { only_last_id } from '#/api/only-last'

import { BasicService } from '../basic'

class StudentService extends BasicService {
  // 计算续费费用
  async calRenewFee(data: RenewProps) {
    const url = '/org/student/sysUser/calRenewVipFee'
    return await post(url, data, {
      [only_last_id]: url,
    } as any)
  }

  async getClassStudents(classId: any) {
    return get<any>('/schoolUser/list', {
      classId,
      size: -1,
    })
  }

  async importStudent(data: any) {
    return await postMultipart<any>('/org/student/sysUser/import', data, {
      timeout: 1000 * 120,
    })
  }

  // 续费
  async renew(data: RenewProps) {
    return await post('/org/student/sysUser/renew', data)
  }

  protected findPageUrl(): string {
    return '/org/student/sysUser/list'
  }

  protected removeUrl(): string {
    return ''
  }

  protected saveOrUpdateUrl(): string {
    return '/org/student/sysUser/saveOrUpdate'
  }

  protected override switchKeyValues() {
    return [
      {
        key: 'status',
        trueValue: 0,
        falseValue: 1,
      },
    ]
  }
}

export const studentService = new StudentService()
