diff --git a/src/main/java/com/mosabulgyeo/bewavoca/entity/User.java b/src/main/java/com/mosabulgyeo/bewavoca/entity/User.java index 163cabd..a4de99f 100644 --- a/src/main/java/com/mosabulgyeo/bewavoca/entity/User.java +++ b/src/main/java/com/mosabulgyeo/bewavoca/entity/User.java @@ -47,7 +47,7 @@ public class User { * 선택되지 않은 경우 null. */ @Column(nullable = true) - private Long selectedCharacterId; + private Long selectedCharacterId = 1L; @ElementCollection @CollectionTable(name = "user_cleared_stages", joinColumns = @JoinColumn(name = "user_id")) @@ -120,6 +120,7 @@ public User(String deviceId, String nickname) { this.deviceId = deviceId; this.nickname = nickname; + this.selectedCharacterId = 1L; } /** diff --git a/src/main/java/com/mosabulgyeo/bewavoca/service/CharacterService.java b/src/main/java/com/mosabulgyeo/bewavoca/service/CharacterService.java index e6840e2..18da935 100644 --- a/src/main/java/com/mosabulgyeo/bewavoca/service/CharacterService.java +++ b/src/main/java/com/mosabulgyeo/bewavoca/service/CharacterService.java @@ -61,6 +61,13 @@ public List getAvailableCharacters(String deviceId) { * @param request 선택 요청 데이터 (기기 ID, 캐릭터 ID 포함) * @throws IllegalArgumentException 사용자 또는 캐릭터가 존재하지 않거나 캐릭터 잠금 해제가 되지 않았을 경우 */ + /** + * 캐릭터 선택 기능 + * 사용자가 특정 캐릭터를 선택하면 해당 캐릭터를 설정. + * + * @param request 선택 요청 데이터 (기기 ID, 캐릭터 ID 포함) + * @throws IllegalArgumentException 사용자 또는 캐릭터가 존재하지 않을 경우 + */ @Transactional public void selectCharacter(SelectCharacterRequest request) { User user = userRepository.findByDeviceId(request.getDeviceId()) @@ -69,10 +76,6 @@ public void selectCharacter(SelectCharacterRequest request) { Character character = characterRepository.findById(request.getCharacterId()) .orElseThrow(() -> new IllegalArgumentException("Character not found")); - if (!user.hasClearedRegion(character.getRegion().getId())) { - throw new IllegalArgumentException("Region not cleared for the selected character."); - } - user.setSelectedCharacterId(character.getId()); userRepository.save(user); }