import request  from '../util/request.js';

export function loginApi(params) {
    return request({
        url: '/authApi/LoginResource/login',
        method: 'post',
        data: params,
    });
}


// 闸机侧查询当天出入库数据
export function getStaticInfo() {
    const warehouseId = localStorage.getItem('#warehouseId');
    return request({
        url: '/api/StockOutResource/queryInboundAndOutboundData?warehouseId=' + warehouseId,
        method: 'get',
    });
}

// 登录时查看是否需要修改密码，默认30天后提醒
export function queryRemindTime() {
    return request({
        url: '/api/RemindPasswordTimeResource/queryRemindTime',
        method: 'get',
    });
}

// 人员登录时推送尚未处理的异常停泊区任务
export function queryAwayAbnormalCar() {
    return request({
        url: '/api/LocatorResource/checkAwayAbnormalCar',
        method: 'get',
    });
}

// 查询用户权限
export function getUserRole() {
    return request({
        url: '/api/RoleResourceV3/listUserRoleOrTemplate',
        method: 'get',
    });
}

// 根据设备ID获取仓库ID
export function getWarehouseId(deviceId) {
    return request({
        url: `/api/WarehouseResource/findWarehouseByDeviceId?deviceId=${deviceId}`,
        method: 'get',
    });
}

// 修改密码
export function updateUserPassword(data) {
    const formData = new FormData();
    formData.append('oldPassword', data.oldPassword);
    formData.append('newPassword', data.newPassword);
    formData.append('newPassword2', data.newPassword2);
    
    return request({
        url: '/api/userResource/updateUserPassword',
        method: 'post',
        data: formData,
        headers: {
            'Content-Type': 'multipart/form-data',
        },
    });
}
