24 lines
780 B
TypeScript
24 lines
780 B
TypeScript
import { execute, queryOne } from '../../../utils/db'
|
|
import { getCurrentUserId } from '../../../utils/user'
|
|
|
|
/**
|
|
* VCS 계정 삭제
|
|
* DELETE /api/vcs-account/[id]/delete
|
|
*/
|
|
export default defineEventHandler(async (event) => {
|
|
const accountId = Number(getRouterParam(event, 'id'))
|
|
const userId = await getCurrentUserId(event)
|
|
|
|
const existing = await queryOne(
|
|
'SELECT * FROM wr_employee_vcs_account WHERE account_id = $1 AND employee_id = $2',
|
|
[accountId, userId]
|
|
)
|
|
if (!existing) {
|
|
throw createError({ statusCode: 404, message: 'VCS 계정을 찾을 수 없습니다.' })
|
|
}
|
|
|
|
await execute('DELETE FROM wr_employee_vcs_account WHERE account_id = $1', [accountId])
|
|
|
|
return { success: true, message: 'VCS 계정이 삭제되었습니다.' }
|
|
})
|