add
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"server/internal/db"
|
||||
"server/internal/handlers"
|
||||
@@ -52,7 +53,8 @@ func main() {
|
||||
mailer := mail.LoadConfigFromEnv()
|
||||
|
||||
app := fiber.New(fiber.Config{
|
||||
AppName: "Simple Care Sync Backend",
|
||||
AppName: "Simple Care Sync Backend",
|
||||
BodyLimit: 100 * 1024 * 1024, // 100MB — upload PDF gói đề
|
||||
})
|
||||
|
||||
app.Use(cors.New(cors.Config{
|
||||
@@ -89,7 +91,10 @@ func main() {
|
||||
api.Post("/student/report-blocked-app", handlers.ReportBlockedAppHandler(gormDB))
|
||||
api.Get("/student/chat/messages", handlers.StudentListChatHandler(gormDB))
|
||||
api.Get("/student/chat/conversations", handlers.StudentListChatConversationsHandler(gormDB))
|
||||
api.Post("/student/chat/messages", handlers.StudentSendChatHandler(gormDB))
|
||||
api.Get("/student/exam", handlers.GetStudentExamHandler(gormDB))
|
||||
api.Get("/student/exam/paper-files", handlers.GetStudentExamPaperFilesHandler(gormDB))
|
||||
api.Get("/student/exam/download", handlers.DownloadStudentExamFileHandler(gormDB))
|
||||
api.Post("/student/exam/submit", handlers.SubmitStudentExamHandler(gormDB))
|
||||
|
||||
// Health check (public)
|
||||
api.Get("/health", func(c *fiber.Ctx) error {
|
||||
@@ -152,6 +157,35 @@ func main() {
|
||||
staff.Delete("/admin/email-domains/:id", handlers.DeleteEmailDomainHandler(gormDB))
|
||||
staff.Get("/admin/staff", handlers.ListStaffHandler(gormDB))
|
||||
|
||||
// Phòng thi
|
||||
staff.Get("/exam-rooms", handlers.ListExamRoomsHandler(gormDB))
|
||||
staff.Post("/exam-rooms", handlers.CreateExamRoomHandler(gormDB))
|
||||
staff.Get("/exam-rooms/search-students", handlers.SearchExamStudentsHandler(gormDB))
|
||||
staff.Get("/exam-rooms/:id", handlers.GetExamRoomHandler(gormDB))
|
||||
staff.Get("/exam-rooms/:id/online-students", handlers.GetExamRoomOnlineStudentsHandler(gormDB))
|
||||
staff.Patch("/exam-rooms/:id", handlers.UpdateExamRoomHandler(gormDB))
|
||||
staff.Delete("/exam-rooms/:id", handlers.DeleteExamRoomHandler(gormDB))
|
||||
staff.Post("/exam-rooms/:id/students", handlers.AddExamRoomStudentsHandler(gormDB))
|
||||
staff.Delete("/exam-rooms/:id/students/:studentRkId", handlers.RemoveExamRoomStudentHandler(gormDB))
|
||||
staff.Post("/exam-rooms/:id/papers", handlers.UploadExamPaperHandler(gormDB))
|
||||
staff.Post("/exam-rooms/:id/papers/:paperId/resources", handlers.UploadExamPaperResourceHandler(gormDB))
|
||||
staff.Delete("/exam-rooms/:id/papers/:paperId", handlers.DeleteExamPaperHandler(gormDB))
|
||||
staff.Post("/exam-rooms/:id/publish", handlers.PublishExamRoomHandler(gormDB))
|
||||
staff.Post("/exam-rooms/:id/unpublish", handlers.UnpublishExamRoomHandler(gormDB))
|
||||
staff.Post("/exam-rooms/:id/cancel", handlers.CancelExamRoomHandler(gormDB))
|
||||
staff.Post("/exam-rooms/:id/assign-random", handlers.RandomAssignExamPapersHandler(gormDB))
|
||||
staff.Post("/exam-rooms/:id/send-papers", handlers.SendExamPapersHandler(gormDB))
|
||||
staff.Get("/exam-rooms/:id/submissions", handlers.ListExamSubmissionsHandler(gormDB))
|
||||
staff.Get("/exam-rooms/:id/submissions/:subId/download", handlers.DownloadExamSubmissionHandler(gormDB))
|
||||
|
||||
go func() {
|
||||
ticker := time.NewTicker(30 * time.Second)
|
||||
defer ticker.Stop()
|
||||
for range ticker.C {
|
||||
handlers.ProcessScheduledExamSends(gormDB)
|
||||
}
|
||||
}()
|
||||
|
||||
port := getEnv("PORT", "8080")
|
||||
log.Printf("Server starting on port %s...", port)
|
||||
if err := app.Listen(":" + port); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user