import request from '../utils/request'
import {codeProjectName} from '../config'
let hi_request=null;
if(window.HIVUI_SETTING&&window.HIVUI_SETTING.request){
  hi_request=window.HIVUI_SETTING.request;
}
function _request(opt){
  if(hi_request){
    return hi_request(opt);
  }else{
    return request(opt);
  }
}
const __base=(window.HIVUI_SETTING.serverUrl||codeProjectName);

//获取用户信息
export function getInfo(param) {
  return _request({
    url: window.HIVUI_SETTING.userInfo||(__base+"/sys/user/detail"),
    method: 'post',
    data: param,
  })
}
//获取多岗列表
export function getBzList(param) {
  return _request({
    url: __base+"/sys/user/detail-list",
    method: 'post',
    data: param,
  })
}
//切换编制岗位
export function changeBz(param) {
  return _request({
    url: __base+"/sys/user/switch-bz",
    method: 'post',
    data: param,
  })
}
//修改密码
export function modifyPassword(param) {
  return _request({
    url: __base+"/sys/user/update-pwd",
    method: 'post',
    data: param,
  })
}

// 查询
export function query(param) {
  return _request({
    url: __base+"/data/query",
    method: 'post',
    data: param,
  })
}
// 更新
export function update(param) {
  return _request({
    url: __base+"/data/update",
    method: 'post',
    data: param,
  })
}
// 上传
export function upload(param) {
  return _request({
    url:HIVUI_SETTING.upload,
    headers: {
      "Content-Type": "multipart/form-data"
    },
    method: 'post',
    data: param,
  })
}
// 获取单点登录服务器信息
export function getSSOInfo(param) {
  return _request({
    url:__base+"/sso/get-sso-info",
    method: 'get',
    data: param,
  })
}
// 获取单点登录服务器票据
export function getSSOTicket(ssoServe,param) {
  return _request({
    url:ssoServe + (ssoServe.endsWith("/")?"":"/") + "sso/get-ticket",
    method: 'post',
    data: param,
  })
}