import request from '@/utils/request'
import { praseStrEmpty } from "@/utils/ruoyi";

// 查询用户列表
export function listUser(query) {
  return request({
    url: '/system/user/teacher/list',
    method: 'get',
    params: query
  })
}

// 查询教职工下拉列表
export function optionUser(data) {
  return request({
    url: '/system/user/teacher/option',
    method: 'post',
    data: data
  })
}

// 查询用户详细
export function getUser(userId) {
  return request({
    url: '/system/user/teacher/' + praseStrEmpty(userId),
    method: 'get'
  })
}

// 新增用户
export function addUser(data) {
  return request({
    url: '/system/user/teacher',
    method: 'post',
    data: data
  })
}

// 修改用户
export function updateUser(data) {
  return request({
    url: '/system/user/teacher',
    method: 'put',
    data: data
  })
}

// 删除用户
export function delUser(userId) {
  return request({
    url: '/system/user/teacher/' + userId,
    method: 'delete'
  })
}

// 用户密码重置
export function resetUserPwd(userId, password) {
  const data = {
    userId,
    password
  }
  return request({
    url: '/system/user/teacher/resetPwd',
    method: 'put',
    data: data
  })
}

// 用户状态修改
export function changeUserStatus(userId, status) {
  const data = {
    userId,
    status
  }
  return request({
    url: '/system/user/teacher/changeStatus',
    method: 'put',
    data: data
  })
}

// 查询用户个人信息
export function getUserProfile() {
  return request({
    url: '/system/user/teacher/profile',
    method: 'get'
  })
}

// 修改用户个人信息
export function updateUserProfile(data) {
  return request({
    url: '/system/user/teacher/profile',
    method: 'put',
    data: data
  })
}

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword
  }
  return request({
    url: '/system/user/teacher/profile/updatePwd',
    method: 'put',
    params: data
  })
}

// 用户头像上传
export function uploadAvatar(data) {
  return request({
    url: '/system/user/teacher/profile/avatar',
    method: 'post',
    data: data
  })
}

// 查询授权角色
export function getAuthRole(userId) {
  return request({
    url: '/system/user/teacher/authRole/' + userId,
    method: 'get'
  })
}

// 保存授权角色
export function updateAuthRole(data) {
  return request({
    url: '/system/user/teacher/authRole',
    method: 'put',
    params: data
  })
}

//教职工启用停用接口
export function putUserTeacher(data) {
  return request({
    url: '/system/user/teacher',
    method: 'put',
    data: data
  })
}

//删除教职工
export function delTeacher(userId) {
  return request({
    url: '/system/user/teacher/' + userId,
    method: 'delete'
  })
}

//重置教职工密码
export function teacherResetPwd(data) {
  return request({
    url: '/system/user/teacher/resetPwd',
    method: 'put',
    data: data
  })
}

//新增部门
export function addDeptByTeacher(data) {
  return request({
    url: '/system/dept/addDeptByTeacher',
    method: 'post',
    data: data
  })
}

//编辑部门
export function putDeptByTeacher(data) {
  return request({
    url: '/system/dept',
    method: 'put',
    data: data
  })
}

//编辑部门名称
export function updateDeptName(data) {
  return request({
    url: '/system/dept/updateDeptName',
    method: 'put',
    data: data
  })
}

//部门位置移动
export function editDeptOrder(data) {
  return request({
    url: '/system/dept/editDeptOrder',
    method: 'put',
    data: data
  })
}

//删除部门
export function delDept(deptId) {
  return request({
    url: '/system/dept/'+deptId,
    method: 'delete',
  })
}

//部门添加人员
export function editUserByDept(data) {
  return request({
    url: '/system/user/teacher/editUserByDept',
    method: 'put',
    data: data
  })
}

//查询教师详情接口
export function getTeacherInfo(userId) {
  return request({
    url: '/system/user/teacher/' + userId,
    method: 'get'
  })
}

//查询身份列表
export function optionselect(query) {
  return request({
    url: '/system/post/optionselect',
    method: 'get',
    params: query
  })
}

//字段模糊搜索
export function getVaguet(query) {
  return request({
    url: '/system/dict/data/getVague',
    method: 'get',
    params: query
  })
}

//根据用户查询权限
export function userPermit(userId) {
  return request({
    url: '/system/permit/userPermit/'+userId,
    method: 'get',
  })
}

//新增教职工
export function addUserTeacher(data) {
  return request({
    url: '/system/user/teacher',
    method: 'post',
    data:data
  })
}

//编辑教职工
export function putUserTeacherNew(data) {
  return request({
    url: '/system/user/teacher',
    method: 'put',
    data:data
  })
}


//教职工在职离职联动启用停用
export function editNatureLinkage(data) {
  return request({
    url: '/system/user/teacher/editNatureLinkage',
    method: 'put',
    data: data
  })
}

// 查询部门下拉树结构
export function treeselect(query) {
  return request({
    url: '/system/dept/treeselect',
    method: 'get',
    params: query
  })
}

//批量获取老师数据
export function teacherBatchSelect(data) {
  return request({
    url: 'system/user/teacher/batchSelect/'+data,
    method: 'post',
  })
}

//批量修改老师卡号
export function teacherUpdateCardNum(data) {
  return request({
    url: '/system/user/teacher/updateCardNum',
    method: 'put',
    data: data
  })
}
