import { http } from '@/utils/http/axios';

export interface BasicResponseModel<T = any> {
  code: number;
  msg: string;
  data: T;
}

export interface BasicPageParams {
  pageNo: number;
  pageSize: number;
  total: number;
}

/**
 * @description: 获取用户信息
 */
export function getUserInfo() {
  return http.request({
    url: '/index/getUser',
    method: 'get',
  });
}

/**
 * @description: 用户登录
 */
export function login(params) {
  return http.request<BasicResponseModel>(
    {
      url: '/login',
      method: 'POST',
      params,
    },
    {
      isTransformResponse: false,
    },
  );
}

/**
 * @description: 用户登录
 */
export function getInfoCaptcha() {
  return http.request(
    {
      url: '/captcha',
      method: 'GET'
    },
  );
}

/**
 * @description: 用户修改密码
 */
export function changePassword(data) {
  return http.request(
    {
      url: `/index/updatePassword`,
      method: 'PUT',
      data
    }
  );
}
/**
 * @description: 获取短信验证码
 */
export function sendSms(data) {
  return http.request(
    {
      url: `/sms/sendSms`,
      method: 'POST',
      data
    }
  );
}
/**
 * @description: 用户登出
 */
export function logout(params) {
  return http.request({
    url: '/login/logout',
    method: 'POST',
    params,
  });
}

/**
 * @description: 获取用户列表
 */
export function getUserList(params) {
  return http.request({
    url: '/user/page',
    method: 'get',
    params,
  });
}
/**
 * @description: 根据ID获取详情
 */
export function getUserDetail(userId) {
  return http.request({
    url: '/user/detail/'+userId,
    method: 'get',
  });
}
/**
 * @description: 添加用户
 */
export function userAdd(data:any) {
  return http.request({
    url: '/user/add',
    method: 'POST',
    data,
  });
}
/**
 * @description: 更新用户
 */
export function userUpdate(data:any) {
  return http.request({
    url: '/user/update',
    method: 'PUT',
    data
  });
}
/**
 * @description: 重置密码
 */
export function resetPwd(data:any) {
  return http.request({
    url: '/user/resetPwd',
    method: 'PUT',
    data
  });
}
/**
 * @description: 删除用户
 */
export function userDelete(userId) {
  return http.request({
    url: '/user/delete/'+userId,
    method: 'DELETE',
  });
}
/**
 * @description: 批量删除用户
 */
export function userBatchDelete(data:any) {
  return http.request({
    url: '/user/batchDelete',
    method: 'DELETE',
    data
  });
}
/**
 * @description: 导入用户
 */
export function userImport(data) {
  return http.request({
    url: '/user/import',
    method: 'POST',
    data
  });
}
/**
 * @description: 导出用户
 */
export function userExport() {
  return http.request({
    url: '/user/export',
    method: 'GET'
  },{
    isTransformResponse: false,
  });
}

/**
 * @description: 下载模板
 */
export function getTemplateByCode(code:any) {
  return http.request({
    url: '/file/template/getTemplateByCode/'+code,
    method: 'GET'
  });
}
/**
 * @description: 获取打印地址
 */
export function getUserDocument(userId:any) {
  return http.request({
    url: '/user/document/'+userId,
    method: 'GET'
  });
}
/**
 * @description: 城市列表
 */
export function getCityByList(pid:any) {
	return http.request({
		url: '/city/getCityList/'+pid,
		method: 'get',
	});
}