同步工作区剩余变更,主要包括: - 营销页面组件与布局持续优化(about/news/services/solutions/team 等) - 详情页四层叙事组件、布局组件、UI 组件调整 - CMS 数据模型、API 路由、权限、工作流、站内通知、媒体管理扩展 - 新增/补充单元测试与 E2E 测试(cms-workflow.spec.ts 等) - ESLint 9 迁移、jest/tsconfig 配置更新、依赖调整 - 新增 ADR、CMS 评估文档、Release Review / Acceptance 报告 - 移除水墨装饰组件与大体积未使用字体文件
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { NextRequest } from 'next/server';
|
|
import { authenticateRequest } from '@/lib/auth';
|
|
import { getUserNotifications } from '@/lib/cms/notifications';
|
|
import { success, unauthorized, validationError, internalError } from '@/lib/api-response';
|
|
|
|
// GET /api/admin/notifications - 获取当前用户通知列表
|
|
export async function GET(request: NextRequest) {
|
|
const user = authenticateRequest(request);
|
|
if (!user) return unauthorized();
|
|
|
|
try {
|
|
const { searchParams } = new URL(request.url);
|
|
const page = parseInt(searchParams.get('page') || '1', 10);
|
|
const pageSize = parseInt(searchParams.get('pageSize') || '20', 10);
|
|
const unreadOnly = searchParams.get('unreadOnly') === 'true';
|
|
|
|
if (Number.isNaN(page) || page < 1) {
|
|
return validationError('page 参数非法');
|
|
}
|
|
if (Number.isNaN(pageSize) || pageSize < 1 || pageSize > 100) {
|
|
return validationError('pageSize 参数非法');
|
|
}
|
|
|
|
const result = await getUserNotifications(user.userId, { page, pageSize, unreadOnly });
|
|
return success(result);
|
|
} catch (error) {
|
|
console.error('Get notifications error:', error);
|
|
return internalError();
|
|
}
|
|
}
|