"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const router_1 = __importDefault(require("@koa/router")); const notifications_service_1 = require("./notifications.service"); const router = new router_1.default({ prefix: '/api/notifications' }); // 测试用户ID const TEST_USER_ID = 'test-user'; /** * 获取通知列表 * GET /api/notifications */ router.get('/', async (ctx) => { try { const notifications = await notifications_service_1.notificationsService.getNotifications(TEST_USER_ID); ctx.body = { code: 0, message: 'success', data: notifications, }; } catch (error) { ctx.body = { code: 400, message: error.message || '获取通知失败', }; } }); /** * 标记通知为已读 * POST /api/notifications/read */ router.post('/read', async (ctx) => { try { const { id } = ctx.request.body; await notifications_service_1.notificationsService.markAsRead(id); ctx.body = { code: 0, message: 'success', }; } catch (error) { ctx.body = { code: 400, message: error.message || '标记失败', }; } }); exports.default = router;