/* eslint-disable */
import axios, { AxiosInstance, AxiosResponse } from 'axios'
import qs from 'qs'

export interface ObjectType {
  [key: string]: any;
}

export interface Config {
  $domain?: string;
  $config?: any;
}

export interface Parameters {
  [key: string]: any;
}

let domain = ''
let axiosInstance = axios.create()
export function getDomain(): string {
  return domain
}
export function setDomain($domain: string): void {
  domain = $domain
}
export function getAxiosInstance(): AxiosInstance {
  return axiosInstance
}
export function setAxiosInstance($axiosInstance: AxiosInstance): void {
  axiosInstance = $axiosInstance
}
type RequestMethod = 'get' | 'post' | 'put' | 'delete' | 'head' | 'option' | 'patch'
export function request(method: RequestMethod, url: string, body?: ObjectType, config: ObjectType = {}) {
  let queryUrl = url
  if (method === 'delete') {
    return axiosInstance[method](queryUrl,{...config, data: body || {} })
  } else if (method === 'get') {
    let params = body ? qs.stringify(body) : ''
    if (params) {
      if (queryUrl.indexOf('?') < 0) {
        params = '?' + params
      } else if (!queryUrl.endsWith('?')) {
        params = '&' + params
      }
    }
    return axiosInstance[method](queryUrl + params, config)
  } else if(method === 'post' || method === 'put' || method === 'patch'){
    return axiosInstance[method](queryUrl, body, config)
  } else if (method === 'head' || method === 'option') {
    return axiosInstance[method](queryUrl, config)
  }
}

// os统计
export interface os统计 {
  count?: number; // 统计结果
  os?: string; // OS
  ratio?: number; // 占比
}

// os统计结果
export interface os统计结果 {
  osStatisticList?: Array<os统计>; // os统计结果
}

// 修改短链接请求
export interface 修改短链接请求 {
  directUrl?: string; // 长链接url
  id?: string; // 短链id
  title?: string; // 标题
}

// 公共响应对象<T>
export interface 公共响应对象<T> {
  data?: T; // 业务数据
  errorCode?: T; // 错误码
  errorMsg?: T; // 错误信息
  status?: boolean; // 响应状态
}

// 公共页对象<T>
export interface 公共页对象<T> {
  currentPage?: number; // 当前页
  list?: Array<T>; // 当前页内容
  pageSize?: number; // 页大小
  totalCount?: number; // 总条数
  totalPage?: number; // 总页
}

// 周统计
export interface 周统计 {
  count?: number; // 统计结果
  weekDay?: string; // 自然日
}

// 周统计结果
export interface 周统计结果 {
  weekStatisticList?: Array<周统计>; // 周统计统计结果
}

// 小时统计
export interface 小时统计 {
  count?: number; // 统计结果
  hour?: number; // 小时
}

// 新增短链接请求
export interface 新增短链接请求 {
  directUrl?: string; // 长链接url
  endDate?: string; // 有效期截止时间，为空表示永久有效
  title?: string; // 标题
}

// 浏览器
export interface 浏览器 {
  browser?: string; // 浏览器
  count?: number; // 统计数
  ratio?: number; // 占比
}

// 浏览器结果
export interface 浏览器结果 {
  browserStatisticList?: Array<浏览器>; // 浏览器结果
}

// 热点ip统计
export interface 热点ip统计 {
  count?: number; // 统计值
  ip?: string; // ip
}

// 热点ip统计结果
export interface 热点ip统计结果 {
  hotIpStatisticList?: Array<热点ip统计>; // 热点ip统计结果
}

// 省份统计
export interface 省份统计 {
  count?: number; // 统计结果
  name?: string; // 省份
  ratio?: number; // 统计占比
}

// 省份统计结果
export interface 省份统计结果 {
  regionStatisticList?: Array<省份统计>;
}

// 短链接信息VO
export interface 短链接信息VO {
  createdBy?: string;
  createdTime?: string;
  directUrl?: string; // 长链接url
  endDate?: string; // 有效期截止时间，为空表示永久有效
  id?: number;
  shortUrl?: string; // 短链接url
  title?: string; // 标题
  updatedBy?: string;
  updatedTime?: string;
}

// 设备统计
export interface 设备统计 {
  count?: number; // 统计
  device?: string; // 设备
  ratio?: number; // 占比
}

// 网络统计
export interface 网络统计 {
  mobileCount?: number; // 移动数据总数
  mobileRatio?: number; // 流量占比
  wifiCount?: number; // wifi总数
  wifiRatio?: number; // wifi占比
}

// 访问图表结果
export interface 访问图表结果 {
  visitCurveList?: Array<访问图表>; // 访问图表统计结果
}

// 访问统计结果
export interface 访问统计结果 {
  newCount?: number; // 新房客数
  newRatio?: number; // 新访客占比
  oldCount?: number; // 老访客数
  oldRatio?: number; // 老访客占比
}

// 统计结果VO
export interface 统计结果VO {
  browserStatisticResult?: 浏览器结果;
  deviceStatisticResult?: 设备统计;
  hotIpStatisticResult?: 热点ip统计结果;
  hourStatisticResult?: 小时统计;
  internetStatisticResult?: 网络统计;
  osStatisticResult?: os统计结果;
  regionStatisticResult?: 省份统计结果;
  visitCurveResult?: 访问图表结果;
  visitorStatisticResult?: 访问统计结果;
  weekStatisticResult?: 周统计结果;
}

// 访问图表
export interface 访问图表 {
  date?: string;
  ipCount?: number; // ip数
  visitTimesCount?: number; // 访问次数
  visitorCount?: number; // 访客数
}

// 访问记录VO
export interface 访问记录VO {
  accessTime?: string; // 访问时间
  address?: string; // 访问地址
  browser?: string; // 浏览器
  device?: string; // 设备
  ip?: string; // 访问IP
  network?: string; // 网络
  os?: string; // 操作系统
  shortUrl?: string; // 短链接
  visitType?: string; // 访客类型 新访客 老访客
}


export interface AccessRecordsearchAccessRecordParameters {
  accessEndTime?: string; // 访问截止时间
  accessStartTime?: string; // 访问开始时间
  currentPage?: number; // currentPage
  pageSize?: number; // pageSize
  shortUrl?: string; // 短链接
}

/**
 * @name: AccessRecordsearchAccessRecord
 * @date: 2022/1/21
 * @description: 查询访问记录
 * @param: {accessEndTime} [string]
 * @param: {accessStartTime} [string]
 * @param: {currentPage} [integer]
 * @param: {pageSize} [integer]
 * @param: {shortUrl} [string]
 * @return: Promise<AxiosResponse<公共响应对象<公共页对象<访问记录VO>>>>
 */
export function AccessRecordsearchAccessRecord(parameters: Config & AccessRecordsearchAccessRecordParameters): Promise<AxiosResponse<公共响应对象<公共页对象<访问记录VO>>>> {
  const { $config, $domain, ...body} = parameters
  const host = $domain ? $domain : getDomain()
  let path = '/admin/api/access-record/searchAccessRecord'

  return request('get', host + path, body, $config)
}

export interface StatisticgetStatisticResultParameters {
  accessEndTime?: string; // 访问截止时间
  accessStartTime?: string; // 访问开始时间
  shortUrl?: string; // 短链接
}

/**
 * @name: StatisticgetStatisticResult
 * @date: 2022/1/21
 * @description: 短链统计汇总
 * @param: {accessEndTime} [string]
 * @param: {accessStartTime} [string]
 * @param: {shortUrl} [string]
 * @return: Promise<AxiosResponse<公共响应对象<统计结果VO>>>
 */
export function StatisticgetStatisticResult(parameters: Config & StatisticgetStatisticResultParameters): Promise<AxiosResponse<公共响应对象<统计结果VO>>> {
  const { $config, $domain, ...body} = parameters
  const host = $domain ? $domain : getDomain()
  let path = '/admin/api/statistic/shortLinkStatistic'

  return request('get', host + path, body, $config)
}

export interface UrlInfoaddShortUrlParameters {
  request: 新增短链接请求; // request
}

/**
 * @name: UrlInfoaddShortUrl
 * @date: 2022/1/21
 * @description: 新增短链
 * @param: {request} [新增短链接请求]
 * @return: Promise<AxiosResponse<公共响应对象<string>>>
 */
export function UrlInfoaddShortUrl(parameters: Config & UrlInfoaddShortUrlParameters): Promise<AxiosResponse<公共响应对象<string>>> {
  const { $config, $domain, ...body} = parameters
  const host = $domain ? $domain : getDomain()
  let path = '/admin/api/url-info/addShortUrl'

  return request('post', host + path, body, $config)
}

export interface UrlInfosearchShortUrlParameters {
  createEndTime?: string; // 创建截止时间
  createStartTime?: string; // 创建开始时间
  currentPage?: number; // currentPage
  directUrl?: string; // 跳转URL
  pageSize?: number; // pageSize
  title?: string; // 短链标题
}

/**
 * @name: UrlInfosearchShortUrl
 * @date: 2022/1/21
 * @description: 查询短链接
 * @param: {createEndTime} [string]
 * @param: {createStartTime} [string]
 * @param: {currentPage} [integer]
 * @param: {directUrl} [string]
 * @param: {pageSize} [integer]
 * @param: {title} [string]
 * @return: Promise<AxiosResponse<公共响应对象<公共页对象<短链接信息VO>>>>
 */
export function UrlInfosearchShortUrl(parameters: Config & UrlInfosearchShortUrlParameters): Promise<AxiosResponse<公共响应对象<公共页对象<短链接信息VO>>>> {
  const { $config, $domain, ...body} = parameters
  const host = $domain ? $domain : getDomain()
  let path = '/admin/api/url-info/searchShortUrl'

  return request('get', host + path, body, $config)
}

export interface UrlInfoupdateShortUrlParameters {
  request: 修改短链接请求; // request
}

/**
 * @name: UrlInfoupdateShortUrl
 * @date: 2022/1/21
 * @description: 修改短链
 * @param: {request} [修改短链接请求]
 * @return: Promise<AxiosResponse<公共响应对象<any>>>
 */
export function UrlInfoupdateShortUrl(parameters: Config & UrlInfoupdateShortUrlParameters): Promise<AxiosResponse<公共响应对象<any>>> {
  const { $config, $domain, ...body} = parameters
  const host = $domain ? $domain : getDomain()
  let path = '/admin/api/url-info/updateShortUrl'

  return request('post', host + path, body, $config)
}

export interface UrlInfodirectUrlParameters {
  id: string; // id
}

/**
 * @name: UrlInfodirectUrl
 * @date: 2022/1/21
 * @description: 访问短链
 * @param: {id} [string]
 * @return: Promise<AxiosResponse<never>>
 */
export function UrlInfodirectUrl(parameters: Config & UrlInfodirectUrlParameters): Promise<AxiosResponse<never>> {
  const { $config, $domain, ...body} = parameters
  const host = $domain ? $domain : getDomain()
  let path = '/s/{id}'

  return request('get', host + path, body, $config)
}