import request from '@/config/axios'

// 用户 VO
export interface UserVO {
  id: number // 主键ID
  username: string // 用户名
  password: string // 密码
  token: string // 登录token
}

// 用户 API
export const UserApi = {
  // 查询用户分页
  getUserPage: async (params: any) => {
    return await request.get({ url: `/portal/user/page`, params })
  },

  // 查询用户详情
  getUser: async (id: number) => {
    return await request.get({ url: `/portal/user/get?id=` + id })
  },

  // 新增用户
  createUser: async (data: UserVO) => {
    return await request.post({ url: `/portal/user/create`, data })
  },

  // 修改用户
  updateUser: async (data: UserVO) => {
    return await request.put({ url: `/portal/user/update`, data })
  },

  // 删除用户
  deleteUser: async (id: number) => {
    return await request.delete({ url: `/portal/user/delete?id=` + id })
  },

  // 导出用户 Excel
  exportUser: async (params) => {
    return await request.download({ url: `/portal/user/export-excel`, params })
  }
}