추가
This commit is contained in:
65
backend/api/report/summary/[id]/detail.get.ts
Normal file
65
backend/api/report/summary/[id]/detail.get.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { queryOne, query } from '../../../../utils/db'
|
||||
|
||||
/**
|
||||
* 취합 보고서 상세 (개별 보고서 포함)
|
||||
* GET /api/report/summary/[id]/detail
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const summaryId = getRouterParam(event, 'id')
|
||||
|
||||
// 취합 보고서 조회
|
||||
const summary = await queryOne<any>(`
|
||||
SELECT s.*, p.project_name, p.project_code,
|
||||
e.employee_name as reviewer_name
|
||||
FROM wr_aggregated_report_summary s
|
||||
JOIN wr_project_info p ON s.project_id = p.project_id
|
||||
LEFT JOIN wr_employee_info e ON s.reviewer_id = e.employee_id
|
||||
WHERE s.summary_id = $1
|
||||
`, [summaryId])
|
||||
|
||||
if (!summary) {
|
||||
throw createError({ statusCode: 404, message: '취합 보고서를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
// 개별 보고서 목록
|
||||
const reports = await query(`
|
||||
SELECT r.*, e.employee_name as author_name, e.employee_position
|
||||
FROM wr_weekly_report_detail r
|
||||
JOIN wr_employee_info e ON r.author_id = e.employee_id
|
||||
WHERE r.project_id = $1 AND r.report_year = $2 AND r.report_week = $3
|
||||
ORDER BY e.employee_name
|
||||
`, [summary.project_id, summary.report_year, summary.report_week])
|
||||
|
||||
return {
|
||||
summary: {
|
||||
summaryId: summary.summary_id,
|
||||
projectId: summary.project_id,
|
||||
projectName: summary.project_name,
|
||||
projectCode: summary.project_code,
|
||||
reportYear: summary.report_year,
|
||||
reportWeek: summary.report_week,
|
||||
weekStartDate: summary.week_start_date,
|
||||
weekEndDate: summary.week_end_date,
|
||||
memberCount: summary.member_count,
|
||||
totalWorkHours: summary.total_work_hours,
|
||||
reviewerId: summary.reviewer_id,
|
||||
reviewerName: summary.reviewer_name,
|
||||
reviewerComment: summary.reviewer_comment,
|
||||
reviewedAt: summary.reviewed_at,
|
||||
summaryStatus: summary.summary_status
|
||||
},
|
||||
reports: reports.map((r: any) => ({
|
||||
reportId: r.report_id,
|
||||
authorId: r.author_id,
|
||||
authorName: r.author_name,
|
||||
authorPosition: r.employee_position,
|
||||
workDescription: r.work_description,
|
||||
planDescription: r.plan_description,
|
||||
issueDescription: r.issue_description,
|
||||
remarkDescription: r.remark_description,
|
||||
workHours: r.work_hours,
|
||||
reportStatus: r.report_status,
|
||||
submittedAt: r.submitted_at
|
||||
}))
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user