Skip to content

Commit

Permalink
Merge pull request #25 from TEAM-DAWM/feat/20
Browse files Browse the repository at this point in the history
[fix] 응답 반환값 수정
  • Loading branch information
choyeongju authored Jul 7, 2024
2 parents 8d18099 + 167f22a commit c9e93d4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/java/nutshell/server/controller/TaskController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import nutshell.server.service.task.TaskService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.net.URI;

@RestController
@RequiredArgsConstructor
Expand All @@ -20,7 +21,6 @@ public ResponseEntity<Void> createTask(
@UserId final Long userId,
@RequestBody final TaskCreateDto taskCreateDto
){
taskService.createTask(userId, taskCreateDto);
return ResponseEntity.ok().build();
return ResponseEntity.created(URI.create(taskService.createTask(userId, taskCreateDto).getId().toString())).build();
}
}
4 changes: 2 additions & 2 deletions src/main/java/nutshell/server/service/task/TaskSaver.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
public class TaskSaver {
private final TaskRepository taskRepository;

public void save(final Task task) {
taskRepository.save(task);
public Task save(final Task task) {
return taskRepository.save(task);
}
}
6 changes: 4 additions & 2 deletions src/main/java/nutshell/server/service/task/TaskService.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ public class TaskService {

private final UserRetriever userRetriever;
private final TaskSaver taskSaver;
private final TaskRetriever taskRetriever;
private final TaskRemover taskRemover;

@Transactional
public void createTask(final Long userId, final TaskCreateDto taskCreateDto){
public Task createTask(final Long userId, final TaskCreateDto taskCreateDto){
User user = userRetriever.findByUserId(userId);

LocalDateTime deadLine = taskCreateDto.deadLine() != null
Expand All @@ -33,6 +35,6 @@ public void createTask(final Long userId, final TaskCreateDto taskCreateDto){
.name(taskCreateDto.name())
.deadLine(deadLine)
.build();
taskSaver.save(task);
return taskSaver.save(task);
}
}

0 comments on commit c9e93d4

Please sign in to comment.