9eb77ab98b
- Update channel, notification, PR, repo, user, workspace models - Remove deleted IM models: articles, channel follows, message attachments/bookmarks/drafts/edit history/embeds/mentions/pins/ polls/reactions/threads, saved messages, thread read states - Add new PR models: review requests, templates - Add repo release assets model - Add base_info module for API detail responses
63 lines
1.9 KiB
Rust
63 lines
1.9 KiB
Rust
use crate::models::base_info::UserBaseInfo;
|
|
use crate::models::common::{Status, Visibility};
|
|
use chrono::{DateTime, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
use uuid::Uuid;
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, sqlx::FromRow, utoipa::ToSchema)]
|
|
pub struct Workspace {
|
|
pub id: Uuid,
|
|
pub owner_id: Uuid,
|
|
pub name: String,
|
|
pub description: Option<String>,
|
|
pub avatar_url: Option<String>,
|
|
pub visibility: Visibility,
|
|
pub plan: String,
|
|
pub status: Status,
|
|
pub default_role: String,
|
|
pub is_personal: bool,
|
|
pub archived_at: Option<DateTime<Utc>>,
|
|
pub created_at: DateTime<Utc>,
|
|
pub updated_at: DateTime<Utc>,
|
|
pub deleted_at: Option<DateTime<Utc>>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
|
|
pub struct WorkspaceDetail {
|
|
pub id: Uuid,
|
|
pub owner: UserBaseInfo,
|
|
pub name: String,
|
|
pub description: Option<String>,
|
|
pub avatar_url: Option<String>,
|
|
pub visibility: Visibility,
|
|
pub plan: String,
|
|
pub status: Status,
|
|
pub default_role: String,
|
|
pub is_personal: bool,
|
|
pub archived_at: Option<DateTime<Utc>>,
|
|
pub created_at: DateTime<Utc>,
|
|
pub updated_at: DateTime<Utc>,
|
|
pub deleted_at: Option<DateTime<Utc>>,
|
|
}
|
|
|
|
impl Workspace {
|
|
pub fn into_detail(self, owner: UserBaseInfo) -> WorkspaceDetail {
|
|
WorkspaceDetail {
|
|
id: self.id,
|
|
owner,
|
|
name: self.name,
|
|
description: self.description,
|
|
avatar_url: self.avatar_url,
|
|
visibility: self.visibility,
|
|
plan: self.plan,
|
|
status: self.status,
|
|
default_role: self.default_role,
|
|
is_personal: self.is_personal,
|
|
archived_at: self.archived_at,
|
|
created_at: self.created_at,
|
|
updated_at: self.updated_at,
|
|
deleted_at: self.deleted_at,
|
|
}
|
|
}
|
|
}
|