Skip to content

Commit

Permalink
[Fix] create VoiceRoom API response voiceRoomId
Browse files Browse the repository at this point in the history
  • Loading branch information
drbug2000 committed Aug 8, 2024
1 parent 0070b0b commit 454fa82
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class VoiceRoomController {

//VoiceRoom ์ƒ์„ฑ/์ˆ˜์ •
@PostMapping("")
public BaseResponse<Boolean> createRoom(
public BaseResponse<PostVoiceRoomDto.Response> createRoom(
@PathVariable("spaceId") @NotNull long spaceId,
@JwtLoginAuth Long userId,
@Validated @RequestBody PostVoiceRoomDto.Request voiceRoomRequest,
Expand All @@ -57,7 +57,8 @@ public BaseResponse<Boolean> createRoom(
//ํ•ด๋‹น ์œ ์ €๊ฐ€ ํ˜„์žฌ space์— ๋Œ€ํ•ด ๊ด€๋ฆฌ์ž ๊ถŒํ•œ์„ ๊ฐ–๊ณ  ์žˆ๋Š”์ง€ ํ™•์ธ
validateManagerPermission(spaceId,userId);
//Todo response ๋‚ด์šฉ์„ ๋ฌด์—‡์„ ์ฃผ๋ฉด ์ข‹์„์ง€ ( POST response ์ „์ฒด ๊ธฐ๋Šฅ ํ†ต์ผ ํ•˜๋Š” ๊ฒƒ์ผ ์ข‹์•„๋ณด์ž„ )
return new BaseResponse<Boolean>(voiceRoomService.createVoiceRoom(spaceId,voiceRoomRequest));
PostVoiceRoomDto.Response res = new PostVoiceRoomDto.Response(voiceRoomService.createVoiceRoom(spaceId,voiceRoomRequest));
return new BaseResponse<>(res);
}

//ํ˜„์žฌ space์— VoiceRoom ๋ชฉ๋ก
Expand Down Expand Up @@ -144,11 +145,11 @@ public BaseResponse<String> updateVoiceRoom(
return new BaseResponse<>("success");
}

@DeleteMapping
@DeleteMapping("/{voiceRoomId}")
public BaseResponse<String> deleteVoiceRoom(
@PathVariable("spaceId") @NotNull long spaceId,
@JwtLoginAuth Long userId,
@RequestParam Long voiceRoomId
@PathVariable("voiceRoomId") @NotNull Long voiceRoomId
){
//ํ•ด๋‹น ์œ ์ €๊ฐ€ voice์ด ์žˆ๋Š” space์— ํฌํ•จ๋˜์–ด ์žˆ๋Š”์ง€(๊ถŒํ•œ์ด ์žˆ๋Š”์ง€) ํ™•์ธ
validateIsUserInSpace(spaceId,userId);
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/space/space_spring/dao/VoiceRoomDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package space.space_spring.dto.VoiceRoom;

import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;

public class PostVoiceRoomDto {
Expand All @@ -10,7 +11,8 @@ public static class Request{
private String name;
}
@Getter
@AllArgsConstructor
public static class Response{

private Long voiceRoomId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 454fa82

Please sign in to comment.