Skip to content

Commit

Permalink
refactor: 기존 redisService -> LotteryEventRedisService 이름 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
wjddn2165 committed Aug 22, 2024
1 parent 64b8199 commit b6637de
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import JGS.CasperEvent.domain.event.dto.ResponseDto.lotteryEventResponseDto.CasperBotResponseDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.lotteryEventResponseDto.LotteryEventResponseDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.lotteryEventResponseDto.LotteryParticipantResponseDto;
import JGS.CasperEvent.domain.event.service.redisService.RedisService;
import JGS.CasperEvent.domain.event.service.redisService.LotteryEventRedisService;
import JGS.CasperEvent.domain.event.service.eventService.LotteryEventService;
import JGS.CasperEvent.global.entity.BaseUser;
import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -31,12 +31,12 @@
public class LotteryEventController {

private final LotteryEventService lotteryEventService;
private final RedisService redisService;
private final LotteryEventRedisService lotteryEventRedisService;

@Autowired
public LotteryEventController(LotteryEventService lotteryEventService, RedisService redisService) {
public LotteryEventController(LotteryEventService lotteryEventService, LotteryEventRedisService lotteryEventRedisService) {
this.lotteryEventService = lotteryEventService;
this.redisService = redisService;
this.lotteryEventRedisService = lotteryEventRedisService;
}

@Operation(summary = "추첨 이벤트 조회", description = "현재 진행 중인 추첨 이벤트의 정보를 조회합니다.")
Expand Down Expand Up @@ -88,6 +88,6 @@ public ResponseEntity<LotteryParticipantResponseDto> getLotteryParticipant(HttpS
@GetMapping("/caspers")
public ResponseEntity<List<CasperBotResponseDto>> getCasperBots() {
return ResponseEntity.status(HttpStatus.OK)
.body(redisService.getRecentData());
.body(lotteryEventRedisService.getRecentData());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import JGS.CasperEvent.domain.event.entity.participants.LotteryParticipants;
import JGS.CasperEvent.domain.event.repository.CasperBotRepository;
import JGS.CasperEvent.domain.event.repository.participantsRepository.LotteryParticipantsRepository;
import JGS.CasperEvent.domain.event.service.redisService.RedisService;
import JGS.CasperEvent.domain.event.service.redisService.LotteryEventRedisService;
import JGS.CasperEvent.global.entity.BaseUser;
import JGS.CasperEvent.global.enums.CustomErrorCode;
import JGS.CasperEvent.global.error.exception.CustomException;
Expand Down Expand Up @@ -37,7 +37,7 @@ public class LotteryEventService {
private final UserRepository userRepository;
private final LotteryParticipantsRepository lotteryParticipantsRepository;
private final CasperBotRepository casperBotRepository;
private final RedisService redisService;
private final LotteryEventRedisService lotteryEventRedisService;
private final SecretKey secretKey;
private final EventCacheService eventCacheService;

Expand All @@ -57,7 +57,7 @@ public CasperBotResponseDto postCasperBot(BaseUser user, CasperBotRequestDto cas
}

CasperBotResponseDto casperBotDto = CasperBotResponseDto.of(casperBot);
redisService.addData(casperBotDto);
lotteryEventRedisService.addData(casperBotDto);

return casperBotDto;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import java.util.List;

@Service
public class RedisService {
public class LotteryEventRedisService {
private static final String LIST_KEY = "recentData";
private static final int MAX_SIZE = 100;

private final RedisTemplate<String, CasperBotResponseDto> redisTemplate;

@Autowired
public RedisService(RedisTemplate<String, CasperBotResponseDto> redisTemplate) {
public LotteryEventRedisService(RedisTemplate<String, CasperBotResponseDto> redisTemplate) {
this.redisTemplate = redisTemplate;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import JGS.CasperEvent.domain.event.entity.participants.LotteryParticipants;
import JGS.CasperEvent.domain.event.service.adminService.AdminService;
import JGS.CasperEvent.domain.event.service.eventService.LotteryEventService;
import JGS.CasperEvent.domain.event.service.redisService.RedisService;
import JGS.CasperEvent.domain.event.service.redisService.LotteryEventRedisService;
import JGS.CasperEvent.global.entity.BaseUser;
import JGS.CasperEvent.global.enums.Role;
import JGS.CasperEvent.global.jwt.service.UserService;
Expand All @@ -23,7 +23,6 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;
Expand Down Expand Up @@ -54,7 +53,7 @@ class LotteryEventControllerTest {
@MockBean
private AdminService adminService;
@MockBean
private RedisService redisService;
private LotteryEventRedisService lotteryEventRedisService;

private BaseUser user;
private String phoneNumber;
Expand Down Expand Up @@ -192,7 +191,7 @@ void getCasperBotsSuccessTest() throws Exception {
for (int i = 0; i < 100; i++) {
recentData.add(casperBotResponse);
}
given(redisService.getRecentData())
given(lotteryEventRedisService.getRecentData())
.willReturn(recentData);

//when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import JGS.CasperEvent.domain.event.repository.CasperBotRepository;
import JGS.CasperEvent.domain.event.repository.eventRepository.LotteryEventRepository;
import JGS.CasperEvent.domain.event.repository.participantsRepository.LotteryParticipantsRepository;
import JGS.CasperEvent.domain.event.service.redisService.RedisService;
import JGS.CasperEvent.domain.event.service.redisService.LotteryEventRedisService;
import JGS.CasperEvent.global.entity.BaseUser;
import JGS.CasperEvent.global.enums.CustomErrorCode;
import JGS.CasperEvent.global.enums.Role;
Expand Down Expand Up @@ -52,7 +52,7 @@ class LotteryEventServiceTest {
@Mock
private CasperBotRepository casperBotRepository;
@Mock
private RedisService redisService;
private LotteryEventRedisService lotteryEventRedisService;


@InjectMocks
Expand Down

0 comments on commit b6637de

Please sign in to comment.