feat: 为数据库模块添加异步获取项目名方法及对应路由处理函数

- 为数据库模块添加获取所有项目名称的异步方法并实现初步查询逻辑。
- 新增获取所有项目名的路由及其处理函数以支持项目信息查询功能。
This commit is contained in:
2025-08-20 00:37:02 +08:00
parent 9cd11a7f37
commit 8257c9e7e5
2 changed files with 39 additions and 1 deletions

View File

@@ -4,7 +4,6 @@ use std::{fs, path::Path};
use welds::{connections::sqlite::SqliteClient, prelude::*};
use crate::InsertArgs;
#[derive(WeldsModel, Clone, Serialize)]
#[welds(table = "authorize")]
pub struct Authorize {
@@ -186,4 +185,21 @@ impl Db {
None => Ok(None),
}
}
pub async fn get_all_project(
&self,
) -> Result<Vec<String>, Box<dyn std::error::Error + Send + Sync>> {
let result = Authorize::select(|a| a.project)
.group_by(|a| a.project)
.run(&self.client)
.await?;
let rows: Vec<Authorize> = result.collect_into()?;
let projects: Vec<String> = Vec::new();
for row in rows {
println!("{row:?}");
}
Ok(projects)
}
}