diff --git a/backend-node/src/app.ts b/backend-node/src/app.ts index d3b366cb..0a22af73 100644 --- a/backend-node/src/app.ts +++ b/backend-node/src/app.ts @@ -31,6 +31,7 @@ import layoutRoutes from "./routes/layoutRoutes"; import mailTemplateFileRoutes from "./routes/mailTemplateFileRoutes"; import mailAccountFileRoutes from "./routes/mailAccountFileRoutes"; import mailSendSimpleRoutes from "./routes/mailSendSimpleRoutes"; +import mailSentHistoryRoutes from "./routes/mailSentHistoryRoutes"; import mailReceiveBasicRoutes from "./routes/mailReceiveBasicRoutes"; import dataRoutes from "./routes/dataRoutes"; import testButtonDataflowRoutes from "./routes/testButtonDataflowRoutes"; @@ -186,6 +187,7 @@ app.use("/api/layouts", layoutRoutes); app.use("/api/mail/accounts", mailAccountFileRoutes); // 파일 기반 계정 app.use("/api/mail/templates-file", mailTemplateFileRoutes); // 파일 기반 템플릿 app.use("/api/mail/send", mailSendSimpleRoutes); // 메일 발송 +app.use("/api/mail/sent", mailSentHistoryRoutes); // 메일 발송 이력 app.use("/api/mail/receive", mailReceiveBasicRoutes); // 메일 수신 app.use("/api/screen", screenStandardRoutes); app.use("/api/data", dataRoutes); diff --git a/backend-node/src/routes/mailSentHistoryRoutes.ts b/backend-node/src/routes/mailSentHistoryRoutes.ts index 2f4c6f98..27b71c4d 100644 --- a/backend-node/src/routes/mailSentHistoryRoutes.ts +++ b/backend-node/src/routes/mailSentHistoryRoutes.ts @@ -7,12 +7,12 @@ const router = Router(); // 모든 라우트에 인증 미들웨어 적용 router.use(authenticateToken); +// GET /api/mail/sent/statistics - 통계 조회 (⚠️ 반드시 /:id 보다 먼저 정의) +router.get('/statistics', (req, res) => mailSentHistoryController.getStatistics(req, res)); + // GET /api/mail/sent - 발송 이력 목록 조회 router.get('/', (req, res) => mailSentHistoryController.getList(req, res)); -// GET /api/mail/sent/statistics - 통계 조회 -router.get('/statistics', (req, res) => mailSentHistoryController.getStatistics(req, res)); - // GET /api/mail/sent/:id - 특정 발송 이력 상세 조회 router.get('/:id', (req, res) => mailSentHistoryController.getById(req, res)); diff --git a/frontend/app/(main)/admin/mail/dashboard/page.tsx b/frontend/app/(main)/admin/mail/dashboard/page.tsx index 02bccb87..dd58c5ed 100644 --- a/frontend/app/(main)/admin/mail/dashboard/page.tsx +++ b/frontend/app/(main)/admin/mail/dashboard/page.tsx @@ -42,7 +42,27 @@ export default function MailDashboardPage() { try { const accounts = await getMailAccounts(); const templates = await getMailTemplates(); - const mailStats = await getMailStatistics(); + + // 메일 통계 조회 (실패 시 기본값 사용) + let mailStats = { + todayCount: 0, + thisMonthCount: 0, + successRate: 0, + }; + + try { + const stats = await getMailStatistics(); + if (stats && typeof stats === 'object') { + mailStats = { + todayCount: stats.todayCount || 0, + thisMonthCount: stats.thisMonthCount || 0, + successRate: stats.successRate || 0, + }; + } + } catch (error) { + console.error('메일 통계 조회 실패:', error); + // 기본값 사용 + } // 오늘 수신 메일 수 조회 (IMAP 실시간 조회) let receivedTodayCount = 0; @@ -62,7 +82,7 @@ export default function MailDashboardPage() { successRate: mailStats.successRate, }); } catch (error) { - // console.error('통계 로드 실패:', error); + console.error('통계 로드 실패:', error); } finally { setLoading(false); }