62 lines
1.5 KiB
Rust
62 lines
1.5 KiB
Rust
use chrono::{DateTime, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use models::{ProjectId, RoomCategoryId, UserId};
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum CategoryEventType {
|
|
Created,
|
|
Updated,
|
|
Deleted,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(tag = "type", rename_all = "snake_case")]
|
|
pub enum CategoryEvent {
|
|
Created(CategoryCreatedService),
|
|
Updated(CategoryUpdatedService),
|
|
Deleted(CategoryDeletedService),
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct CategoryCreatedService {
|
|
pub id: RoomCategoryId,
|
|
pub project: ProjectId,
|
|
pub name: String,
|
|
pub position: i32,
|
|
pub created_by: UserId,
|
|
pub created_at: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct CategoryUpdatedService {
|
|
pub id: RoomCategoryId,
|
|
pub project: ProjectId,
|
|
pub name: Option<String>,
|
|
pub position: Option<i32>,
|
|
pub updated_by: UserId,
|
|
pub updated_at: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct CategoryDeletedService {
|
|
pub id: RoomCategoryId,
|
|
pub project: ProjectId,
|
|
pub deleted_by: UserId,
|
|
pub deleted_at: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
pub struct CategoryCreateClient {
|
|
pub project: ProjectId,
|
|
pub name: String,
|
|
pub position: Option<i32>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
pub struct CategoryUpdateClient {
|
|
pub name: Option<String>,
|
|
pub position: Option<i32>,
|
|
}
|