Init
This commit is contained in:
33
src/interfaces/http/dto/user.rs
Normal file
33
src/interfaces/http/dto/user.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
use crate::models::user;
|
||||
use sea_orm::Set;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct UserResponse {
|
||||
pub id: Uuid,
|
||||
pub username: String,
|
||||
}
|
||||
|
||||
impl From<user::Model> for UserResponse {
|
||||
fn from(model: user::Model) -> Self {
|
||||
Self {
|
||||
id: model.id,
|
||||
username: model.username,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct CreateUserRequest {
|
||||
pub username: String,
|
||||
}
|
||||
|
||||
impl From<CreateUserRequest> for user::ActiveModel {
|
||||
fn from(request: CreateUserRequest) -> Self {
|
||||
Self {
|
||||
username: Set(request.username),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user