feat: add user profile management with update and retrieval endpoints, enhance database setup for testing
This commit is contained in:
@@ -10,6 +10,15 @@ pub struct Model {
|
||||
#[sea_orm(unique)]
|
||||
pub username: String,
|
||||
pub password_hash: Option<String>,
|
||||
#[sea_orm(unique)]
|
||||
pub email: Option<String>,
|
||||
pub display_name: Option<String>,
|
||||
pub bio: Option<String>,
|
||||
pub avatar_url: Option<String>,
|
||||
pub header_url: Option<String>,
|
||||
pub custom_css: Option<String>,
|
||||
pub created_at: DateTimeWithTimeZone,
|
||||
pub updated_at: DateTimeWithTimeZone,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
@@ -9,3 +9,26 @@ pub struct CreateUserParams {
|
||||
#[validate(length(min = 6))]
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Validate, ToSchema, Default)]
|
||||
pub struct UpdateUserParams {
|
||||
#[validate(length(max = 50))]
|
||||
#[schema(example = "Frutiger Aero Fan")]
|
||||
pub display_name: Option<String>,
|
||||
|
||||
#[validate(length(max = 160))]
|
||||
#[schema(example = "Est. 2004")]
|
||||
pub bio: Option<String>,
|
||||
|
||||
#[validate(url)]
|
||||
pub avatar_url: Option<String>,
|
||||
|
||||
#[validate(url)]
|
||||
pub header_url: Option<String>,
|
||||
|
||||
pub custom_css: Option<String>,
|
||||
|
||||
#[validate(length(max = 8))]
|
||||
#[schema(example = json!(["username1", "username2"]))]
|
||||
pub top_friends: Option<Vec<String>>,
|
||||
}
|
||||
|
@@ -1,3 +1,4 @@
|
||||
use common::DateTimeWithTimeZoneWrapper;
|
||||
use serde::Serialize;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
@@ -7,6 +8,15 @@ use crate::domains::user;
|
||||
pub struct UserSchema {
|
||||
pub id: i32,
|
||||
pub username: String,
|
||||
pub display_name: Option<String>,
|
||||
pub bio: Option<String>,
|
||||
pub avatar_url: Option<String>,
|
||||
pub header_url: Option<String>,
|
||||
pub custom_css: Option<String>,
|
||||
// In a real implementation, you'd fetch and return this data.
|
||||
// For now, we'll omit it from the schema to keep it simple.
|
||||
// pub top_friends: Vec<String>,
|
||||
pub joined_at: DateTimeWithTimeZoneWrapper,
|
||||
}
|
||||
|
||||
impl From<user::Model> for UserSchema {
|
||||
@@ -14,6 +24,12 @@ impl From<user::Model> for UserSchema {
|
||||
Self {
|
||||
id: user.id,
|
||||
username: user.username,
|
||||
display_name: user.display_name,
|
||||
bio: user.bio,
|
||||
avatar_url: user.avatar_url,
|
||||
header_url: user.header_url,
|
||||
custom_css: user.custom_css,
|
||||
joined_at: user.created_at.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user