import request from '@/utils/request'

export const queryEdDataPage = (data) => {
  return request({
    url: '/cs-device-boot/edData/queryEdDataPage',
    method: 'post',
    data: Object.assign(
      {
        pageNum: {},
        devName: '',
        devType: '',
        pageSize: {},
        versionStartDate: '',
        versionendDate: '',
      },
      data
    ),
  })
}

// 新增程序版本
export const addEdData = (data) => {
  return request({
    url: '/cs-device-boot/edData/addEdData',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data: data,
  })
}

export const auditEdData = (data) => {
  return request({
    url: '/cs-device-boot/edData/auditEdData',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data: data,
  })
}

// 设备模版查询
export const queryDevModelPage = (data) => {
  return request({
    url: '/cs-device-boot/devmodel/queryDevModelPage',
    method: 'post',
    data: Object.assign(
      {
        pageNum: {},
        devName: '',
        devType: '',
        pageSize: {},
        versionStartDate: '',
        versionendDate: '',
      },
      data
    ),
  })
}

// 新增设备模版
export const addDevModel = (file) => {
  let form = new FormData()
  form.append('file', file)
  return request({
    url: '/access-boot/analyzeModel/addModel',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data: form,
  })
}
// 编辑设备模版
export const AuditDevModel = (data) => {
  return request({
    url: '/cs-device-boot/devmodel/AuditDevModel',
    method: 'post',
    data: data,
  })
}

// 拓扑图查询
export const queryTopologyDiagramPage = (data) => {
  return request({
    url: '/cs-device-boot/topologyDiagram/queryTopologyDiagramPage',
    method: 'post',
    data: Object.assign(
      {
        pageNum: {},
        devName: '',
        devType: '',
        pageSize: {},
        versionStartDate: '',
        versionendDate: '',
      },
      data
    ),
  })
}
// 新增拓扑图
export const addAppTopologyDiagram = (data) => {
  return request({
    url: '/cs-device-boot/topologyDiagram/addAppTopologyDiagram',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data: data,
  })
}

// 删除拓扑图
export const delAppTopologyDiagram = (id) => {
  let form = new FormData()
  form.append('id', id)
  form.append('status', 0)

  return request({
    url: '/cs-device-boot/topologyDiagram/AuditAppTopologyDiagram',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    data: form,
  })
}

// 新增字典数据
export const addCsDictData = (data) => {
  return request({
    url: '/system-boot/csDictData/add',
    method: 'post',
    data: data,
  })
}

// 查询字典数据
export const queryCsDictDataPage = (data) => {
  return request({
    url: '/system-boot/csDictData/list',
    method: 'post',
    data: Object.assign(
      {
        orderBy: '',
        pageNum: 0,
        pageSize: 0,
        searchBeginTime: '',
        searchEndTime: '',
        searchState: 0,
        searchValue: '',
        dataType: '',
        sortBy: '',
      },
      data
    ),
  })
}

//删除字典数据
export const delCsDictData = (id) => {
  let form = new FormData()
  form.append('id', id)
  return request({
    url: '/system-boot/csDictData/delete',
    method: 'post',
    data: form,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
  })
}

// 修改字典数据
export const updateCsDictData = (data) => {
  return request({
    url: '/system-boot/csDictData/update',
    method: 'post',
    data: data,
  })
}

// 字典树接口

export const queryCsDictTree = (pid) => {
  let form = new FormData()
  form.append('pid', pid)
  return request({
    url: '/system-boot/dictTree/query',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    data: form,
  })
}
// 字典树接口通过code
export const queryByCode = (code) => {
  let form = new FormData()
  form.append('code', code)
  return request({
    url: '/system-boot/dictTree/queryByCode',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    data: form,
  })
}
// 字典树接口通过id
export const queryByid = (id) => {
  let form = new FormData()
  form.append('id', id)
  return request({
    url: '/system-boot/dictTree/queryByid',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    data: form,
  })
}

export const csDictDataSelectAll = () => {
  return request({
    url: '/system-boot/csDictData/selectAll',
    method: 'post',
  })
}

// 查询指标
export const queryStatistical = (id) => {
  let form = new FormData()
  form.append('id', id)
  return request({
    url: '/system-boot/csstatisticalset/queryStatistical',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    data: form,
  })
}

// 绑定指标
export const addStatistical = (params) => {
  return request({
    url: '/system-boot/csstatisticalset/addStatistical',
    method: 'post',
    data: params,
  })
}


//新增字典树数据
export const addDictTree = (data) => {
  return request({
    url: '/system-boot/dictTree/add',
    method: 'post',
    data: data,
  })
}

/**
 * 新增app基础信息
 * @param content 内容
 * @param type 类型
 * Data_base 资料库
 * introductior 系统介绍
 * User_Manual 用户手册
 * User_Agreement 用户协议
 * Company_Profile 公司简介
 * @returns {*}
 */
export const addAppInfo = ({content, type}) => {
  return request({
    url: '/cs-system-boot/appinfo/addAppInfo',
    method: 'post',
    data: {
      content,
      type
    },
  })
}

/**
 * 查询app个人中心信息
 */
export const queryPersonSet = () => {
  return request({
    url: '/cs-system-boot/appinfo/queryPersonSet',
    method: 'post',
  })
}

/**
 * 查询app个人中心信息详情
 * @param id
 */

export const queryAppInfo = (type) => {
  let form = new FormData()
  form.append('type', type)
  return request({
    url: '/cs-system-boot/appinfo/queryAppInfoByType',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    data: form,
  })
}

export const findReferralCode = () => {
    return request({
        url: '/user-boot/referralCode/findReferralCode',
        method: 'post',
    })
}
export const refreshReferralCode = () => {
    return request({
        url: '/user-boot/referralCode/refreshReferralCode',
        method: 'post',
    })
}


/**
 * 删除统计指标配置项
 */

export const deleteStatistical = (id) => {
    let form = new FormData()
    form.append('id', id)
    return request({
        url: '/system-boot/dic/delete',
        method: 'DELETE',
        headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        },
        data: form,
    })
}


/**
 * 编辑统计指标配置项
 */

export const updateStatistical = (data) => {
    return request({
        url: '/system-boot/dic/update',
        method: 'PUT',
        data: data,
    })
}