import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UserVO, UserForm, UserQuery, GrantForm } from '@/api/system/business/apiUsers/types';

/**
 * 查询【请填写功能名称】列表
 * @param query
 * @returns {*}
 */

export const listUser = (query?: UserQuery): AxiosPromise<UserVO[]> => {
  return request({
    url: '/business/user/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询【请填写功能名称】详细
 * @param id
 */
export const getUser = (id: string | number): AxiosPromise<UserVO> => {
  return request({
    url: '/business/user/' + id,
    method: 'get'
  });
};

/**
 * 新增【请填写功能名称】
 * @param data
 */
export const addUser = (data: UserForm) => {
  return request({
    url: '/business/user',
    method: 'post',
    data: data
  });
};

/**
 * 修改【请填写功能名称】
 * @param data
 */
export const updateUser = (data: UserForm) => {
  return request({
    url: '/business/user',
    method: 'put',
    data: data
  });
};

/**
 * 删除【请填写功能名称】
 * @param id
 */
export const delUser = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/user/' + id,
    method: 'delete'
  });
};

/**
 * 发送道具
 * @param data
 */
export const sendRewardToos = (data: GrantForm) => {
  return request({
    url: '/business/user/sendRewardToos',
    method: 'post',
    data: data
  });
};

/**
 * 获取短信验证码
 * @param phone 手机号
 */
export const getSmsCode = (phone: string) => {
  return request({
    url: '/business/user/getSmsCode',
    method: 'get',
    params: {
      phone
    }
  });
};

export const updateUserPhone = (data: UserForm) => {
  return request({
    url: '/business/user/updateUserPhone',
    method: 'put',
    data: data
  });
};

/**
 * 移除系统数据
 */
export const removeUserCacheSystemData = () => {
  return request({
    url: '/business/user/removeUserCacheSystemData',
    method: 'post'
  });
};
/**
 * 根据手机号查询用户信息
 * @param phone
 */
export const queryUserInfoByPhone = (phone: string | number): AxiosPromise<UserVO> => {
  return request({
    url: '/business/user/queryUserInfoByPhone/' + phone,
    method: 'get'
  });
};
