Skip to content

Commit

Permalink
rename: Diary 조회 클래스명 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
koo995 committed Oct 2, 2024
1 parent 49dcdea commit e7ffa1b
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import flab.nutridiary.diary.dto.response.query.DiaryRecordWithProduct;
import flab.nutridiary.diary.service.AddDiaryRecordService;
import flab.nutridiary.diary.service.DiaryRegisterService;
import flab.nutridiary.diary.service.DiaryRetrievalService;
import flab.nutridiary.diary.service.DiarySearchService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
Expand All @@ -20,7 +20,7 @@
public class DiaryController {
private final DiaryRegisterService diaryRegisterService;
private final AddDiaryRecordService addDiaryRecordService;
private final DiaryRetrievalService diaryRetrievalService;
private final DiarySearchService diarySearchService;

@PostMapping("/diary/new")
public ApiResponse<DiarySavedResponse> createDiary(@Valid @RequestBody DiaryRegisterRequest diaryRegisterRequest) {
Expand All @@ -36,6 +36,6 @@ public ApiResponse<DiarySavedResponse> addDiaryRecord(@Valid @RequestBody AddDia
@GetMapping("/diary")
public ApiResponse<List<DiaryRecordWithProduct>> getDiary(@RequestParam(name = "diaryDate") LocalDate diaryDate) {
Long memberId = 1L;
return ApiResponse.success(diaryRetrievalService.getDiary(memberId, diaryDate));
return ApiResponse.success(diarySearchService.getDiary(memberId, diaryDate));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
import java.time.LocalDate;
import java.util.List;

public interface DiaryRetrievalRepository {
public interface DiarySearchRepository {
List<DiaryRecordWithProduct> findDiaryWithProductAllByMemberIdAndDiaryDate(Long memberId, LocalDate diaryDate);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package flab.nutridiary.diary.repository.query;

import flab.nutridiary.diary.dto.response.query.DiaryRecordWithProduct;
import flab.nutridiary.diary.repository.DiaryRetrievalRepository;
import flab.nutridiary.diary.repository.DiarySearchRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
Expand All @@ -12,7 +12,7 @@

@Repository
@RequiredArgsConstructor
public class JdbcTemplateDiaryRetrievalRepository implements DiaryRetrievalRepository {
public class JdbcTemplateDiarySearchRepository implements DiarySearchRepository {
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
private final DiaryRecordWithProductRowMapper diaryRecordWithProductRowMapper;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package flab.nutridiary.diary.service;

import flab.nutridiary.diary.dto.response.query.DiaryRecordWithProduct;
import flab.nutridiary.diary.repository.DiaryRetrievalRepository;
import flab.nutridiary.diary.repository.DiarySearchRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -12,11 +12,11 @@
@Transactional
@Service
@RequiredArgsConstructor
public class DiaryRetrievalService {
private final DiaryRetrievalRepository diaryRetrievalRepository;
public class DiarySearchService {
private final DiarySearchRepository diarySearchRepository;

@Transactional(readOnly = true)
public List<DiaryRecordWithProduct> getDiary(Long memberId, LocalDate diaryDate) {
return diaryRetrievalRepository.findDiaryWithProductAllByMemberIdAndDiaryDate(memberId, diaryDate);
return diarySearchRepository.findDiaryWithProductAllByMemberIdAndDiaryDate(memberId, diaryDate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
@ActiveProfiles("test")
@Transactional
@SpringBootTest
class DiaryRetrievalRepositoryTest{
class DiarySearchRepositoryTest {
@Autowired
private NutritionCalculator nutritionCalculator;
@Autowired
private DiaryRetrievalRepository diaryRetrievalRepository;
private DiarySearchRepository diarySearchRepository;
@Autowired
private DiaryRepository diaryRepository;
@Autowired
Expand Down Expand Up @@ -101,7 +101,7 @@ void findDiaryWithProductsByMemberIdAndDiaryDate() throws Exception {
Long diaryId = diaryRepository.save(diary).getId();

// when
List<DiaryRecordWithProduct> results = diaryRetrievalRepository.findDiaryWithProductAllByMemberIdAndDiaryDate(memberId, LocalDate.of(2024, 8, 10));
List<DiaryRecordWithProduct> results = diarySearchRepository.findDiaryWithProductAllByMemberIdAndDiaryDate(memberId, LocalDate.of(2024, 8, 10));

// then
List<DiaryRecordWithProduct> expectedResults = List.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
@ActiveProfiles("test")
@Transactional
@SpringBootTest
class DiaryRetrievalServiceTest {
class DiarySearchServiceTest {
@Autowired
private NutritionCalculator nutritionCalculator;
@Autowired
private DiaryRepository diaryRepository;
@Autowired
private DiaryRetrievalService diaryRetrievalService;
private DiarySearchService diarySearchService;
@Autowired
private ProductRepository productRepository;
private List<Long> savedProductIds = new ArrayList<>();
Expand Down Expand Up @@ -106,7 +106,7 @@ void getDiary() throws Exception {
LocalDate date = LocalDate.of(2024, 8, 10);

//when
List<DiaryRecordWithProduct> results = diaryRetrievalService.getDiary(memberId, date);
List<DiaryRecordWithProduct> results = diarySearchService.getDiary(memberId, date);

// then
List<DiaryRecordWithProduct> expectedResults = List.of(
Expand Down

0 comments on commit e7ffa1b

Please sign in to comment.