feat(m12): meetings + schedule conflict detection, tests, e2e
- MeetingRepository (CRUD, soft-delete, members, findMeetingsByUserInRange overlap) + CalendarRepository.findByCreatorInRange + TodoRepository. findHighPriorityByAssignee - MeetingService (createMeeting tx+members, meeting_invited notify, meeting_created activity, SSE meeting.created; updateMeeting/updateMinutes/ deleteMeeting; checkScheduleConflicts = other meetings overlap + calendar events overlap + high-priority todos due +-3d, time-overlap logic, excludeMeetingId; conflicts are warnings) - APIs: meetings list/create/edit + /check conflict check - Screens: meetings page + MeetingForm(member checkboxes, conflict display) + ConflictWarning, ProjectNav link - Unit tests (MeetingRepository, MeetingService incl. conflict algorithm) + e2e meetings
This commit is contained in:
58
app/api/projects/[projectId]/meetings/route.ts
Normal file
58
app/api/projects/[projectId]/meetings/route.ts
Normal file
@ -0,0 +1,58 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { getCurrentUser } from '@/lib/auth/getCurrentUser';
|
||||
import { createMeetingService } from '@/lib/api/services';
|
||||
import { UnauthorizedError } from '@/lib/errors';
|
||||
import { handleApiError, jsonError } from '@/lib/api/handleError';
|
||||
|
||||
export const runtime = 'nodejs';
|
||||
|
||||
export async function GET(
|
||||
_request: NextRequest,
|
||||
{ params }: { params: Promise<{ projectId: string }> }
|
||||
) {
|
||||
const user = await getCurrentUser();
|
||||
if (!user) return handleApiError(new UnauthorizedError());
|
||||
const { projectId } = await params;
|
||||
const service = createMeetingService();
|
||||
try {
|
||||
return NextResponse.json({
|
||||
meetings: service.getMeetings(user.id, Number(projectId)),
|
||||
});
|
||||
} catch (error) {
|
||||
return handleApiError(error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function POST(
|
||||
request: NextRequest,
|
||||
{ params }: { params: Promise<{ projectId: string }> }
|
||||
) {
|
||||
const user = await getCurrentUser();
|
||||
if (!user) return handleApiError(new UnauthorizedError());
|
||||
const { projectId } = await params;
|
||||
let body: Record<string, unknown>;
|
||||
try {
|
||||
body = (await request.json()) as Record<string, unknown>;
|
||||
} catch {
|
||||
return jsonError(400, 'リクエスト本文が不正です');
|
||||
}
|
||||
const service = createMeetingService();
|
||||
try {
|
||||
const result = service.createMeeting(user.id, Number(projectId), {
|
||||
title: String(body.title ?? ''),
|
||||
startAt: String(body.startAt ?? ''),
|
||||
endAt: String(body.endAt ?? ''),
|
||||
description:
|
||||
typeof body.description === 'string' ? body.description : null,
|
||||
location: typeof body.location === 'string' ? body.location : null,
|
||||
meetingUrl: typeof body.meetingUrl === 'string' ? body.meetingUrl : null,
|
||||
agendaMd: typeof body.agendaMd === 'string' ? body.agendaMd : null,
|
||||
memberIds: Array.isArray(body.memberIds)
|
||||
? body.memberIds.map(Number)
|
||||
: [],
|
||||
});
|
||||
return NextResponse.json(result, { status: 201 });
|
||||
} catch (error) {
|
||||
return handleApiError(error);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user