import request from '@/utils/request'
/** =========================user=======================**/
export function getUserList(param) {
  return request({
    url: '/user/getUserList',
    method: 'post',
    data: param
  })
}

export function getUserTypeList() {
  return request({
    url: `/UserTypeRole/getUserTypeList/0`,
    method: 'get'
  })
}

export function updateUserState(userId, state) {
  return request({
    url: `/user/updateUserState/${userId}/${state}`,
    method: 'post'
  })
}

export function getInstitutionList(typeId) {
  return request({
    url: `/institution/getInstitutionList/${typeId}`,
    method: 'get'
  })
}

export function addUser(param) {
  return request({
    url: `/user/addUser`,
    method: 'post',
    data: param
  })
}

export function updateUser(param) {
  return request({
    url: `/user/updateUser`,
    method: 'put',
    data: param
  })
}

export function getUser(userId) {
  return request({
    url: `/user/getUser/${userId}`,
    method: 'get'
  })
}

export function deleteSysUser(userId) {
  return request({
    url: `/user/deleteUser/${userId}`,
    method: 'delete'
  })
}

export function getRoleList(userId, pageIndex, pageSize) {
  return request({
    url: `/role/getRoleList/${userId}/${pageIndex}/${pageSize}`,
    method: 'get'
  })
}

export function getUserRoles(userId) {
  return request({
    url: `/user/getUserRoles/${userId}`,
    method: 'get'
  })
}

export function UpdateUserRole(param) {
  return request({
    url: `/role/UpdateUserRole`,
    method: 'post',
    data: param
  })
}

export function resetPassword(userId) {
  return request({
    url: `/user/resetPassword/${userId}`,
    method: 'get'
  })
}

export function modifyPassword(param) {
  return request({
    url: `/user/modifyPassword`,
    method: 'post',
    data: param
  })
}

/** =========================role=======================**/
export function getRolesList(pageIndex, pageSize) {
  return request({
    url: `/role/getRoleList/${pageIndex}/${pageSize}`,
    method: 'get'
  })
}

export function addOrUpdateRole(param) {
  return request({
    url: `/role/addOrUpdateRole`,
    method: 'post',
    data: param
  })
}

export function deleteRole(roleId) {
  return request({
    url: `/role/deleteRole/${roleId}`,
    method: 'delete'
  })
}

export function getRoleMenuFunction(roleId) {
  return request({
    url: `/menu/getRoleMenuFunction/${roleId}`,
    method: 'get'
  })
}

export function getRoleFunction(roleId, parentId) {
  return request({
    url: `/menu/getRoleFunction/${roleId}/${parentId}`,
    method: 'get'
  })
}

export function updateRoleMenu(param) {
  return request({
    url: `/menu/updateRoleMenu`,
    method: 'post',
    data: param
  })
}

export function updateRoleFunction(param) {
  return request({
    url: `/menu/updateRoleFunction`,
    method: 'post',
    data: param
  })
}
/** =========================menu=======================**/

export function getMenuFunction() {
  return request({
    url: `/menu/getMenuFunction`,
    method: 'get'
  })
}

export function addOrUpdateMenu(param) {
  return request({
    url: `/menu/addOrUpdateMenu`,
    method: 'post',
    data: param
  })
}

export function deleteMenuFunction(menuFunctionId) {
  return request({
    url: `/menu/deleteMenuFunction/${menuFunctionId}`,
    method: 'delete'
  })
}
/** =========================log=======================**/

export function getLogList(param) {
  return request({
    url: `/log/getLogList`,
    method: 'post',
    data: param
  })
}

/** =========================UserType=======================**/
export function getUserTypeRoleList(param) {
  return request({
    url: `/UserTypeRole/getUserTypeRoleList`,
    method: 'post',
    data: param
  })
}

export function addOrUpdateUserType(param) {
  return request({
    url: `/UserTypeRole/addOrUpdateUserTypeRole`,
    method: 'post',
    data: param
  })
}
export function deleteUserTypeRole(userTypeRoleId) {
  return request({
    url: `/UserTypeRole/deleteUserTypeRole/${userTypeRoleId}`,
    method: 'delete'
  })
}

export function getUserTypeListByUserType(userType) {
  return request({
    url: `/UserTypeRole/getUserTypeList/${userType}`,
    method: 'get'
  })
}

export function initSetUserNameAndPwd(params) {
  return request({
    url: `/User/initSetUserNameAndPwd?NewUserName=${params.NewUserName}&UserId=${params.UserId}&NewPwd=${params.NewPwd}&access_token=${params.access_token}`,
    method: 'get'
  })
}
