Skip to content

Conversation

@sehee123
Copy link
Collaborator

@sehee123 sehee123 commented Jul 11, 2025

🛰️ Issue Number

🪐 작업 내용

  • RoomController 생성 (/game/api/)

  • RoomService 생성 (/game/app/)
 public Long saveRoom(RoomCreateRequest request, Map<String, Object> loginUser) {

        //todo 제일 작은 index quizId 가져와서 gameSetting
        GameSetting gameSetting = new GameSetting(1L, 10, 60);
        //todo security에서 가져오는걸로 변경
        Player host = new Player((Long) loginUser.get("id"), loginUser.get("nickname").toString());
        RoomSetting roomSetting = toRoomSetting(request);

        return roomRepository.saveRoom(gameSetting, host, roomSetting);
    }

서비스에서 new Room 으로 생성 후 room 만 넘겨주고싶었으나, repository에서 room의 id를 생성해주고있기 때문에
room생성시 필요한 필드들을 service에서 생성후 넘겨주게 되었습니다.
(id생성은 db에서 increase해주는 것 과 같이 책임이 repository에게 있다고 생각해서 id 생성 부분은 repository로 넣었습니다.)


  • RoomRepository 생성( /game/store/)
    메모리 저장소에는 주로 store라는 패키지 네이밍을 쓴다고하여 store라는 이름으로 패키지 생성했습니다.
 private final Map<Long, Room> rooms = new ConcurrentHashMap<>();
    private final AtomicLong roomIdGenerator = new AtomicLong(0);

동시성을 보장해주는 ConcurreentHashMap, AtomicLong 을 사용하였습니다.

 //테스트 전용 메소드
    public Room getRoomForTest(Long roomId) {
        return rooms.get(roomId);
    }

room을 조회하는 api는 없지만 저장 후 테스트를 위해서 만들어놨습니다.(테스트 코드 작성 완료)


  • RoomSetting 레코드 파일 필드 명 title -> roomName 변경
    클라이언트에서 보내주는 이름과 일치하지 않아서 클라이언트 기준으로 통일

  • RoomCreateRequest 생성

  • RoomMapper 생성

  • model 패키지 생성
    model은 비즈니스에서 의미 있는 도메인 객체를 뜻한다고합니다.
    game 밑에 있던 객체,enum들을 model 패키지를 생성하여 아래로 이동했습니다. (/game/model/)

  • test code 작성
 RoomRepository roomRepository;

    @BeforeEach
    void setUp() {
        roomRepository = new RoomRepository();
    }

메모리에 저장을 하기 때문에 new 로 객체를 새로 생성해서 테스트와 데이터를 분리하였습니다.
(테스트가 끝나면 GC 대상이 됨)


  • requestDTO 생성
public record RoomCreateRequest(@NotNull(message = "방 제목은 필수입니다.") String roomName,
                                @NotNull(message = "인원 수 입력은 필수입니다.") @Min(value = 2, message = "방 인원 수는 최소 2명 이상이어야합니다.") Integer maxUserCount,
                                String password,
                                boolean locked) {

}

validation적용을 하였습니다. globalExcpetionhandler를 구현해서 message를 응답에 같이 넣어 줘야합니다.


  • responseDTO 생성
image

📚 Reference

✅ Check List

  • 코드가 정상적으로 컴파일되나요?
  • 테스트 코드를 통과했나요?
  • merge할 브랜치의 위치를 확인했나요?
  • Label을 지정했나요?

@sehee123 sehee123 linked an issue Jul 11, 2025 that may be closed by this pull request
3 tasks
@sehee123 sehee123 added the enhancement New feature or request label Jul 11, 2025
sehee123 and others added 3 commits July 12, 2025 15:39
# Conflicts:
#	backend/src/main/java/io/f1/backend/domain/game/api/RoomController.java
#	backend/src/main/java/io/f1/backend/domain/game/app/RoomService.java
#	backend/src/main/java/io/f1/backend/domain/game/dto/request/RoomCreateRequest.java
#	backend/src/main/java/io/f1/backend/domain/game/store/RoomRepository.java
#	backend/src/test/java/io/f1/backend/domain/game/store/RoomRepositoryTests.java
@LimKangHyun LimKangHyun self-requested a review July 12, 2025 06:56
Copy link
Collaborator

@LimKangHyun LimKangHyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!

sehee123 and others added 3 commits July 12, 2025 16:08
# Conflicts:
#	backend/src/main/java/io/f1/backend/domain/game/api/RoomController.java
Copy link
Collaborator

@jiwon1217 jiwon1217 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다 !

@sehee123 sehee123 merged commit 2d3c46d into dev Jul 12, 2025
@sehee123 sehee123 deleted the feat/12 branch July 12, 2025 09:16
@sehee123 sehee123 self-assigned this Jul 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] 게임 방 생성 api 구현

5 participants