refactor(models): update data models and remove deprecated IM entities

- 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
This commit is contained in:
zhenyi
2026-06-10 18:49:37 +08:00
parent 420dedbc1e
commit 9eb77ab98b
50 changed files with 827 additions and 440 deletions
+88
View File
@@ -1,3 +1,4 @@
use crate::models::base_info::{UserBaseInfo, WorkspaceBaseInfo};
use crate::models::common::{GitService, Status, Visibility};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
@@ -23,4 +24,91 @@ pub struct Repo {
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub deleted_at: Option<DateTime<Utc>>,
#[sqlx(default)]
pub topics: Vec<String>,
#[sqlx(default)]
pub homepage: Option<String>,
#[sqlx(default)]
pub has_issues: bool,
#[sqlx(default)]
pub has_wiki: bool,
#[sqlx(default)]
pub has_pull_requests: bool,
#[sqlx(default)]
pub allow_forking: bool,
#[sqlx(default)]
pub allow_merge_commit: bool,
#[sqlx(default)]
pub allow_squash_merge: bool,
#[sqlx(default)]
pub allow_rebase_merge: bool,
#[sqlx(default)]
pub delete_branch_on_merge: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
pub struct RepoDetail {
pub id: Uuid,
pub workspace: WorkspaceBaseInfo,
pub owner: UserBaseInfo,
pub name: String,
pub description: Option<String>,
pub default_branch: String,
pub visibility: Visibility,
pub status: Status,
pub is_fork: bool,
pub forked_from_repo_id: Option<Uuid>,
pub storage_node_ids: Vec<Uuid>,
pub primary_storage_node_id: Uuid,
pub storage_path: String,
pub git_service: GitService,
pub archived_at: Option<DateTime<Utc>>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub deleted_at: Option<DateTime<Utc>>,
pub topics: Vec<String>,
pub homepage: Option<String>,
pub has_issues: bool,
pub has_wiki: bool,
pub has_pull_requests: bool,
pub allow_forking: bool,
pub allow_merge_commit: bool,
pub allow_squash_merge: bool,
pub allow_rebase_merge: bool,
pub delete_branch_on_merge: bool,
}
impl Repo {
pub fn into_detail(self, owner: UserBaseInfo, workspace: WorkspaceBaseInfo) -> RepoDetail {
RepoDetail {
id: self.id,
workspace,
owner,
name: self.name,
description: self.description,
default_branch: self.default_branch,
visibility: self.visibility,
status: self.status,
is_fork: self.is_fork,
forked_from_repo_id: self.forked_from_repo_id,
storage_node_ids: self.storage_node_ids,
primary_storage_node_id: self.primary_storage_node_id,
storage_path: self.storage_path,
git_service: self.git_service,
archived_at: self.archived_at,
created_at: self.created_at,
updated_at: self.updated_at,
deleted_at: self.deleted_at,
topics: self.topics,
homepage: self.homepage,
has_issues: self.has_issues,
has_wiki: self.has_wiki,
has_pull_requests: self.has_pull_requests,
allow_forking: self.allow_forking,
allow_merge_commit: self.allow_merge_commit,
allow_squash_merge: self.allow_squash_merge,
allow_rebase_merge: self.allow_rebase_merge,
delete_branch_on_merge: self.delete_branch_on_merge,
}
}
}