feat: migrate imphnen-backend-qr into workspace as imphnen-qr crate
Ports the Go QR campaign overlay service to a self-contained Rust crate nested at /v1/qr/... in the gateway. Features: - Auth: register, login, Google OAuth, JWT refresh (bcrypt compat with Go DB) - Users: profile management + admin CRUD (list/role/delete) - Campaigns: create (auto-generates QR PNG via qrcode crate), list, activate, delete; process-image endpoint overlays active campaign QR onto uploaded images (bottom-right corner, image crate) - QR pool connects to imphnen_qr database via QR_DATABASE_URL Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
5715e75593
commit
4bba182ea3
@@ -0,0 +1 @@
|
||||
pub mod user_service;
|
||||
@@ -0,0 +1,51 @@
|
||||
use async_trait::async_trait;
|
||||
use imphnen_utils::errors::AppError;
|
||||
use std::sync::Arc;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::users::domain::{
|
||||
entity::{UpdateUserInput, UserEntity},
|
||||
repository::UserRepository,
|
||||
service::QrUserService,
|
||||
};
|
||||
|
||||
pub struct QrUserServiceImpl {
|
||||
repo: Arc<dyn UserRepository>,
|
||||
}
|
||||
|
||||
impl QrUserServiceImpl {
|
||||
pub fn new(repo: Arc<dyn UserRepository>) -> Self {
|
||||
Self { repo }
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl QrUserService for QrUserServiceImpl {
|
||||
async fn get_profile(&self, user_id: Uuid) -> Result<UserEntity, AppError> {
|
||||
self.repo
|
||||
.find_by_id(user_id)
|
||||
.await?
|
||||
.ok_or_else(|| AppError::NotFoundError("User not found".to_string()))
|
||||
}
|
||||
|
||||
async fn update_profile(&self, user_id: Uuid, input: UpdateUserInput) -> Result<UserEntity, AppError> {
|
||||
if let Some(ref email) = input.email {
|
||||
if email.trim().is_empty() {
|
||||
return Err(AppError::ValidationError("Email cannot be empty".to_string()));
|
||||
}
|
||||
}
|
||||
self.repo.update(user_id, input).await
|
||||
}
|
||||
|
||||
async fn list_all(&self) -> Result<Vec<UserEntity>, AppError> {
|
||||
self.repo.find_all().await
|
||||
}
|
||||
|
||||
async fn update_role(&self, id: Uuid, role: String) -> Result<UserEntity, AppError> {
|
||||
self.repo.update_role(id, role).await
|
||||
}
|
||||
|
||||
async fn delete(&self, id: Uuid) -> Result<(), AppError> {
|
||||
self.repo.delete(id).await
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user