This commit is contained in:
2026-01-04 20:58:47 +09:00
parent a87c11597a
commit 0660ed3973
37 changed files with 1723 additions and 885 deletions

View File

@@ -1,4 +1,6 @@
import { execute, queryOne } from '../../../../utils/db'
import { getClientIp } from '../../../../utils/ip'
import { getCurrentUserEmail } from '../../../../utils/user'
/**
* 주간보고 제출
@@ -11,10 +13,12 @@ export default defineEventHandler(async (event) => {
}
const reportId = getRouterParam(event, 'id')
const clientIp = getClientIp(event)
const userEmail = await getCurrentUserEmail(event)
// 보고서 조회 및 권한 확인
const report = await queryOne<any>(`
SELECT * FROM wr_weekly_report_detail WHERE report_id = $1
SELECT * FROM wr_weekly_report WHERE report_id = $1
`, [reportId])
if (!report) {
@@ -25,13 +29,19 @@ export default defineEventHandler(async (event) => {
throw createError({ statusCode: 403, message: '본인의 보고서만 제출할 수 있습니다.' })
}
if (report.report_status !== 'DRAFT') {
throw createError({ statusCode: 400, message: '이미 제출된 보고서입니다.' })
}
await execute(`
UPDATE wr_weekly_report_detail SET
UPDATE wr_weekly_report SET
report_status = 'SUBMITTED',
submitted_at = NOW(),
updated_at = NOW()
WHERE report_id = $1
`, [reportId])
updated_at = NOW(),
updated_ip = $1,
updated_email = $2
WHERE report_id = $3
`, [clientIp, userEmail, reportId])
return { success: true }
})