기능구현중

This commit is contained in:
2026-01-11 13:47:33 +09:00
parent f5bf084afc
commit d56154d5d2
13 changed files with 948 additions and 46 deletions

View File

@@ -0,0 +1,22 @@
import { execute } from '../../../utils/db'
import { requireAuth } from '../../../utils/session'
/**
* 저장소 삭제 (비활성화)
* DELETE /api/repository/[id]
*/
export default defineEventHandler(async (event) => {
await requireAuth(event)
const repoId = parseInt(event.context.params?.id || '0')
if (!repoId) {
throw createError({ statusCode: 400, message: '저장소 ID가 필요합니다.' })
}
// 실제 삭제 대신 비활성화
await execute(`
UPDATE wr_repository SET is_active = false, updated_at = NOW() WHERE repo_id = $1
`, [repoId])
return { success: true }
})

View File

@@ -0,0 +1,64 @@
import { execute } from '../../../utils/db'
import { requireAuth } from '../../../utils/session'
import { getClientIp } from '../../../utils/ip'
interface UpdateRepoBody {
repoName?: string
repoPath?: string
repoUrl?: string
defaultBranch?: string
description?: string
isActive?: boolean
}
/**
* 저장소 수정
* PUT /api/repository/[id]
*/
export default defineEventHandler(async (event) => {
await requireAuth(event)
const repoId = parseInt(event.context.params?.id || '0')
const body = await readBody<UpdateRepoBody>(event)
const ip = getClientIp(event)
if (!repoId) {
throw createError({ statusCode: 400, message: '저장소 ID가 필요합니다.' })
}
const updates: string[] = ['updated_at = NOW()', 'updated_ip = $1']
const values: any[] = [ip]
let idx = 2
if (body.repoName !== undefined) {
updates.push(`repo_name = $${idx++}`)
values.push(body.repoName)
}
if (body.repoPath !== undefined) {
updates.push(`repo_path = $${idx++}`)
values.push(body.repoPath)
}
if (body.repoUrl !== undefined) {
updates.push(`repo_url = $${idx++}`)
values.push(body.repoUrl)
}
if (body.defaultBranch !== undefined) {
updates.push(`default_branch = $${idx++}`)
values.push(body.defaultBranch)
}
if (body.description !== undefined) {
updates.push(`description = $${idx++}`)
values.push(body.description)
}
if (body.isActive !== undefined) {
updates.push(`is_active = $${idx++}`)
values.push(body.isActive)
}
values.push(repoId)
await execute(`
UPDATE wr_repository SET ${updates.join(', ')} WHERE repo_id = $${idx}
`, values)
return { success: true }
})