nxtgauge-backend-rust/apps/ugc_content_creators/src/handlers.rs
Ashwin Kumar 89b055b329 Add UGC Content Creator microservice (10th professional role)
- New service at apps/ugc_content_creators (port 8095)
- DB model + repository in crates/db/src/models/ugc_content_creator.rs
- Migration: ugc_content_creator_profiles table with platforms, content_niches,
  content_formats, follower_count, handles, and standard status/timestamps
- Contracts: is_professional_profile_approved() handles UGC_CONTENT_CREATOR case
- Gateway: routes /api/ugc-content-creators to new service
- Workspace Cargo.toml updated with new member

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-05 21:14:02 +02:00

28 lines
1.3 KiB
Rust

use axum::{extract::State, http::StatusCode, response::IntoResponse, routing::get, Json, Router};
use db::models::ugc_content_creator::{UgcContentCreatorRepository, UpsertUgcContentCreatorProfilePayload};
use contracts::{auth_middleware::AuthUser, ProfessionState};
pub fn router() -> Router<ProfessionState> {
Router::new()
.route("/profile/me", get(get_profile).patch(update_profile))
.merge(contracts::profession_shared::shared_routes("UGC_CONTENT_CREATOR"))
}
async fn get_profile(State(state): State<ProfessionState>, auth: AuthUser) -> impl IntoResponse {
match UgcContentCreatorRepository::get_by_user_id(&state.pool, auth.user_id).await {
Ok(Some(p)) => (StatusCode::OK, Json(p)).into_response(),
Ok(None) => (StatusCode::NOT_FOUND, "Profile not found").into_response(),
Err(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(),
}
}
async fn update_profile(
State(state): State<ProfessionState>,
auth: AuthUser,
Json(payload): Json<UpsertUgcContentCreatorProfilePayload>,
) -> impl IntoResponse {
match UgcContentCreatorRepository::upsert(&state.pool, auth.user_id, payload).await {
Ok(p) => (StatusCode::OK, Json(p)).into_response(),
Err(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(),
}
}