diff --git a/src/main/java/org/ezcode/codetest/application/game/dto/response/character/CharacterCheckResponse.java b/src/main/java/org/ezcode/codetest/application/game/dto/response/character/CharacterCheckResponse.java new file mode 100644 index 00000000..46d36664 --- /dev/null +++ b/src/main/java/org/ezcode/codetest/application/game/dto/response/character/CharacterCheckResponse.java @@ -0,0 +1,11 @@ +package org.ezcode.codetest.application.game.dto.response.character; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema(description = "캐릭터 생성 여부 확인 response") +public record CharacterCheckResponse( + + boolean isCharacterExist + +) { +} diff --git a/src/main/java/org/ezcode/codetest/application/game/play/GamePlayUseCase.java b/src/main/java/org/ezcode/codetest/application/game/play/GamePlayUseCase.java index 2be34a50..de5645f2 100644 --- a/src/main/java/org/ezcode/codetest/application/game/play/GamePlayUseCase.java +++ b/src/main/java/org/ezcode/codetest/application/game/play/GamePlayUseCase.java @@ -7,6 +7,7 @@ import org.ezcode.codetest.application.game.dto.request.encounter.EncounterChoiceRequest; import org.ezcode.codetest.application.game.dto.request.skill.SkillEquipRequest; import org.ezcode.codetest.application.game.dto.request.skill.SkillUnEquipRequest; +import org.ezcode.codetest.application.game.dto.response.character.CharacterCheckResponse; import org.ezcode.codetest.application.game.dto.response.character.CharacterStatusResponse; import org.ezcode.codetest.application.game.dto.response.encounter.BattleHistoryResponse; import org.ezcode.codetest.application.game.dto.response.encounter.DefenceBattleHistoryResponse; @@ -59,6 +60,12 @@ public void createCharacter(String email) { characterService.createGameCharacter(new GameCharacter(user)); } + @Transactional + public CharacterCheckResponse isCharacterExist(Long userId) { + + return new CharacterCheckResponse(characterService.isCharacterExist(userId)); + } + @Transactional public CharacterStatusResponse characterStatusOpen(Long userId) { diff --git a/src/main/java/org/ezcode/codetest/domain/game/exception/GameExceptionCode.java b/src/main/java/org/ezcode/codetest/domain/game/exception/GameExceptionCode.java index d15dc595..c29959c2 100644 --- a/src/main/java/org/ezcode/codetest/domain/game/exception/GameExceptionCode.java +++ b/src/main/java/org/ezcode/codetest/domain/game/exception/GameExceptionCode.java @@ -14,7 +14,7 @@ public enum GameExceptionCode implements ResponseCode { ITEM_NOT_FOUND(false, HttpStatus.NOT_FOUND, "해당 아이템이 인벤토리에 없습니다."), SKILL_NOT_EXISTS(false, HttpStatus.NOT_FOUND, "해당 스킬이 존재하지 않습니다."), ITEM_NOT_EXISTS(false, HttpStatus.NOT_FOUND, "해당 아이템이 존재하지 않습니다."), - CHARACTER_NOT_FOUND(false, HttpStatus.NOT_FOUND, "해당 캐릭터가 조회되지 없습니다."), + CHARACTER_NOT_FOUND(false, HttpStatus.NOT_FOUND, "해당 캐릭터가 조회되지 않습니다."), RANDOM_CHARACTER_MATCHING_FAIL(false, HttpStatus.NOT_FOUND, "현재 매칭가능한 유저가 존재하지 않습니다."), NOT_ENOUGH_GOLD(false, HttpStatus.BAD_REQUEST, "도박을 하기에 충분한 골드가 있지 않습니다."), SKILL_NOT_FOUND(false, HttpStatus.NOT_FOUND, "해당 스킬이 조회되지 없습니다."), diff --git a/src/main/java/org/ezcode/codetest/domain/game/repository/GameCharacterRepository.java b/src/main/java/org/ezcode/codetest/domain/game/repository/GameCharacterRepository.java index 747913a5..f7729e92 100644 --- a/src/main/java/org/ezcode/codetest/domain/game/repository/GameCharacterRepository.java +++ b/src/main/java/org/ezcode/codetest/domain/game/repository/GameCharacterRepository.java @@ -11,4 +11,6 @@ public interface GameCharacterRepository { Optional findByUserId(Long userId); Optional findRandomCharacter(Long userId); + + boolean isCharacterExist(Long userId); } diff --git a/src/main/java/org/ezcode/codetest/domain/game/service/CharacterStatusDomainService.java b/src/main/java/org/ezcode/codetest/domain/game/service/CharacterStatusDomainService.java index 6e7e5d44..dee38f24 100644 --- a/src/main/java/org/ezcode/codetest/domain/game/service/CharacterStatusDomainService.java +++ b/src/main/java/org/ezcode/codetest/domain/game/service/CharacterStatusDomainService.java @@ -51,6 +51,11 @@ public GameCharacter createGameCharacter(GameCharacter character) { return savedCharacter; } + public boolean isCharacterExist(Long userId) { + + return characterRepository.isCharacterExist(userId); + } + public GameCharacter getGameCharacter(Long userId) { return characterRepository.findByUserId(userId) diff --git a/src/main/java/org/ezcode/codetest/infrastructure/persistence/repository/game/mysql/character/GameCharacterJpaRepository.java b/src/main/java/org/ezcode/codetest/infrastructure/persistence/repository/game/mysql/character/GameCharacterJpaRepository.java index 6d385ba5..0d909f51 100644 --- a/src/main/java/org/ezcode/codetest/infrastructure/persistence/repository/game/mysql/character/GameCharacterJpaRepository.java +++ b/src/main/java/org/ezcode/codetest/infrastructure/persistence/repository/game/mysql/character/GameCharacterJpaRepository.java @@ -20,4 +20,6 @@ public interface GameCharacterJpaRepository extends JpaRepository findByUserId(Long userId) { diff --git a/src/main/java/org/ezcode/codetest/presentation/game/play/GamePlayController.java b/src/main/java/org/ezcode/codetest/presentation/game/play/GamePlayController.java index 9376e7bb..5af179db 100644 --- a/src/main/java/org/ezcode/codetest/presentation/game/play/GamePlayController.java +++ b/src/main/java/org/ezcode/codetest/presentation/game/play/GamePlayController.java @@ -8,6 +8,7 @@ import org.ezcode.codetest.application.game.dto.request.item.ItemGamblingRequest; import org.ezcode.codetest.application.game.dto.request.skill.SkillEquipRequest; import org.ezcode.codetest.application.game.dto.request.skill.SkillUnEquipRequest; +import org.ezcode.codetest.application.game.dto.response.character.CharacterCheckResponse; import org.ezcode.codetest.application.game.dto.response.character.CharacterStatusResponse; import org.ezcode.codetest.application.game.dto.response.encounter.BattleHistoryResponse; import org.ezcode.codetest.application.game.dto.response.encounter.DefenceBattleHistoryResponse; @@ -60,6 +61,20 @@ public ResponseEntity createCharacter( return ResponseEntity.status(HttpStatus.CREATED).build(); } + @Operation( + summary = "게임 캐릭터 생성 확인 API", + description = "현재 사용자가 게임 캐릭터를 생성했는지 확인합니다..", + responses = { + @ApiResponse(responseCode = "200", description = "확인후 true / false 반환") + } + ) + @GetMapping("/characters/check") + public ResponseEntity checkCharacter( + @AuthenticationPrincipal AuthUser authUser + ) { + return ResponseEntity.status(HttpStatus.OK).body(gamePlayUseCase.isCharacterExist(authUser.getId())); + } + @Operation( summary = "스테이터스 조회 API", description = "현재 캐릭터의 상태를 조회합니다.", diff --git a/src/main/resources/templates/chat-page.html b/src/main/resources/templates/chat-page.html index a58e195e..117bac60 100644 --- a/src/main/resources/templates/chat-page.html +++ b/src/main/resources/templates/chat-page.html @@ -262,9 +262,9 @@

채팅방 목록

stompClient = Stomp.over(socket); // ─── Heartbeat 5분(300,000ms) 설정 ─── - stompClient.heartbeat.outgoing = 300000; // 클라이언트→서버 heartbeat 전송 간격 - stompClient.heartbeat.incoming = 300000; // 서버→클라이언트 heartbeat 수신 허용 최대 간격 - const hbHeader = {'heart-beat': '300000,300000'}; + stompClient.heartbeat.outgoing = 20000; // 클라이언트→서버 heartbeat 전송 간격 + stompClient.heartbeat.incoming = 600000; // 서버→클라이언트 heartbeat 수신 허용 최대 간격 + const hbHeader = {'heart-beat': '20000,600000'}; // ──────────────────────────────────── stompClient.connect(