Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, "해당 스킬이 조회되지 없습니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ public interface GameCharacterRepository {
Optional<GameCharacter> findByUserId(Long userId);

Optional<GameCharacter> findRandomCharacter(Long userId);

boolean isCharacterExist(Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ public interface GameCharacterJpaRepository extends JpaRepository<GameCharacter,

@Cacheable(value = "counts", key = "'count'")
long count();

boolean existsByUserId(Long userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public GameCharacter save(GameCharacter character) {
return characterRepository.save(character);
}

@Override
public boolean isCharacterExist(Long userId) {

return characterRepository.existsByUserId(userId);
}

@Override
public Optional<GameCharacter> findByUserId(Long userId) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -60,6 +61,20 @@ public ResponseEntity<Void> createCharacter(
return ResponseEntity.status(HttpStatus.CREATED).build();
}

@Operation(
summary = "게임 캐릭터 생성 확인 API",
description = "현재 사용자가 게임 캐릭터를 생성했는지 확인합니다..",
responses = {
@ApiResponse(responseCode = "200", description = "확인후 true / false 반환")
}
)
@GetMapping("/characters/check")
public ResponseEntity<CharacterCheckResponse> checkCharacter(
@AuthenticationPrincipal AuthUser authUser
) {
return ResponseEntity.status(HttpStatus.OK).body(gamePlayUseCase.isCharacterExist(authUser.getId()));
}

@Operation(
summary = "스테이터스 조회 API",
description = "현재 캐릭터의 상태를 조회합니다.",
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/templates/chat-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ <h2>채팅방 목록</h2>
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(
Expand Down