use crate::event::{UserInfo, WorkspaceInfo}; use chrono::{DateTime, Utc}; use uuid::Uuid; use serde::{Deserialize, Serialize}; #[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")] pub enum CategoryEvent { #[serde(rename = "category.created")] Created(CategoryCreatedService), #[serde(rename = "category.updated")] Updated(CategoryUpdatedService), #[serde(rename = "category.deleted")] Deleted(CategoryDeletedService), } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct CategoryCreatedService { pub id: Uuid, #[serde(rename = "workspace")] pub project: WorkspaceInfo, pub name: String, pub position: i32, pub created_by: UserInfo, pub created_at: DateTime, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct CategoryUpdatedService { pub id: Uuid, #[serde(rename = "workspace")] pub project: WorkspaceInfo, pub name: Option, pub position: Option, pub updated_by: UserInfo, pub updated_at: DateTime, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct CategoryDeletedService { pub id: Uuid, #[serde(rename = "workspace")] pub project: WorkspaceInfo, pub deleted_by: UserInfo, pub deleted_at: DateTime, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct CategoryCreateClient { pub project: WorkspaceInfo, pub name: String, pub position: i32, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct CategoryUpdateClient { pub name: Option, pub position: Option, }