import axios from '@/common/services/axios-instance'

class DataService {
  // 删除时分类
  deleteCategory(ids) {
    return axios
      .delete('api/xcoa-mobile/v1/iamdatacategory/delete-category?ids=' + ids)
      .then(function(res) {
        return res.data
      })
  }

  findIamAuditMaintainCategoryTree(parentId) {
    const url =
      'api/xcoa-mobile/v1/iamdatacategory/findIamAuditMattersCategoryTree?parentId=' + parentId
    return axios.post(url).then(function(res) {
      return res
    })
  }

  // 获取单个授权模型信息
  findIamAuditMaintain(id) {
    return axios({
      url: `api/xcoa-mobile/v1/iamdatacategory/findIamDataCategory/?id=${id}`,
      method: 'post',
    }).then((res) => {
      return res.data
    })
  }

  // 获取角色列表
  rolesList() {
    return axios({
      url: `api/xcoa-mobile/v1/iamdatacategory/findRoles`,
      method: 'get',
    }).then((res) => {
      return res.data
    })
  }

  // 获取项目列表
  projectList(params) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-page/businessList`,
      method: 'post',
      data: params,
    }).then((res) => {
      return res.data
    })
  }

  // 保存授权模型 iamModelMaintainSqSave
  saveIamAuditMaintain(params) {
    return axios({
      url: `api/xcoa-mobile/v1/iamdatacategory/iamDataSqSave`,
      method: 'post',
      data: params,
    }).then((res) => {
      return res.data
    })
  }

  setShareStatus(data) {
    return axios({
      method: 'post',
      url: `api/framework/v1/page/handleData`,
      data: data,
    })
  }

  // 获取索引列表
  findIndexList(params) {
    return axios({
      method: 'post',
      url: 'api/xcoa-mobile/v1/iam-page/businessList',
      data: params,
    })
  }

  // 解除绑定索引
  unbindIndex(ids) {
    return axios({
      method: 'post',
      url: 'api/xcoa-mobile/v1/iamsearchindex/unbind?ids=' + ids,
    })
  }

  // 获取索引列表
  findIndexListDatas(categoryIds) {
    return axios({
      method: 'post',
      url: 'api/xcoa-mobile/v1/iamsearchindex/getByCategoryIds?categoryIds=' + categoryIds,
    })
  }

  // 编辑授权记录
  editIamAuditMaintain(params) {
    return axios({
      url: `api/xcoa-mobile/v1/iamdatacategory/iamDataSqSave`,
      method: 'post',
      data: params,
    })
  }
}
export default new DataService()
