smbcloud_model/
project.rs1use crate::{app_auth::AuthApp, ar_date_format};
2use chrono::{DateTime, Utc};
3use serde::{Deserialize, Serialize};
4
5#[derive(Deserialize, Debug, Serialize)]
6pub struct Config {
7 pub current_project: Option<Project>,
8 pub current_auth_app: Option<AuthApp>,
9}
10
11#[derive(Deserialize, Debug, Serialize)]
12pub struct Project {
13 pub id: i32,
14 pub name: String,
15 pub description: String,
16 #[serde(with = "ar_date_format")]
17 pub created_at: DateTime<Utc>,
18 #[serde(with = "ar_date_format")]
19 pub updated_at: DateTime<Utc>,
20}
21#[derive(Serialize, Debug)]
22pub struct ProjectCreate {
23 pub name: String,
24 pub description: String,
25}
26
27#[cfg(test)]
28mod tests {
29 use super::*;
30 use serde_json::json;
31 #[test]
32 fn test_project_create() {
33 let project_create = ProjectCreate {
34 name: "test".to_owned(),
35 description: "test".to_owned(),
36 };
37 let json = json!({
38 "name": "test",
39 "description": "test",
40 });
41 assert_eq!(serde_json::to_value(project_create).unwrap(), json);
42 }
43}