import { request } from 'umi';

function Page(params) {
   return request(`/kitchen/api/user/userpage`,{method:'post',data:params});
}

//启用
function Enable(params)
{
 return request(`/kitchen/api/user/enable/?Id=${params}`)
}
//禁用
 function Disable(params)
{
 return request(`/kitchen/api/user/disable/?Id=${params}`)
}

//删除
function RemoveUser(params) {
    return request('/kitchen/api​/user/delete', {
      method: 'POST',
      data: params
    });
}

function  Add(params) {
    return request('/kitchen/api​/user/add', {
        method: 'POST',
        data: params
      });
}

function  Update(params) {
    return request('/kitchen/api​/user/update', {
        method: 'POST',
        data: params
      });
}

function ResetPwd(params) {
  return request(`/kitchen/api/user/resetuserpwd/?Id=${params}`);
}

function  UpdatePwd(params) {
  return request('/kitchen/api/user/updatepwd', {
    method: 'POST',
    data: params
  });
}

function  GetRoleDic() {
  return request(`/kitchen/api/select/getrole`);
}

function  GetUserRole(params) {
  return request(`/kitchen/api/user/getuserrole/?UserId=${params}`);
}

function  AddUserRole(params) {
  return request('/kitchen/api/user/adduserrole', {
    method: 'POST',
    data: params
  });
}

function  UpdateUserRole(params) {
  return request('/kitchen/api/user/updateuserrole', {
    method: 'POST',
    data: params
  });
}
//数据授权
export async function SetDataRole(params) {
  return request(`/kitchen/api/user/setandalteruserscope`,{
    method:'post',
    data:params
  });
}

function gettree(params) {
  return request('​/kitchen/api​/sysOrg​/tree', {
    data: {
      ...params,
    },
  });
}

export default {
  Page,
  Enable,
  Disable,
  RemoveUser,
  Update,
  Add,
  ResetPwd,
  UpdatePwd,
  GetRoleDic,
  GetUserRole,
  AddUserRole,
  UpdateUserRole,
  SetDataRole,
  gettree
};
