import send_request from '../utils/send_request';

/**
 * 用户登录
 * @returns
 */
export function userLogin({ username, password }) {
    return send_request({
        url: '/user/login',
        method: 'POST',
        useQS: true,
        params: {
            "username": username,
            "password": password,
        },
    });
};

/**
 * 用户退出登录
 * @returns
 */
export function userLogout() {
    return null;
};

/**
 * 修改密码
 * @returns
 */
export function updatePwd({ oldpwd, newpwd }) {
    let userId = localStorage.getItem("ms_user_id")
    return send_request({
        url: '/user/updatePwd',
        method: 'POST',
        useQS: true,
        params: {
            "userId": userId,
            "oldpwd": oldpwd,
            "newpwd": newpwd,
        },
    });
};

/**
 * 获取用户列表
 * @returns
 */
export function getUserList(params) {
    return send_request({
        url: '/user/manage/getUserList',
        method: 'GET',
        params: params,
    });
};

/**
 * 添加/修改用户信息
 * @returns
 */
export function editUser(params) {
    return send_request({
        url: '/user/manage/editUser',
        method: 'POST',
        useQS: true,
        params: params,
    });
};

/**
 * 删除用户
 * @returns
 */
export function deleteUser(params) {
    return send_request({
        url: '/user/manage/deleteUser',
        method: 'POST',
        useQS: true,
        params: params,
    });
};

/**
 * 导出用户列表
 * @returns
 */
export function exportUserList(params) {
    return send_request({
        url: '/user/manage/exportUserList',
        method: 'GET',
        params: params,
    });
};
