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
@@ -648,4 +648,39 @@ pub fn hackathon_routes() -> Router {
.route("/submissions/{id}", put(update_hackathon_submission))
.route("/submissions/{id}/submit", post(submit_hackathon_submission))
.route("/submissions/{id}", delete(delete_hackathon_submission))
// Participants
.route("/{id}/participants", post(register_participant))
.route("/{id}/participants", get(list_participants))
}
use super::hackathon_dto::RegisterParticipantRequestDto;
// Register a participant for a hackathon (persistent)
pub async fn register_participant(
Extension(state): Extension<AppState>,
Path(hackathon_id): Path<String>,
Json(payload): Json<RegisterParticipantRequestDto>,
) -> impl IntoResponse {
match HackathonService::register_participant(hackathon_id, payload, &state).await {
Ok(response) => {
let body = serde_json::json!({ "message": "Participant registered", "data": response.data });
(axum::http::StatusCode::OK, Json(body)).into_response()
}
Err(error) => (StatusCode::from_u16(error.status).unwrap(), Json(error)).into_response(),
}
}
// List participants for a hackathon
pub async fn list_participants(
Extension(state): Extension<AppState>,
Path(hackathon_id): Path<String>,
Query(meta): Query<imphnen_libs::MetaRequestDto>,
) -> impl IntoResponse {
match HackathonService::list_participants(meta, hackathon_id, &state).await {
Ok(response) => {
let body = serde_json::json!({ "message": "Success", "data": response.data, "meta": response.meta });
(axum::http::StatusCode::OK, Json(body)).into_response()
}
Err(error) => (StatusCode::from_u16(error.status).unwrap(), Json(error)).into_response(),
}
}