기능구현중
This commit is contained in:
30
server/api/business-report/[id]/confirm.put.ts
Normal file
30
server/api/business-report/[id]/confirm.put.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { execute, queryOne } from '../../../utils/db'
|
||||
|
||||
/**
|
||||
* 사업 주간보고 확정
|
||||
* PUT /api/business-report/[id]/confirm
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const businessReportId = Number(getRouterParam(event, 'id'))
|
||||
|
||||
const existing = await queryOne(`
|
||||
SELECT * FROM wr_business_weekly_report WHERE business_report_id = $1
|
||||
`, [businessReportId])
|
||||
|
||||
if (!existing) {
|
||||
throw createError({ statusCode: 404, message: '보고서를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
if (existing.status === 'confirmed') {
|
||||
throw createError({ statusCode: 400, message: '이미 확정된 보고서입니다.' })
|
||||
}
|
||||
|
||||
await execute(`
|
||||
UPDATE wr_business_weekly_report SET
|
||||
status = 'confirmed',
|
||||
updated_at = NOW()
|
||||
WHERE business_report_id = $1
|
||||
`, [businessReportId])
|
||||
|
||||
return { success: true, message: '보고서가 확정되었습니다.' }
|
||||
})
|
||||
80
server/api/business-report/[id]/detail.get.ts
Normal file
80
server/api/business-report/[id]/detail.get.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
import { query, queryOne } from '../../../utils/db'
|
||||
|
||||
/**
|
||||
* 사업 주간보고 상세 조회
|
||||
* GET /api/business-report/[id]/detail
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const businessReportId = Number(getRouterParam(event, 'id'))
|
||||
|
||||
const report = await queryOne(`
|
||||
SELECT
|
||||
br.*,
|
||||
b.business_name,
|
||||
e.employee_name as created_by_name
|
||||
FROM wr_business_weekly_report br
|
||||
JOIN wr_business b ON br.business_id = b.business_id
|
||||
LEFT JOIN wr_employee_info e ON br.created_by = e.employee_id
|
||||
WHERE br.business_report_id = $1
|
||||
`, [businessReportId])
|
||||
|
||||
if (!report) {
|
||||
throw createError({ statusCode: 404, message: '보고서를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
// 소속 프로젝트 목록
|
||||
const projects = await query(`
|
||||
SELECT project_id, project_name FROM wr_project_info WHERE business_id = $1
|
||||
`, [report.business_id])
|
||||
|
||||
const projectIds = projects.map((p: any) => p.project_id)
|
||||
|
||||
// 해당 주차 실적 목록
|
||||
const tasks = await query(`
|
||||
SELECT
|
||||
t.task_id,
|
||||
t.task_description,
|
||||
t.task_type,
|
||||
t.task_hours,
|
||||
p.project_id,
|
||||
p.project_name,
|
||||
e.employee_id,
|
||||
e.employee_name
|
||||
FROM wr_weekly_report_task t
|
||||
JOIN wr_weekly_report r ON t.report_id = r.report_id
|
||||
JOIN wr_project_info p ON t.project_id = p.project_id
|
||||
JOIN wr_employee_info e ON r.author_id = e.employee_id
|
||||
WHERE t.project_id = ANY($1)
|
||||
AND r.report_year = $2
|
||||
AND r.report_week = $3
|
||||
ORDER BY p.project_name, e.employee_name
|
||||
`, [projectIds, report.report_year, report.report_week])
|
||||
|
||||
return {
|
||||
report: {
|
||||
businessReportId: report.business_report_id,
|
||||
businessId: report.business_id,
|
||||
businessName: report.business_name,
|
||||
reportYear: report.report_year,
|
||||
reportWeek: report.report_week,
|
||||
weekStartDate: report.week_start_date,
|
||||
weekEndDate: report.week_end_date,
|
||||
aiSummary: report.ai_summary,
|
||||
manualSummary: report.manual_summary,
|
||||
status: report.status,
|
||||
createdByName: report.created_by_name,
|
||||
createdAt: report.created_at,
|
||||
updatedAt: report.updated_at
|
||||
},
|
||||
tasks: tasks.map((t: any) => ({
|
||||
taskId: t.task_id,
|
||||
taskDescription: t.task_description,
|
||||
taskType: t.task_type,
|
||||
taskHours: t.task_hours,
|
||||
projectId: t.project_id,
|
||||
projectName: t.project_name,
|
||||
employeeId: t.employee_id,
|
||||
employeeName: t.employee_name
|
||||
}))
|
||||
}
|
||||
})
|
||||
31
server/api/business-report/[id]/update.put.ts
Normal file
31
server/api/business-report/[id]/update.put.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { execute, queryOne } from '../../../utils/db'
|
||||
|
||||
/**
|
||||
* 사업 주간보고 수정
|
||||
* PUT /api/business-report/[id]/update
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const businessReportId = Number(getRouterParam(event, 'id'))
|
||||
const body = await readBody<{ manualSummary: string }>(event)
|
||||
|
||||
const existing = await queryOne(`
|
||||
SELECT * FROM wr_business_weekly_report WHERE business_report_id = $1
|
||||
`, [businessReportId])
|
||||
|
||||
if (!existing) {
|
||||
throw createError({ statusCode: 404, message: '보고서를 찾을 수 없습니다.' })
|
||||
}
|
||||
|
||||
if (existing.status === 'confirmed') {
|
||||
throw createError({ statusCode: 400, message: '확정된 보고서는 수정할 수 없습니다.' })
|
||||
}
|
||||
|
||||
await execute(`
|
||||
UPDATE wr_business_weekly_report SET
|
||||
manual_summary = $1,
|
||||
updated_at = NOW()
|
||||
WHERE business_report_id = $2
|
||||
`, [body.manualSummary, businessReportId])
|
||||
|
||||
return { success: true }
|
||||
})
|
||||
Reference in New Issue
Block a user