54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import { queryOne } from '../../../utils/db'
|
|
|
|
/**
|
|
* TODO 상세 조회
|
|
* GET /api/todo/[id]/detail
|
|
*/
|
|
export default defineEventHandler(async (event) => {
|
|
const todoId = Number(getRouterParam(event, 'id'))
|
|
|
|
const todo = await queryOne(`
|
|
SELECT
|
|
t.*,
|
|
p.project_name,
|
|
m.meeting_title,
|
|
a.employee_name as assignee_name,
|
|
r.employee_name as reporter_name
|
|
FROM wr_todo t
|
|
LEFT JOIN wr_project_info p ON t.project_id = p.project_id
|
|
LEFT JOIN wr_meeting m ON t.meeting_id = m.meeting_id
|
|
LEFT JOIN wr_employee_info a ON t.assignee_id = a.employee_id
|
|
LEFT JOIN wr_employee_info r ON t.reporter_id = r.employee_id
|
|
WHERE t.todo_id = $1
|
|
`, [todoId])
|
|
|
|
if (!todo) {
|
|
throw createError({ statusCode: 404, message: 'TODO를 찾을 수 없습니다.' })
|
|
}
|
|
|
|
return {
|
|
todo: {
|
|
todoId: todo.todo_id,
|
|
todoTitle: todo.todo_title,
|
|
todoContent: todo.todo_content,
|
|
sourceType: todo.source_type,
|
|
sourceId: todo.source_id,
|
|
meetingId: todo.meeting_id,
|
|
meetingTitle: todo.meeting_title,
|
|
projectId: todo.project_id,
|
|
projectName: todo.project_name,
|
|
assigneeId: todo.assignee_id,
|
|
assigneeName: todo.assignee_name,
|
|
reporterId: todo.reporter_id,
|
|
reporterName: todo.reporter_name,
|
|
dueDate: todo.due_date,
|
|
status: todo.status,
|
|
priority: todo.priority,
|
|
completedAt: todo.completed_at,
|
|
weeklyReportId: todo.weekly_report_id,
|
|
createdAt: todo.created_at,
|
|
updatedAt: todo.updated_at
|
|
}
|
|
}
|
|
})
|