기능구현중

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

@@ -0,0 +1,67 @@
import { execute, queryOne } from '../../../utils/db'
import { getCurrentUserId } from '../../../utils/user'
interface UpdateBody {
serverName?: string
serverType?: string
serverUrl?: string
description?: string
isActive?: boolean
}
/**
* VCS 서버 수정
* PUT /api/vcs-server/[id]/update
*/
export default defineEventHandler(async (event) => {
const serverId = Number(getRouterParam(event, 'id'))
const body = await readBody<UpdateBody>(event)
const userId = await getCurrentUserId(event)
const existing = await queryOne('SELECT * FROM wr_vcs_server WHERE server_id = $1', [serverId])
if (!existing) {
throw createError({ statusCode: 404, message: 'VCS 서버를 찾을 수 없습니다.' })
}
const updates: string[] = []
const values: any[] = []
let paramIndex = 1
if (body.serverName !== undefined) {
updates.push(`server_name = $${paramIndex++}`)
values.push(body.serverName)
}
if (body.serverType !== undefined) {
updates.push(`server_type = $${paramIndex++}`)
values.push(body.serverType)
}
if (body.serverUrl !== undefined) {
updates.push(`server_url = $${paramIndex++}`)
values.push(body.serverUrl)
}
if (body.description !== undefined) {
updates.push(`description = $${paramIndex++}`)
values.push(body.description)
}
if (body.isActive !== undefined) {
updates.push(`is_active = $${paramIndex++}`)
values.push(body.isActive)
}
if (updates.length === 0) {
return { success: true, message: '변경된 내용이 없습니다.' }
}
updates.push(`updated_at = NOW()`, `updated_by = $${paramIndex++}`)
values.push(userId, serverId)
await execute(`
UPDATE wr_vcs_server SET ${updates.join(', ')} WHERE server_id = $${paramIndex}
`, values)
return { success: true }
})