import request from '@/config/axios'

// 分销用户关系 VO
export interface SharePathVO {
  // 层级
  depth: number
  // id
  id: number
  // 推荐人
  ancestor: number
  // 直推人
  descendant: number
  // 顺序
  sort: number
}

// 分销用户关系 API
export const SharePathApi = {
  // 查询分销用户关系分页
  getSharePathPage: async (params: any) => {
    return await request.get({ url: `/distri/share-path/page`, params })
  },
  // 根据用户id查后代
  getDuserByUserId: async (params: any) => {
    return await request.get({ url: `/distri/share-path/getDescendants`, params })
  },
  // 查树状图结构
  getSharePathPageTree: async (params: any) => {
    return await request.get({ url: `/distri/share-path/getTree`, params })
  },
  // 根据条件查树状图结构
  getTreeByNameOrMobile: async (params: any) => {
    return await request.get({ url: `/distri/share-path/getTreeByNameOrMobile`, params })
  },
  // 查询分销用户关系详情
  getSharePath: async (id: number) => {
    return await request.get({ url: `/distri/share-path/get?id=` + id })
  },

  // 新增分销用户关系
  createSharePath: async (data: SharePathVO) => {
    return await request.post({ url: `/distri/share-path/create`, data })
  },

  // 修改分销用户关系
  updateSharePath: async (data: SharePathVO) => {
    return await request.put({ url: `/distri/share-path/update`, data })
  },

  // 删除分销用户关系
  deleteSharePath: async (id: number) => {
    return await request.delete({ url: `/distri/share-path/delete?id=` + id })
  },

  // 导出分销用户关系 Excel
  exportSharePath: async (params) => {
    return await request.download({ url: `/distri/share-path/export-excel`, params })
  }
}