feat: Enhance hackathon submission and participant management

- Updated HackathonSubmissionsSchema to use Option types for team_id, project_name, description, technologies, submission_status, and submitted_at.
- Modified seed_hackathons and seed_test_submission scripts to accommodate new optional fields.
- Added routes for participant registration and listing in hackathon_controller.
- Implemented register_participant and list_participants functions in hackathon_controller.
- Introduced HackathonParticipantSchema and corresponding DTOs for participant management.
- Enhanced HackathonRepository with CRUD operations for hackathon participants.
- Updated HackathonService to include methods for participant registration and listing.
- Refactored TeamsService to allow admin-level updates and invitations, bypassing leader-only restrictions.
- Added validation for member emails in TeamsCreateRequestDto and TeamInviteRequestDto.
This commit is contained in:
MythEclipse
2025-10-11 15:06:12 +07:00
parent c10443f881
commit 6ef624c169
11 changed files with 549 additions and 59 deletions
@@ -7,6 +7,7 @@ use crate::v1::hackathon::hackathon_schema::{
HackathonEventType, HackathonEventsSchema, HackathonPhase, HackathonSchema,
HackathonStatus, HackathonSubmissionsSchema, HackathonTimelineSchema,
SubmissionStatus,
HackathonParticipantSchema,
};
// Hackathon DTOs
@@ -410,16 +411,46 @@ impl From<HackathonSubmissionsSchema> for HackathonSubmissionDto {
Self {
id: schema.id.id.to_raw(),
hackathon_id: schema.hackathon_id.id.to_raw(),
team_id: schema.team_id.id.to_raw(),
project_name: schema.project_name,
description: schema.description,
team_id: schema.team_id.map(|t| t.id.to_raw()).unwrap_or_default(),
project_name: schema.project_name.unwrap_or_default(),
description: schema.description.unwrap_or_default(),
repository_url: schema.repository_url,
demo_url: schema.demo_url,
slides_url: schema.slides_url,
technologies: schema.technologies,
submission_status: schema.submission_status,
technologies: schema.technologies.unwrap_or_default(),
submission_status: schema.submission_status.unwrap_or(super::hackathon_schema::SubmissionStatus::Draft),
judge_feedback: schema.judge_feedback,
submitted_at: schema.submitted_at,
submitted_at: schema.submitted_at.unwrap_or(chrono::Utc::now()),
is_deleted: schema.is_deleted,
created_at: schema.created_at,
updated_at: schema.updated_at,
}
}
}
// Hackathon Participant DTOs
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema, Validate)]
pub struct RegisterParticipantRequestDto {
#[validate(length(min = 1, message = "user_id cannot be empty"))]
pub user_id: String,
}
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
pub struct HackathonParticipantDto {
pub id: String,
pub hackathon_id: String,
pub user_id: String,
pub is_deleted: bool,
pub created_at: Option<String>,
pub updated_at: Option<String>,
}
impl From<HackathonParticipantSchema> for HackathonParticipantDto {
fn from(schema: HackathonParticipantSchema) -> Self {
Self {
id: schema.id.id.to_raw(),
hackathon_id: schema.hackathon_id.id.to_raw(),
user_id: schema.user_id,
is_deleted: schema.is_deleted,
created_at: schema.created_at,
updated_at: schema.updated_at,