todo 오류 있던거 수정 이젠 디비꺼도 지워짐

This commit is contained in:
leeheejin
2025-10-20 18:04:49 +09:00
parent 86135dcf10
commit 1e3136cb0b
3 changed files with 29 additions and 51 deletions

View File

@@ -155,10 +155,15 @@ export class TodoService {
updates: Partial<TodoItem>
): Promise<TodoItem> {
try {
if (DATA_SOURCE === "database") {
// 먼저 데이터베이스에서 찾아보고, 없으면 파일에서 찾기
try {
return await this.updateTodoDB(id, updates);
} else {
return this.updateTodoFile(id, updates);
} catch (dbError: any) {
// 데이터베이스에서 찾지 못했으면 파일에서 찾기
if (dbError.message && dbError.message.includes("찾을 수 없습니다")) {
return this.updateTodoFile(id, updates);
}
throw dbError;
}
} catch (error) {
logger.error("❌ To-Do 수정 오류:", error);
@@ -171,10 +176,16 @@ export class TodoService {
*/
public async deleteTodo(id: string): Promise<void> {
try {
if (DATA_SOURCE === "database") {
// 먼저 데이터베이스에서 찾아보고, 없으면 파일에서 찾기
try {
await this.deleteTodoDB(id);
} else {
this.deleteTodoFile(id);
} catch (dbError: any) {
// 데이터베이스에서 찾지 못했으면 파일에서 찾기
if (dbError.message && dbError.message.includes("찾을 수 없습니다")) {
this.deleteTodoFile(id);
} else {
throw dbError;
}
}
logger.info(`✅ To-Do 삭제: ${id}`);
} catch (error) {