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,28 @@
import { NextApiResponse } from 'next';
import { AuthenticatedRequest } from '@/lib/middleware/authMiddleware';
import { requireAdmin } from '@/lib/middleware/adminMiddleware';
import { UserService } from '@/backend/services/userService';
export default async function handler(req: AuthenticatedRequest, res: NextApiResponse) {
if (req.method !== 'POST') {
return res.status(405).json({ success: false, error: 'Method not allowed' });
}
const isAdmin = await requireAdmin(req, res);
if (!isAdmin) return;
const { id } = req.query;
const { role } = req.body || {};
if (typeof id !== 'string' || typeof role !== 'string') {
return res.status(400).json({ success: false, error: 'Invalid input' });
}
try {
const updated = await UserService.updateUserRole(id, role as any);
return res.status(200).json({ success: true, data: updated });
} catch (error) {
console.error('Error updating role:', error);
return res.status(500).json({ success: false, error: 'Failed to update role' });
}
}

View File

@@ -0,0 +1,30 @@
import { NextApiResponse } from 'next';
import { AuthenticatedRequest } from '../../../../../../lib/middleware/authMiddleware';
import { requireAdmin } from '../../../../../../lib/middleware/adminMiddleware';
import { UserService } from '../../../../../../backend/services/userService';
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 admin authentication
const isAdmin = await requireAdmin(req, res);
if (!isAdmin) {
return;
}
const { id } = req.query;
if (typeof id !== 'string') {
return res.status(400).json({ success: false, error: 'Invalid user ID' });
}
try {
const updatedUser = await UserService.toggleUserStatus(id);
return res.status(200).json({ success: true, data: updatedUser });
} catch (error) {
console.error('Error toggling user status:', error);
return res.status(500).json({ success: false, error: 'Failed to toggle user status' });
}
}