추가
This commit is contained in:
48
backend/api/report/weekly/[id]/detail.get.ts
Normal file
48
backend/api/report/weekly/[id]/detail.get.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { queryOne } from '../../../../utils/db'
|
||||
|
||||
/**
|
||||
* 주간보고 상세 조회
|
||||
* GET /api/report/weekly/[id]/detail
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const userId = getCookie(event, 'user_id')
|
||||
if (!userId) {
|
||||
throw createError({ statusCode: 401, message: '로그인이 필요합니다.' })
|
||||
}
|
||||
|
||||
const reportId = getRouterParam(event, 'id')
|
||||
|
||||
const report = await queryOne<any>(`
|
||||
SELECT r.*, p.project_name, p.project_code, e.employee_name as author_name
|
||||
FROM wr_weekly_report_detail r
|
||||
JOIN wr_project_info p ON r.project_id = p.project_id
|
||||
JOIN wr_employee_info e ON r.author_id = e.employee_id
|
||||
WHERE r.report_id = $1
|
||||
`, [reportId])
|
||||
|
||||
if (!report) {
|
||||
throw createError({ statusCode: 404, message: '보고서를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
return {
|
||||
reportId: report.report_id,
|
||||
projectId: report.project_id,
|
||||
projectName: report.project_name,
|
||||
projectCode: report.project_code,
|
||||
authorId: report.author_id,
|
||||
authorName: report.author_name,
|
||||
reportYear: report.report_year,
|
||||
reportWeek: report.report_week,
|
||||
weekStartDate: report.week_start_date,
|
||||
weekEndDate: report.week_end_date,
|
||||
workDescription: report.work_description,
|
||||
planDescription: report.plan_description,
|
||||
issueDescription: report.issue_description,
|
||||
remarkDescription: report.remark_description,
|
||||
workHours: report.work_hours,
|
||||
reportStatus: report.report_status,
|
||||
submittedAt: report.submitted_at,
|
||||
createdAt: report.created_at,
|
||||
updatedAt: report.updated_at
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user