use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum UserIdType {
#[serde(rename = "user_id")]
UserId,
#[serde(rename = "union_id")]
UnionId,
#[serde(rename = "open_id")]
OpenId,
}
impl UserIdType {
pub fn as_str(&self) -> &'static str {
match self {
UserIdType::UserId => "user_id",
UserIdType::UnionId => "union_id",
UserIdType::OpenId => "open_id",
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum DepartmentIdType {
#[serde(rename = "department_id")]
DepartmentId,
#[serde(rename = "open_department_id")]
OpenDepartmentId,
}
impl DepartmentIdType {
pub fn as_str(&self) -> &'static str {
match self {
DepartmentIdType::DepartmentId => "department_id",
DepartmentIdType::OpenDepartmentId => "open_department_id",
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum ApprovalStatus {
#[serde(rename = "PENDING")]
Pending,
#[serde(rename = "APPROVED")]
Approved,
#[serde(rename = "REJECTED")]
Rejected,
#[serde(rename = "CANCELED")]
Canceled,
#[serde(rename = "DELETED")]
Deleted,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum TaskStatus {
#[serde(rename = "PENDING")]
Pending,
#[serde(rename = "APPROVED")]
Approved,
#[serde(rename = "REJECTED")]
Rejected,
#[serde(rename = "TRANSFERRED")]
Transferred,
#[serde(rename = "DONE")]
Done,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Approval {
pub approval_code: String,
pub approval_name: String,
pub description: Option<String>,
pub status: Option<String>,
pub creator: Option<UserInfo>,
pub create_time: Option<String>,
pub update_time: Option<String>,
pub form: Option<Vec<FormField>>,
pub process: Option<ApprovalProcess>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApprovalInstance {
pub instance_code: String,
pub approval_code: String,
pub approval_name: Option<String>,
pub initiator: Option<UserInfo>,
pub status: ApprovalStatus,
pub create_time: Option<String>,
pub update_time: Option<String>,
pub form: Option<Vec<FormData>>,
pub timeline: Option<Vec<ApprovalNode>>,
pub cc_users: Option<Vec<UserInfo>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApprovalTask {
pub task_id: String,
pub instance_code: String,
pub approval_code: String,
pub approval_name: Option<String>,
pub initiator: Option<UserInfo>,
pub approver: Option<UserInfo>,
pub status: TaskStatus,
pub create_time: Option<String>,
pub update_time: Option<String>,
pub task_links: Option<Vec<TaskLink>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserInfo {
pub user_id: String,
pub name: Option<String>,
pub avatar: Option<String>,
pub email: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FormField {
pub id: String,
pub name: String,
pub field_type: String,
pub required: Option<bool>,
pub properties: Option<serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FormData {
pub id: String,
pub name: Option<String>,
pub value: Option<serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApprovalProcess {
pub nodes: Vec<ProcessNode>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProcessNode {
pub node_id: String,
pub node_name: Option<String>,
pub node_type: String,
pub approvers: Option<Vec<UserInfo>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApprovalNode {
pub node_id: String,
pub node_name: Option<String>,
pub node_type: String,
pub approver: Option<UserInfo>,
pub status: Option<String>,
pub approve_time: Option<String>,
pub comment: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TaskLink {
pub platform: String,
pub link: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApprovalFile {
pub file_id: String,
pub filename: String,
pub file_size: Option<i64>,
pub file_type: Option<String>,
pub upload_time: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApprovalComment {
pub comment_id: String,
pub content: String,
pub commenter: Option<UserInfo>,
pub create_time: Option<String>,
pub update_time: Option<String>,
pub attachments: Option<Vec<CommentAttachment>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CommentAttachment {
pub attachment_id: String,
pub name: String,
pub attachment_type: String,
pub link: Option<String>,
}