feat: Docker部署与CI/CD集成, 搜索栏修复, 上传目录改为data

This commit is contained in:
xiner
2025-11-28 18:42:30 +08:00
commit 8351d6bbfc
243 changed files with 13192 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import { NextApiResponse } from 'next';
import { AuthenticatedRequest, requireAuth } from '../../../../../lib/middleware/authMiddleware';
import { MaterialService } from '../../../../../backend/services/materialService';
export default async function handler(req: AuthenticatedRequest, res: NextApiResponse) {
if (req.method !== 'POST') {
return res.status(405).json({ success: false, error: 'Method not allowed' });
}
// Require authentication
const isAuthenticated = await requireAuth(req, res);
if (!isAuthenticated) {
return;
}
const { id } = req.query;
const { content } = req.body;
if (typeof id !== 'string') {
return res.status(400).json({ success: false, error: 'Invalid material ID' });
}
if (!content || !content.trim()) {
return res.status(400).json({ success: false, error: 'Comment content is required' });
}
try {
const comment = await MaterialService.addComment(id, req.user!.id, content);
return res.status(201).json({ success: true, data: comment });
} catch (error) {
console.error('Error adding comment:', error);
return res.status(500).json({ success: false, error: 'Failed to add comment' });
}
}