기능구현중

This commit is contained in:
2026-01-11 17:01:01 +09:00
parent 375d5bf91a
commit 954ba21211
148 changed files with 2276 additions and 0 deletions

View File

@@ -1,50 +0,0 @@
import { queryOne, query } from '../../../utils/db'
/**
* 프로젝트 상세 조회
* GET /api/project/[id]/detail
*/
export default defineEventHandler(async (event) => {
const projectId = getRouterParam(event, 'id')
const project = await queryOne<any>(`
SELECT p.*, b.business_name, b.business_code
FROM wr_project_info p
LEFT JOIN wr_business b ON p.business_id = b.business_id
WHERE p.project_id = $1
`, [projectId])
if (!project) {
throw createError({ statusCode: 404, message: '프로젝트를 찾을 수 없습니다.' })
}
// 현재 PM/PL
const managers = await query(`
SELECT * FROM wr_project_manager_current WHERE project_id = $1
`, [projectId])
const pm = managers.find((m: any) => m.role_type === 'PM')
const pl = managers.find((m: any) => m.role_type === 'PL')
return {
project: {
projectId: project.project_id,
projectCode: project.project_code,
projectName: project.project_name,
projectType: project.project_type || 'SI',
clientName: project.client_name,
projectDescription: project.project_description,
startDate: project.start_date,
endDate: project.end_date,
contractAmount: project.contract_amount,
projectStatus: project.project_status,
businessId: project.business_id,
businessName: project.business_name,
businessCode: project.business_code,
createdAt: project.created_at,
updatedAt: project.updated_at,
currentPm: pm ? { employeeId: pm.employee_id, employeeName: pm.employee_name } : null,
currentPl: pl ? { employeeId: pl.employee_id, employeeName: pl.employee_name } : null
}
}
})

View File

@@ -1,58 +0,0 @@
import { execute, queryOne, insertReturning } from '../../../utils/db'
import { formatDate } from '../../../utils/week-calc'
import { getClientIp } from '../../../utils/ip'
import { getCurrentUserEmail } from '../../../utils/user'
interface AssignManagerBody {
employeeId: number
roleType: 'PM' | 'PL'
startDate?: string
changeReason?: string
}
/**
* PM/PL 지정 (기존 담당자 종료 + 신규 등록)
* POST /api/project/[id]/manager-assign
*/
export default defineEventHandler(async (event) => {
const projectId = getRouterParam(event, 'id')
const body = await readBody<AssignManagerBody>(event)
const clientIp = getClientIp(event)
const userEmail = await getCurrentUserEmail(event)
if (!body.employeeId || !body.roleType) {
throw createError({ statusCode: 400, message: '담당자와 역할을 선택해주세요.' })
}
if (!['PM', 'PL'].includes(body.roleType)) {
throw createError({ statusCode: 400, message: '역할은 PM 또는 PL만 가능합니다.' })
}
const today = formatDate(new Date())
const startDate = body.startDate || today
// 기존 담당자 종료 (end_date가 NULL인 경우)
await execute(`
UPDATE wr_project_manager_history SET
end_date = $1,
change_reason = COALESCE(change_reason || ' / ', '') || '신규 담당자 지정으로 종료',
updated_at = NOW(),
updated_ip = $2,
updated_email = $3
WHERE project_id = $4 AND role_type = $5 AND end_date IS NULL
`, [startDate, clientIp, userEmail, projectId, body.roleType])
// 신규 담당자 등록
const history = await insertReturning(`
INSERT INTO wr_project_manager_history (
project_id, employee_id, role_type, start_date, change_reason,
created_ip, created_email, updated_ip, updated_email
) VALUES ($1, $2, $3, $4, $5, $6, $7, $6, $7)
RETURNING *
`, [projectId, body.employeeId, body.roleType, startDate, body.changeReason || null, clientIp, userEmail])
return {
success: true,
historyId: history.history_id
}
})

View File

@@ -1,30 +0,0 @@
import { query } from '../../../utils/db'
/**
* 프로젝트 PM/PL 이력 조회
* GET /api/project/[id]/manager-history
*/
export default defineEventHandler(async (event) => {
const projectId = getRouterParam(event, 'id')
const history = await query(`
SELECT h.*, e.employee_name, e.employee_email
FROM wr_project_manager_history h
JOIN wr_employee_info e ON h.employee_id = e.employee_id
WHERE h.project_id = $1
ORDER BY h.role_type, h.start_date DESC
`, [projectId])
return history.map((h: any) => ({
historyId: h.history_id,
projectId: h.project_id,
employeeId: h.employee_id,
employeeName: h.employee_name,
employeeEmail: h.employee_email,
roleType: h.role_type,
startDate: h.start_date,
endDate: h.end_date,
changeReason: h.change_reason,
createdAt: h.created_at
}))
})

View File

@@ -1,71 +0,0 @@
import { execute, queryOne } from '../../../utils/db'
import { getClientIp } from '../../../utils/ip'
import { getCurrentUserEmail } from '../../../utils/user'
interface UpdateProjectBody {
projectName?: string
projectType?: string
clientName?: string
projectDescription?: string
startDate?: string
endDate?: string
contractAmount?: number
projectStatus?: string
businessId?: number | null
}
/**
* 프로젝트 정보 수정
* PUT /api/project/[id]/update
*/
export default defineEventHandler(async (event) => {
const projectId = getRouterParam(event, 'id')
const body = await readBody<UpdateProjectBody>(event)
const clientIp = getClientIp(event)
const userEmail = await getCurrentUserEmail(event)
const existing = await queryOne<any>(`
SELECT * FROM wr_project_info WHERE project_id = $1
`, [projectId])
if (!existing) {
throw createError({ statusCode: 404, message: '프로젝트를 찾을 수 없습니다.' })
}
// 프로젝트 유형 검증
if (body.projectType && !['SI', 'SM'].includes(body.projectType)) {
throw createError({ statusCode: 400, message: '프로젝트 유형은 SI 또는 SM이어야 합니다.' })
}
await execute(`
UPDATE wr_project_info SET
project_name = $1,
project_type = $2,
client_name = $3,
project_description = $4,
start_date = $5,
end_date = $6,
contract_amount = $7,
project_status = $8,
business_id = $9,
updated_at = NOW(),
updated_ip = $10,
updated_email = $11
WHERE project_id = $12
`, [
body.projectName ?? existing.project_name,
body.projectType ?? existing.project_type ?? 'SI',
body.clientName ?? existing.client_name,
body.projectDescription ?? existing.project_description,
body.startDate ?? existing.start_date,
body.endDate ?? existing.end_date,
body.contractAmount ?? existing.contract_amount,
body.projectStatus ?? existing.project_status,
body.businessId !== undefined ? body.businessId : existing.business_id,
clientIp,
userEmail,
projectId
])
return { success: true }
})