mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-04-30 16:20:54 +00:00
28 lines
555 B
Rust
28 lines
555 B
Rust
//! # Admin information API
|
|
//!
|
|
//! @author Pierre Hubert
|
|
|
|
use serde::Serialize;
|
|
|
|
use crate::data::admin::Admin;
|
|
|
|
#[derive(Serialize)]
|
|
pub struct AdminInfoAPI {
|
|
id: u64,
|
|
name: String,
|
|
email: String,
|
|
time_create: u64,
|
|
roles: Vec<&'static str>,
|
|
}
|
|
|
|
impl AdminInfoAPI {
|
|
pub fn new(a: &Admin) -> Self {
|
|
Self {
|
|
id: a.id.id(),
|
|
name: a.name.clone(),
|
|
email: a.email.clone(),
|
|
time_create: a.time_create,
|
|
roles: a.roles.iter().map(|r| r.to_id()).collect(),
|
|
}
|
|
}
|
|
} |