import request from '@/utils/request'

/**
 * 获取部门列表
 * @returns {*}
 */
export function getDeptList(deptName){
    let url = '/system/dept/list';
    if(deptName){
        deptName = encodeURIComponent(deptName);
        url = url+"?deptName="+deptName
    }
    return request({
        url:url,
        method: 'get'
    })
}

/**
 * 获取部门用户列表
 * @returns {*}
 */
export function getUserListByDept(deptId,username){
    let url='/system/user/list?pageNum=1&pageSize=20&deptId='+deptId;
    if(username){
        username = encodeURIComponent(username);
        url = url+"&userName="+username
    }
    return request({
      url:url,
        method: 'get'
    })
}

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

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

//删除用户
export function deleteUser(id){
    return request({
        url:'/system/user/'+id,
        method: 'delete'
    })
}
//获取用户详情
export function getUserById(id){
    return request({
        url:'/system/user/'+id,
        method: 'get'
    })
}
