Files
zhenyi 9eb77ab98b 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
2026-06-10 18:49:37 +08:00

90 lines
2.8 KiB
Rust

use crate::models::base_info::UserBaseInfo;
use crate::models::common::State;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, sqlx::FromRow, utoipa::ToSchema)]
pub struct PullRequest {
pub id: Uuid,
pub repo_id: Uuid,
pub author_id: Uuid,
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>>,
}
#[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,
}
}
}