db/_archive/herodb_old/src/models/gov/user.rs
2025-06-27 12:11:04 +03:00

57 lines
1.2 KiB
Rust

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use crate::db::{Model, Storable}; // Import db traits
// use std::collections::HashMap; // Removed unused import
/// User represents a user in the governance system
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct User {
pub id: u32,
pub name: String,
pub email: String,
pub password: String,
pub company: String, // here its just a best effort
pub role: String,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
// Removed old Model trait implementation
impl User {
/// Create a new user with default timestamps
pub fn new(
id: u32,
name: String,
email: String,
password: String,
company: String,
role: String,
) -> Self {
let now = Utc::now();
Self {
id,
name,
email,
password,
company,
role,
created_at: now,
updated_at: now,
}
}
}
impl Storable for User{}
// Implement Model trait
impl Model for User {
fn get_id(&self) -> u32 {
self.id
}
fn db_prefix() -> &'static str {
"user"
}
}