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:
+6
-2
@@ -9,8 +9,10 @@ pub mod pr_merge_strategy;
|
||||
pub mod pr_reactions;
|
||||
pub mod pr_review;
|
||||
pub mod pr_review_comment;
|
||||
pub mod pr_review_requests;
|
||||
pub mod pr_status;
|
||||
pub mod pr_subscriptions;
|
||||
pub mod pr_templates;
|
||||
pub mod pull_request;
|
||||
pub mod pull_request_queries;
|
||||
|
||||
@@ -23,8 +25,10 @@ pub use pr_label_relations::PrLabelRelation;
|
||||
pub use pr_labels::PrLabel;
|
||||
pub use pr_merge_strategy::PrMergeStrategy;
|
||||
pub use pr_reactions::PrReaction;
|
||||
pub use pr_review::PrReview;
|
||||
pub use pr_review::{PrReview, PrReviewDetail};
|
||||
pub use pr_review_comment::PrReviewComment;
|
||||
pub use pr_review_requests::PrReviewRequest;
|
||||
pub use pr_status::PrStatus;
|
||||
pub use pr_subscriptions::PrSubscription;
|
||||
pub use pull_request::PullRequest;
|
||||
pub use pr_templates::PrTemplate;
|
||||
pub use pull_request::{PullRequest, PullRequestDetail};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::models::base_info::UserBaseInfo;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
@@ -17,3 +18,34 @@ pub struct PrReview {
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
|
||||
pub struct PrReviewDetail {
|
||||
pub id: Uuid,
|
||||
pub pull_request_id: Uuid,
|
||||
pub author: UserBaseInfo,
|
||||
pub state: String,
|
||||
pub body: Option<String>,
|
||||
pub dismissed: bool,
|
||||
pub dismissed_by: Option<Uuid>,
|
||||
pub dismissed_at: Option<DateTime<Utc>>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
impl PrReview {
|
||||
pub fn into_detail(self, author: UserBaseInfo) -> PrReviewDetail {
|
||||
PrReviewDetail {
|
||||
id: self.id,
|
||||
pull_request_id: self.pull_request_id,
|
||||
author,
|
||||
state: self.state,
|
||||
body: self.body,
|
||||
dismissed: self.dismissed_at.is_some(),
|
||||
dismissed_by: self.dismissed_by,
|
||||
dismissed_at: self.dismissed_at,
|
||||
created_at: self.created_at,
|
||||
updated_at: self.updated_at,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, sqlx::FromRow, utoipa::ToSchema)]
|
||||
pub struct PrReviewRequest {
|
||||
pub id: Uuid,
|
||||
pub pull_request_id: Uuid,
|
||||
pub reviewer_id: Uuid,
|
||||
pub requested_by: Uuid,
|
||||
pub created_at: chrono::DateTime<chrono::Utc>,
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, sqlx::FromRow, utoipa::ToSchema)]
|
||||
pub struct PrTemplate {
|
||||
pub id: Uuid,
|
||||
pub repo_id: Uuid,
|
||||
pub name: String,
|
||||
pub description: Option<String>,
|
||||
pub title_template: Option<String>,
|
||||
pub body_template: String,
|
||||
pub labels: Vec<String>,
|
||||
pub active: bool,
|
||||
pub created_by: Option<Uuid>,
|
||||
pub created_at: chrono::DateTime<chrono::Utc>,
|
||||
pub updated_at: chrono::DateTime<chrono::Utc>,
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::models::base_info::UserBaseInfo;
|
||||
use crate::models::common::State;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -29,3 +30,60 @@ pub struct PullRequest {
|
||||
pub updated_at: DateTime<Utc>,
|
||||
pub deleted_at: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
|
||||
pub struct PullRequestDetail {
|
||||
pub id: Uuid,
|
||||
pub repo_id: Uuid,
|
||||
pub author: UserBaseInfo,
|
||||
pub number: i64,
|
||||
pub title: String,
|
||||
pub body: Option<String>,
|
||||
pub state: State,
|
||||
pub source_repo_id: Uuid,
|
||||
pub source_branch: String,
|
||||
pub target_repo_id: Uuid,
|
||||
pub target_branch: String,
|
||||
pub base_commit_sha: Option<String>,
|
||||
pub head_commit_sha: String,
|
||||
pub merge_commit_sha: Option<String>,
|
||||
pub draft: bool,
|
||||
pub locked: bool,
|
||||
pub merged_by: Option<Uuid>,
|
||||
pub merged_at: Option<DateTime<Utc>>,
|
||||
pub closed_by: Option<Uuid>,
|
||||
pub closed_at: Option<DateTime<Utc>>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
pub deleted_at: Option<DateTime<Utc>>,
|
||||
}
|
||||
|
||||
impl PullRequest {
|
||||
pub fn into_detail(self, author: UserBaseInfo) -> PullRequestDetail {
|
||||
PullRequestDetail {
|
||||
id: self.id,
|
||||
repo_id: self.repo_id,
|
||||
author,
|
||||
number: self.number,
|
||||
title: self.title,
|
||||
body: self.body,
|
||||
state: self.state,
|
||||
source_repo_id: self.source_repo_id,
|
||||
source_branch: self.source_branch,
|
||||
target_repo_id: self.target_repo_id,
|
||||
target_branch: self.target_branch,
|
||||
base_commit_sha: self.base_commit_sha,
|
||||
head_commit_sha: self.head_commit_sha,
|
||||
merge_commit_sha: self.merge_commit_sha,
|
||||
draft: self.draft,
|
||||
locked: self.locked,
|
||||
merged_by: self.merged_by,
|
||||
merged_at: self.merged_at,
|
||||
closed_by: self.closed_by,
|
||||
closed_at: self.closed_at,
|
||||
created_at: self.created_at,
|
||||
updated_at: self.updated_at,
|
||||
deleted_at: self.deleted_at,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user