import { addUser, list, login, page, resourcePage, updatePassword } from '@/api/user'
import { message } from 'ant-design-vue'

export class UserController {
  static async login (data: USER.Params.Login) {
    return await login(data)
  }

  static async page (queryState: USER.Params.Query) {
    return await page(queryState)
  }

  static async list ({
    limit = 200,
    userLabel = ''
  }: {limit: number, userLabel: string}) {
    return await list({ limit, userLabel })
  }

  static async add (data: USER.User.Detail) {
    await addUser(data)
    message.success('添加成功')
  }

  static async updatePassword (data: {id: string, sourcePassword: string, newPassword: string}) {
    await updatePassword(data)
    message.success('修改成功')
  }

  static async resourcePage (params: USER.Params.Query & {resourceLabel: string}) {
    return await resourcePage(params)
  }
}
