기능구현중
This commit is contained in:
23
backend/api/todo/[id]/complete.put.ts
Normal file
23
backend/api/todo/[id]/complete.put.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { execute } from '../../../utils/db'
|
||||
import { requireAuth } from '../../../utils/session'
|
||||
|
||||
/**
|
||||
* TODO 완료 처리
|
||||
* PUT /api/todo/[id]/complete
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
await requireAuth(event)
|
||||
const todoId = parseInt(event.context.params?.id || '0')
|
||||
|
||||
if (!todoId) {
|
||||
throw createError({ statusCode: 400, message: 'TODO ID가 필요합니다.' })
|
||||
}
|
||||
|
||||
await execute(`
|
||||
UPDATE wr_todo
|
||||
SET status = 'COMPLETED', completed_at = NOW(), updated_at = NOW()
|
||||
WHERE todo_id = $1
|
||||
`, [todoId])
|
||||
|
||||
return { success: true, message: '완료 처리되었습니다.' }
|
||||
})
|
||||
Reference in New Issue
Block a user