Skip to content

Commit 8d9bdbc

Browse files
committed
refactor : update season error code
1 parent a2503d1 commit 8d9bdbc

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package cmf.commitField.domain.noti.noti.entity;
2+
3+
import cmf.commitField.global.jpa.BaseEntity;
4+
import jakarta.persistence.Entity;
5+
import lombok.AllArgsConstructor;
6+
import lombok.Getter;
7+
import lombok.NoArgsConstructor;
8+
import lombok.Setter;
9+
import lombok.experimental.SuperBuilder;
10+
11+
import static lombok.AccessLevel.PROTECTED;
12+
13+
@Entity
14+
@NoArgsConstructor(access = PROTECTED)
15+
@AllArgsConstructor(access = PROTECTED)
16+
@SuperBuilder
17+
@Getter
18+
@Setter
19+
public class Noti extends BaseEntity {
20+
}

β€Žsrc/main/java/cmf/commitField/domain/season/service/UserSeasonService.javaβ€Ž

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import cmf.commitField.domain.season.repository.UserSeasonRepository;
88
import cmf.commitField.domain.user.entity.User;
99
import cmf.commitField.domain.user.repository.UserRepository;
10+
import cmf.commitField.global.error.ErrorCode;
11+
import cmf.commitField.global.exception.CustomException;
1012
import lombok.RequiredArgsConstructor;
1113
import org.springframework.stereotype.Service;
1214

@@ -23,7 +25,7 @@ public class UserSeasonService {
2325
// ν˜„μž¬ μ‹œμ¦Œμ— μœ μ € 랭크 μΆ”κ°€ν•˜κΈ° (SEED λ“±κΈ‰)
2426
public UserSeason addUserRank(Long userId) {
2527
User user = userRepository.findById(userId)
26-
.orElseThrow(() -> new RuntimeException("User not found"));
28+
.orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND_USER));
2729

2830
Season season = seasonService.getActiveSeason();
2931

@@ -38,17 +40,17 @@ public UserSeason addUserRank(Long userId) {
3840
// μœ μ €μ˜ λͺ¨λ“  μ‹œμ¦Œ 랭크 쑰회
3941
public List<UserSeason> getUserRanks(Long userId) {
4042
User user = userRepository.findById(userId)
41-
.orElseThrow(() -> new RuntimeException("User not found"));
43+
.orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND_USER));
4244
return userSeasonRepository.findByUser(user);
4345
}
4446

4547
// νŠΉμ • μ‹œμ¦Œμ˜ μœ μ € 랭크 쑰회
4648
public UserSeason getUserRankBySeason(Long userId, Long seasonId) {
4749
User user = userRepository.findById(userId)
48-
.orElseThrow(() -> new RuntimeException("User not found"));
50+
.orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND_USER));
4951
Season season = seasonRepository.findById(seasonId)
50-
.orElseThrow(() -> new RuntimeException("Season not found"));
52+
.orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND_SEASON));
5153
return userSeasonRepository.findByUserAndSeason(user, season)
52-
.orElseThrow(() -> new RuntimeException("Rank not found for this season"));
54+
.orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND_SEASON_RANK));
5355
}
5456
}

β€Žsrc/main/java/cmf/commitField/global/config/RedisConfig.javaβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
88
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
99
import org.springframework.data.redis.core.RedisTemplate;
10+
import org.springframework.data.redis.core.StringRedisTemplate;
1011
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
1112
import org.springframework.data.redis.serializer.StringRedisSerializer;
1213

@@ -34,6 +35,7 @@ public RedisConnectionFactory redisConnectionFactory() {
3435
configuration.setHostName(host);
3536
configuration.setPort(port);
3637
return new LettuceConnectionFactory(configuration);
38+
}
3739

3840
@Bean
3941
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) {

β€Žsrc/main/java/cmf/commitField/global/error/ErrorCode.javaβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public enum ErrorCode {
3535
// member
3636
MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "μ‚¬μš©μžλ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€"),
3737

38+
// season
39+
NOT_FOUND_SEASON(HttpStatus.NOT_FOUND, "μ‹œμ¦Œμ„ 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."),
40+
NOT_FOUND_SEASON_RANK(HttpStatus.NOT_FOUND, "ν•΄λ‹Ή μ‹œμ¦Œμ˜ λž­ν‚Ήμ„ 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."),
41+
3842
//chatroom
3943
NOT_FOUND_ROOM(HttpStatus.NOT_FOUND, "이미 μ‚­μ œλœ λ°©μ΄κ±°λ‚˜ 방을 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."),
4044
ROOM_USER_FULL(HttpStatus.BAD_REQUEST, "방에 μ‚¬μš©μžκ°€ λ‹€ μ°¨ μžˆμŠ΅λ‹ˆλ‹€."),

0 commit comments

Comments
Β (0)