1 Star 0 Fork 0

叶秋明 / ybat

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Zlib

易班客户端

实现了易班的部分接口,包括登陆过程

Cargo.toml中导入

[dependencies]
ybat = { git = "https://gitee.com/ye-qiuming/ybat", branch = "v1.2" }
tokio = { version = "1.7.10", features = ["full"] }
tokio-stream = "0.1.8"
// 处理错误
anyhow = "1.0.56"

接下来

use ybat::Client;
use ybat::module::task::{TaskForm, Content, FormExtend, json};
use tokio_stream::StreamExt;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = Client::login("***", "***").await?;
    let tasks = client.query_uncompleted_tasks().await?.data;
    println!("共有{}个任务", tasks.len());
    let mut stream = tokio_stream::iter(tasks);
    while let Some(task) = stream.next().await {
        if task.title.contains("健康") {
            let detail = client.get_task_detail(&task.task_id).await?.data;
            let process_detail = client.get_process_detail(&detail.wfid)
                .await?.data;
            let extend = FormExtend {
                task_id: &task.task_id,
                title: "任务信息",
                content: vec![
                    Content {
                        label: "任务名称",
                        value: &task.title,
                    },
                    Content {
                        label: "发布机构",
                        value: "学生工作处",
                    },
                ],
            };
            let form = TaskForm::default(&detail.wfid,
                                         &process_detail.list[0].id, json!({
    "a069e4b52079413679cc71a8f70c7edf": "正常在校",
    "98205659930dc79306b3c41ede65f239": {
        "name": "北苑99栋学生公寓",
        "location": "**,**",
        "address": "火星"
    },
    "303558fbc358e7fccdb9a1e258606ffc": [
        "体温正常,身体健康(37.3°以下)"
    ],
    "664d3c096eefcdc6f80e35b1c701a227": "36.6°-36.9°(正常体温)",
    "7bdcea686bff26915e91ce77034de2b3": "体温正常,身体健康(37.3°以下)"
}), extend);
            println!("要提交的表单:{:#?}", form);
            let response = client.submit_task(form).await?;
            println!("返回结果是:{:#?}", response);
        }
    };
    Ok(())
}
zlib License (C) 2022 叶秋明 This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution.

简介

易班API库 展开 收起
Rust
Zlib
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Rust
1
https://gitee.com/ye-qiuming/ybat.git
git@gitee.com:ye-qiuming/ybat.git
ye-qiuming
ybat
ybat
v1.2

搜索帮助

344bd9b3 5694891 D2dac590 5694891