106 lines
2.8 KiB
Rust
106 lines
2.8 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct Task {
|
|
pub id: u32,
|
|
pub source: String,
|
|
pub project: Option<String>,
|
|
pub status_name: String,
|
|
pub status_class: String,
|
|
pub subject: String,
|
|
pub last_note: Option<String>,
|
|
pub created_on: Option<String>,
|
|
pub updated_on: Option<String>,
|
|
}
|
|
|
|
impl Task {
|
|
pub fn status_class_from_name(name: &str) -> String {
|
|
let name_lower = name.to_lowercase();
|
|
if name_lower.contains("new") || name_lower.contains("новая") {
|
|
"new".to_string()
|
|
} else if name_lower.contains("progress") || name_lower.contains("в работе") {
|
|
"progress".to_string()
|
|
} else if name_lower.contains("resolv") || name_lower.contains("решен") {
|
|
"resolved".to_string()
|
|
} else {
|
|
"closed".to_string()
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct TaskDetail {
|
|
pub id: u32,
|
|
pub source: String,
|
|
pub subject: String,
|
|
pub description: String,
|
|
pub status_name: String,
|
|
pub status_class: String,
|
|
pub priority_name: String,
|
|
pub project_name: String,
|
|
pub author_name: String,
|
|
pub assigned_to_name: String,
|
|
pub created_on: String,
|
|
pub updated_on: String,
|
|
pub start_date: String,
|
|
pub due_date: String,
|
|
pub done_ratio: u32,
|
|
pub estimated_hours: f32,
|
|
pub spent_hours: f32,
|
|
pub journals: Vec<TaskJournal>,
|
|
pub attachments: Vec<TaskAttachment>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct TaskJournal {
|
|
pub id: u32,
|
|
pub user_name: String,
|
|
pub notes: String,
|
|
pub created_on: String,
|
|
pub details: Vec<JournalDetail>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct JournalDetail {
|
|
pub property: String,
|
|
pub name: String,
|
|
pub old_value: String,
|
|
pub new_value: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct TaskAttachment {
|
|
pub id: u32,
|
|
pub filename: String,
|
|
pub filesize: u32,
|
|
pub content_type: String,
|
|
pub content_url: String,
|
|
pub description: String,
|
|
pub author_name: String,
|
|
pub created_on: String,
|
|
pub is_image: bool,
|
|
}
|
|
|
|
impl TaskAttachment {
|
|
pub fn is_image_type(content_type: Option<&str>) -> bool {
|
|
match content_type {
|
|
Some(ct) => ct.starts_with("image/"),
|
|
None => false,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct BitrixTask {
|
|
pub id: u32,
|
|
pub title: String,
|
|
pub status: String,
|
|
pub status_code: String,
|
|
pub responsible_id: Option<u32>,
|
|
pub created_by: Option<u32>,
|
|
pub date_created: String,
|
|
pub date_change: String,
|
|
pub deadline: Option<String>,
|
|
pub description: Option<String>,
|
|
}
|