.
This commit is contained in:
parent
967579009d
commit
8d07fafabd
@ -2,12 +2,22 @@ use crate::admin::domain::AdminRepository;
|
||||
use crate::admin::domain::*;
|
||||
use crate::admin::state::AdminRegistry;
|
||||
use async_trait::async_trait;
|
||||
use entity;
|
||||
use log::{debug, warn};
|
||||
use sea_orm::{Database, DatabaseConnection, EntityTrait};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
struct UserRepository {}
|
||||
struct UserRepository {
|
||||
connection: DatabaseConnection,
|
||||
}
|
||||
|
||||
impl UserRepository {}
|
||||
impl UserRepository {
|
||||
pub fn new(connection: DatabaseConnection) -> Self {
|
||||
UserRepository {
|
||||
connection: connection,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl AdminRepository for UserRepository {
|
||||
@ -26,7 +36,26 @@ impl AdminRepository for UserRepository {
|
||||
}
|
||||
|
||||
async fn list(&self, model: &RepositoryContext) -> RepositoryList {
|
||||
RepositoryList::Empty
|
||||
let results = entity::User::find()
|
||||
.all(&self.connection)
|
||||
.await
|
||||
.expect("Error loading users.");
|
||||
let repository_items: Vec<RepositoryItem> = results
|
||||
.into_iter()
|
||||
.filter_map(|item| {
|
||||
match serde_json::to_value(item) {
|
||||
Ok(fields) => Some(RepositoryItem {
|
||||
fields,
|
||||
detail_url: None, // replace with actual value if available
|
||||
change_url: None, // replace with actual value if available
|
||||
}),
|
||||
Err(_) => None,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
RepositoryList::List {
|
||||
values: repository_items,
|
||||
}
|
||||
}
|
||||
|
||||
async fn create(
|
||||
|
Loading…
Reference in New Issue
Block a user