59 lines
1.1 KiB
Rust
59 lines
1.1 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
use uuid::Uuid;
|
|
|
|
use crate::domain;
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct AccountMemberRequest {
|
|
pub user: UserRequest,
|
|
}
|
|
|
|
impl AccountMemberRequest {
|
|
pub fn into_domain(
|
|
self,
|
|
id: Uuid,
|
|
account_id: Uuid,
|
|
) -> Result<domain::AccountMember, domain::DomainError> {
|
|
Ok(domain::AccountMember {
|
|
id,
|
|
account_id,
|
|
user_id: self.user.id,
|
|
})
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Serialize)]
|
|
pub struct AccountMemberResponse {
|
|
pub id: Uuid,
|
|
pub user: UserResponse,
|
|
}
|
|
|
|
impl AccountMemberResponse {
|
|
pub fn new(member: domain::AccountMember, user: domain::User) -> Self {
|
|
Self {
|
|
id: member.id,
|
|
user: user.into(),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct UserRequest {
|
|
pub id: Uuid,
|
|
}
|
|
|
|
#[derive(Debug, Serialize)]
|
|
pub struct UserResponse {
|
|
pub id: Uuid,
|
|
pub name: Option<String>,
|
|
}
|
|
|
|
impl From<domain::User> for UserResponse {
|
|
fn from(user: domain::User) -> Self {
|
|
Self {
|
|
id: user.id,
|
|
name: user.name,
|
|
}
|
|
}
|
|
}
|