Skip to content

Commit daad2de

Browse files
authored
Cacheable 주석 처리 (#33)
* [Fix]Test 코드 수정 * [Refactor]CafeteriaServiceV2 단일 책임 원칙 적용하여 클래스 분리 * Update Java CI-CD.yml dependency submission code removed * [Refactor]CampusServiceV2 클래스 분리 * [Refactor]DietServiceV2 서비스 클래스 분리
1 parent 32231b9 commit daad2de

File tree

6 files changed

+27
-16
lines changed

6 files changed

+27
-16
lines changed

src/main/java/com/example/Jinus/controller/v2/CafeteriaControllerV2.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import com.example.Jinus.dto.request.RequestDto;
44
import com.example.Jinus.service.v2.cafeteria.CafeteriaServiceV2;
55
import com.example.Jinus.service.v2.userInfo.UserServiceV2;
6+
import com.fasterxml.jackson.core.JsonProcessingException;
7+
import com.fasterxml.jackson.databind.ObjectMapper;
68
import lombok.RequiredArgsConstructor;
9+
import org.springframework.beans.factory.annotation.Autowired;
710
import org.springframework.web.bind.annotation.PostMapping;
811
import org.springframework.web.bind.annotation.RequestBody;
912
import org.springframework.web.bind.annotation.RequestMapping;
@@ -27,5 +30,4 @@ public String responseCafeteriaOrCampusListCard(@RequestBody RequestDto requestD
2730

2831
return cafeteriaServiceV2.campusOrCafeteria(userCampusId, sysCampusId);
2932
}
30-
31-
}
33+
}

src/main/java/com/example/Jinus/controller/v2/DietControllerV2.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import com.example.Jinus.dto.request.RequestDto;
44
import com.example.Jinus.service.v2.cafeteria.DietServiceV2;
5+
import com.fasterxml.jackson.databind.ObjectMapper;
56
import lombok.RequiredArgsConstructor;
7+
import org.springframework.beans.factory.annotation.Autowired;
68
import org.springframework.web.bind.annotation.PostMapping;
79
import org.springframework.web.bind.annotation.RequestBody;
810
import org.springframework.web.bind.annotation.RequestMapping;
@@ -14,6 +16,9 @@
1416
public class DietControllerV2 {
1517
private final DietServiceV2 dietServiceV2;
1618

19+
@Autowired
20+
private ObjectMapper objectMapper;
21+
1722
@PostMapping("/v2/dish")
1823
public String handleRequest(@RequestBody RequestDto requestDto) {
1924
return dietServiceV2.requestHandler(requestDto);

src/main/java/com/example/Jinus/controller/v2/NoticeControllerV2.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package com.example.Jinus.controller.v2;
22

33
import com.example.Jinus.dto.request.RequestDto;
4-
import com.example.Jinus.service.v2.notice.CategoryServiceV2;
54
import com.example.Jinus.service.v2.notice.NoticeServiceV2;
65
import com.example.Jinus.service.v2.userInfo.DepartmentServiceV2;
76
import com.example.Jinus.service.v2.userInfo.UserServiceV2;
7+
import com.fasterxml.jackson.databind.ObjectMapper;
88
import lombok.RequiredArgsConstructor;
9+
import org.springframework.beans.factory.annotation.Autowired;
910
import org.springframework.web.bind.annotation.PostMapping;
1011
import org.springframework.web.bind.annotation.RequestBody;
1112
import org.springframework.web.bind.annotation.RequestMapping;
@@ -19,6 +20,8 @@ public class NoticeControllerV2 {
1920
private final NoticeServiceV2 noticeServiceV2;
2021
private final DepartmentServiceV2 departmentServiceV2;
2122
private final UserServiceV2 userServiceV2;
23+
@Autowired
24+
private ObjectMapper objectMapper;
2225

2326
// 학교 공지사항 조회
2427
@PostMapping("/v2/main-notice")
@@ -32,6 +35,7 @@ public String getMainNotice() {
3235
@PostMapping("/v2/department-notice")
3336
public String responseDepartmentNotice(@RequestBody RequestDto requestDto) {
3437
String userId = requestDto.getUserRequest().getUser().getId();
38+
3539
int departmentId = userServiceV2.getUserDepartmentId(userId);
3640
// 학과 영문명 찾기
3741
String departmentEng = departmentServiceV2.getDepartmentEng(departmentId);

src/main/java/com/example/Jinus/service/v2/cafeteria/CacheServiceV2.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ public class CacheServiceV2 {
1818
private final DietRepositoryV2 dietRepositoryV2;
1919
private final CafeteriaRepositoryV2 cafeteriaRepositoryV2;
2020

21-
@Cacheable(
22-
value = "dietList",
23-
key = "#parameters.dietDate + '::' + #parameters.period + '::' + #cafeteriaId",
24-
unless = "#result == null || #result.isEmpty()",
25-
cacheManager = "contentCacheManager"
26-
)
21+
// @Cacheable(
22+
// value = "dietList",
23+
// key = "#parameters?.dietDate?.toString() + '::' + #parameters?.period + '::' + #cafeteriaId",
24+
// unless = "#result == null || #result.isEmpty()",
25+
// cacheManager = "contentCacheManager"
26+
// )
2727
// 식단 데이터 가져오기
2828
public List<DietDto> getDietList(HandleRequestDto parameters, int cafeteriaId) {
2929
// 오늘, 내일 문자열로 날짜 설정하기
@@ -34,7 +34,7 @@ public List<DietDto> getDietList(HandleRequestDto parameters, int cafeteriaId) {
3434

3535

3636
// Redis에서 조회 (없으면 DB에서 가져옴)
37-
@Cacheable(value = "cafeteriaList", key = "#campusId", cacheManager = "contentCacheManager")
37+
// @Cacheable(value = "cafeteriaList", key = "#campusId", cacheManager = "contentCacheManager")
3838
public List<CafeteriaDto> getCafeteriaList(int campusId) {
3939
return cafeteriaRepositoryV2.findCafeteriaListByCampusId(campusId);
4040
}

src/main/java/com/example/Jinus/service/v2/cafeteria/DietServiceV2.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
public class DietServiceV2 {
2121

2222
private final CampusServiceV2 campusServiceV2;
23-
private final CafeteriaQueryServiceV2 queryServiceV2;
24-
private final DietParameterServiceV2 parameterServiceV2;
23+
private final CafeteriaQueryServiceV2 cafeteriaQueryServiceV2;
24+
private final DietParameterServiceV2 dietParameterServiceV2;
2525
private final DietResponseServiceV2 dietResponseServiceV2;
2626
private final DietQueryServiceV2 dietQueryServiceV2;
2727

@@ -31,15 +31,15 @@ public String requestHandler(RequestDto requestDto) {
3131
// 현재 시간 파악
3232
LocalTime time = getCurrentTime();
3333
// 사용자 발화에서 파라미터 추출 및 객체 생성
34-
HandleRequestDto parameters = parameterServiceV2.setParameters(kakaoId, time, requestDto);
34+
HandleRequestDto parameters = dietParameterServiceV2.setParameters(kakaoId, time, requestDto);
3535

3636
return checkIsCafeteriaInCampus(parameters);
3737
}
3838

3939
// 식당 존재 여부에 따른 메뉴 조회 로직
4040
private String checkIsCafeteriaInCampus(HandleRequestDto parameters) {
4141
int campusId = campusServiceV2.getCampusId(parameters.getCampusName());
42-
int cafeteriaId = queryServiceV2.getCafeteriaId(parameters.getCafeteriaName(), campusId);
42+
int cafeteriaId = cafeteriaQueryServiceV2.getCafeteriaId(parameters.getCafeteriaName(), campusId);
4343

4444
// 캠퍼스에 식당이 존재하지 않는 경우
4545
if (cafeteriaId == -1) {
@@ -54,7 +54,7 @@ private String checkIsCafeteriaInCampus(HandleRequestDto parameters) {
5454
// 응답 내용 생성
5555
private String makeContents(HandleRequestDto parameters, int cafeteriaId, String diets) {
5656
// 식당 img 찾기
57-
String imgUrl = queryServiceV2.getImgUrl(cafeteriaId);
57+
String imgUrl = cafeteriaQueryServiceV2.getImgUrl(cafeteriaId);
5858

5959
// title 데이터 연결
6060
String title = "\uD83C\uDF71 " +

src/main/java/com/example/Jinus/utility/JsonUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.fasterxml.jackson.databind.ObjectMapper;
66

77
public class JsonUtils {
8-
private static final ObjectMapper objectMapper = new ObjectMapper();
8+
public static final ObjectMapper objectMapper = new ObjectMapper();
99

1010
static {
1111
// null 값 무시 설정

0 commit comments

Comments
 (0)