Skip to content

Commit

Permalink
[Refactor] todo에서의 category save 기능
Browse files Browse the repository at this point in the history
  • Loading branch information
jiyunio committed May 29, 2024
1 parent 68b8cae commit 8220c05
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/jiyunio/todolist/todo/TodoController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.jiyunio.todolist.todo.dto.GetUpdateTodoDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/jiyunio/todolist/todo/TodoService.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ public ResponseTodoDTO createTodo(Long memberId, CreateTodoDTO createTodo) {
// 회원 존재 안함
() -> new CustomException(HttpStatus.NOT_FOUND, ErrorCode.NOT_EXIST_MEMBER)
);
Category category = Category.builder()
.member(member)
.content(createTodo.getCategory().getContent())
.color(createTodo.getCategory().getColor())
.build();

Todo todo = Todo.builder()
.member(member)
.content(createTodo.getContent())
.writeDate(createTodo.getWriteDate())
.setDate(createTodo.getSetDate())
.checked(false)
.category(Category.builder()
.member(member)
.content(createTodo.getCategory().getContent())
.color(createTodo.getCategory().getColor())
.build())
.category(category)
.build();

todoRepository.save(todo);
Expand Down

0 comments on commit 8220c05

Please sign in to comment.