Skip to content

Commit

Permalink
feat: TodoInfo (todo response 용 info 클래스) 에 Todo 리스트로 부터 TodoInfo 리스트…
Browse files Browse the repository at this point in the history
…를 생성하는 기능 추가 #46
  • Loading branch information
khw7385 committed Feb 8, 2025
1 parent 935715b commit f6b38b3
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.dubu.backend.todo.entity.Todo;
import com.dubu.backend.todo.entity.TodoDifficulty;

import java.util.List;

public record TodoInfo(Long todoId, String category, String difficulty, String title, String memo) {
public TodoInfo(Long todoId, Category category, TodoDifficulty todoDifficulty, String title, String memo) {
this(todoId, category.getName(), todoDifficulty.name(), title, memo);
Expand All @@ -13,4 +15,9 @@ public TodoInfo(Long todoId, Category category, TodoDifficulty todoDifficulty, S
public static TodoInfo fromEntity(Todo todo){
return new TodoInfo(todo.getId(), todo.getCategory(), todo.getDifficulty(), todo.getTitle(), todo.getMemo());
}

public static List<TodoInfo> fromEntities(List<Todo> todos){
return todos.stream()
.map(todo -> new TodoInfo(todo.getId(), todo.getCategory().getName(), todo.getDifficulty(), todo.getTitle(), todo.getMemo())).toList();
}
}

0 comments on commit f6b38b3

Please sign in to comment.