diff --git a/src/main/java/space/space_spring/controller/VoiceRoomController.java b/src/main/java/space/space_spring/controller/VoiceRoomController.java index 068d7c56..b874453c 100644 --- a/src/main/java/space/space_spring/controller/VoiceRoomController.java +++ b/src/main/java/space/space_spring/controller/VoiceRoomController.java @@ -43,7 +43,7 @@ public class VoiceRoomController { //VoiceRoom 생성/수정 @PostMapping("") - public BaseResponse createRoom( + public BaseResponse createRoom( @PathVariable("spaceId") @NotNull long spaceId, @JwtLoginAuth Long userId, @Validated @RequestBody PostVoiceRoomDto.Request voiceRoomRequest, @@ -57,7 +57,8 @@ public BaseResponse createRoom( //해당 유저가 현재 space에 대해 관리자 권한을 갖고 있는지 확인 validateManagerPermission(spaceId,userId); //Todo response 내용을 무엇을 주면 좋을지 ( POST response 전체 기능 통일 하는 것일 좋아보임 ) - return new BaseResponse(voiceRoomService.createVoiceRoom(spaceId,voiceRoomRequest)); + PostVoiceRoomDto.Response res = new PostVoiceRoomDto.Response(voiceRoomService.createVoiceRoom(spaceId,voiceRoomRequest)); + return new BaseResponse<>(res); } //현재 space에 VoiceRoom 목록 @@ -144,11 +145,11 @@ public BaseResponse updateVoiceRoom( return new BaseResponse<>("success"); } - @DeleteMapping + @DeleteMapping("/{voiceRoomId}") public BaseResponse deleteVoiceRoom( @PathVariable("spaceId") @NotNull long spaceId, @JwtLoginAuth Long userId, - @RequestParam Long voiceRoomId + @PathVariable("voiceRoomId") @NotNull Long voiceRoomId ){ //해당 유저가 voice이 있는 space에 포함되어 있는지(권한이 있는지) 확인 validateIsUserInSpace(spaceId,userId); diff --git a/src/main/java/space/space_spring/dao/VoiceRoomDao.java b/src/main/java/space/space_spring/dao/VoiceRoomDao.java index 8e28aab5..95b9195c 100644 --- a/src/main/java/space/space_spring/dao/VoiceRoomDao.java +++ b/src/main/java/space/space_spring/dao/VoiceRoomDao.java @@ -16,13 +16,17 @@ public class VoiceRoomDao { @PersistenceContext private EntityManager entityManager; @Transactional - public boolean createVoiceRoom(String name,int order,Space space){ + public Long createVoiceRoom(String name,int order,Space space){ try { - entityManager.persist(VoiceRoom.createVoiceRoom(name, order, space)); - return true; + VoiceRoom voiceRoom = VoiceRoom.createVoiceRoom(name, order, space); + entityManager.persist(voiceRoom); + entityManager.flush(); + + return voiceRoom.getVoiceRoomId(); }catch (Exception e){ System.out.print("create voiceRoom exception:"+e); - return false; + //Todo 예외 처리 필요 + return null; } } @Transactional diff --git a/src/main/java/space/space_spring/dto/VoiceRoom/PostVoiceRoomDto.java b/src/main/java/space/space_spring/dto/VoiceRoom/PostVoiceRoomDto.java index c5f0e916..a3c0dc41 100644 --- a/src/main/java/space/space_spring/dto/VoiceRoom/PostVoiceRoomDto.java +++ b/src/main/java/space/space_spring/dto/VoiceRoom/PostVoiceRoomDto.java @@ -1,6 +1,7 @@ package space.space_spring.dto.VoiceRoom; import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; import lombok.Getter; public class PostVoiceRoomDto { @@ -10,7 +11,8 @@ public static class Request{ private String name; } @Getter + @AllArgsConstructor public static class Response{ - + private Long voiceRoomId; } } diff --git a/src/main/java/space/space_spring/service/VoiceRoomService.java b/src/main/java/space/space_spring/service/VoiceRoomService.java index d117c9ff..b2e2ae3f 100644 --- a/src/main/java/space/space_spring/service/VoiceRoomService.java +++ b/src/main/java/space/space_spring/service/VoiceRoomService.java @@ -32,7 +32,7 @@ public class VoiceRoomService { private final UserDao userDao; private final UserSpaceDao userSpaceDao; - public boolean createVoiceRoom(long spaceId,PostVoiceRoomDto.Request req){ + public Long createVoiceRoom(long spaceId,PostVoiceRoomDto.Request req){ Space targetSpace = spaceUtils.findSpaceBySpaceId(spaceId); Integer orderInt = voiceRoomRepository.findMaxOrderBySpace(targetSpace); int order;