Skip to content

Commit fc56ccd

Browse files
committed
2 parents c44eb69 + 36a553f commit fc56ccd

File tree

4 files changed

+28
-38
lines changed

4 files changed

+28
-38
lines changed

src/main/java/com/example/Jinus/controller/AcademicController.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public String responseMapping(RequestDto requestDto) {
4141
// 해당 월의 학사일정이 존재하는 경우
4242
if (!academicList.isEmpty()) {
4343
descriptions = academicService.handleAcademicList(academicList, descriptionList);
44-
responseDto = handleResponse(descriptions, requestDto);
44+
responseDto = handleResponse(academicList, descriptions, requestDto);
4545
} else { // 일정 존재하지 않는 경우
4646
String msg = "해당 월에는 학사일정이 없어\uD83D\uDE05";
4747
responseDto = SimpleTextResponse.simpleTextResponse(msg);
@@ -51,14 +51,17 @@ public String responseMapping(RequestDto requestDto) {
5151

5252

5353
// 학사일정 return 블록 생성 함수
54-
public String handleResponse(String descriptions, RequestDto requestDto) {
54+
public String handleResponse(List<HashMap<String, String>> academicList,
55+
String descriptions,
56+
RequestDto requestDto) {
5557
List<ButtonDto> buttons = new ArrayList<>();
5658
ButtonDto buttonDto = new ButtonDto("더보기", "webLink", "https://www.gnu.ac.kr/main/ps/schdul/selectSchdulMainList.do");
5759
buttons.add(buttonDto);
5860

59-
int year = LocalDate.now().getYear();
61+
String currentYear = academicService.getYear(academicList);
6062
int currentMonth = academicService.getCurrentMonth(requestDto);
61-
String title = year + "년 " + currentMonth + "월 학사일정";
63+
String title = currentYear + "년 " + currentMonth + "월 학사일정";
64+
6265
TextCardDto textCardDto = new TextCardDto(title, descriptions, buttons);
6366

6467
List<ComponentDto> components = new ArrayList<>();
@@ -78,16 +81,17 @@ public String handleResponse(String descriptions, RequestDto requestDto) {
7881
// quickReplies 생성 (월 생성)
7982
public List<QuickReplyDto> handleQuickReplies(List<QuickReplyDto> quickReplies, int currentMonth) {
8083
for (int i = 1; i <= 4; i++) {
81-
int replyMonth = currentMonth + i;
84+
int replyMonth = ++ currentMonth;
8285

8386
if (replyMonth == 13) {
84-
break;
85-
} else {
86-
String label = replyMonth + "월";
87-
String msg = label + " 학사일정";
88-
QuickReplyDto quickReplyDto = new QuickReplyDto(label, "message", msg);
89-
quickReplies.add(quickReplyDto);
87+
currentMonth = 0;
88+
++ currentMonth;
89+
replyMonth = currentMonth;
9090
}
91+
String label = replyMonth + "월";
92+
String msg = label + " 학사일정";
93+
QuickReplyDto quickReplyDto = new QuickReplyDto(label, "message", msg);
94+
quickReplies.add(quickReplyDto);
9195
}
9296
return quickReplies;
9397
}

src/main/java/com/example/Jinus/service/academic/AcademicService.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public List<HashMap<String, String>> getAcademicContents(int currentMonth) {
3636
List<AcademicEntity> entities = academicRepository.findCalendarEntities(currentMonth);
3737
List<HashMap<String, String>> academicList = new ArrayList<>();
3838

39-
// 해당 월의 학사일정이 존재하지 않는 경우
39+
// 해당 월의 학사일정이 존재하는 경우
4040
if (entities != null) {
4141
for (AcademicEntity entity : entities) {
4242
HashMap<String, String> academicMap = new HashMap<>();
@@ -47,7 +47,7 @@ public List<HashMap<String, String>> getAcademicContents(int currentMonth) {
4747
academicMap.put("start_date", entity.getStartDate());
4848
academicList.add(academicMap);
4949
}
50-
} else {
50+
} else { // 해당 월의 학사일정이 존재하지 않는 경우
5151
logger.debug("db에 해당 월의 학사일정이 존재하지 않음");
5252
academicList = null;
5353
}
@@ -116,11 +116,19 @@ public static String joinAllAcademics(String startDate, String endDate, String c
116116
return duration + "\uD83D\uDDD3\uFE0F" + content + "\n\n";
117117
}
118118

119-
// 날짜 추출
119+
// 날짜 추출(월/일)a
120120
public static String spltDate(String date) {
121121
String[] spltDate = date.split(" ");
122122
String[] spltMonth = spltDate[0].split("-");
123123

124124
return spltMonth[1] + "/" + spltMonth[2];
125125
}
126+
127+
// 년도 추출(올해/다음 년도)
128+
public String getYear(List<HashMap<String, String>> academicList) {
129+
HashMap<String, String> first_academic = academicList.getFirst();
130+
logger.info("first_academic:"+ first_academic);
131+
String endDate = first_academic.get("end_date"); // 끝 날짜
132+
return endDate.split(" ")[0].split("-")[0];
133+
}
126134
}

src/main/java/com/example/Jinus/service/notice/CategoryService.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,18 @@ public CategoryService(
4444
this.itCategoryRepository = itCategoryRepository;
4545
this.marsciCategoryRepository = marsciCategoryRepository;
4646
this.sadaeCategoryRepository = sadaeCategoryRepository;
47-
// logger.info("CategoryService 실행");
4847
}
4948

5049
public Map<Integer, Map<String, String>> getCategory(int departmentId, String collegeEng) {
51-
// logger.info("getCategory 실행");
52-
// logger.info("collegeEng: {}", collegeEng);
5350
// 결과를 담을 해시맵 생성
5451
Map<Integer, Map<String, String>> categoryMap = new HashMap<>();
5552

5653
switch(collegeEng) {
5754
case "biz" -> {
5855
List<BizCategoryEntity> bizCategoryEntities = bizCategoryRepository.findByDepartmentId(departmentId);
59-
// logger.info("biz: {}", bizCategoryEntities.toString());
6056

6157
for (BizCategoryEntity entity : bizCategoryEntities) {
6258
Map<String, String> map = new HashMap<>();
63-
// logger.info("entity.getId():{}", entity.getId());
64-
// logger.info("entity.getCategory():{}", entity.getCategory());
65-
// logger.info("entity.getMi():{}", entity.getMi());
66-
// logger.info("entity.getBbsId():{}", entity.getBbsId());
6759
map.put("category", entity.getCategory());
6860
map.put("mi", String.valueOf(entity.getMi()));
6961
map.put("bbs_id", String.valueOf(entity.getBbsId()));
@@ -72,14 +64,9 @@ public Map<Integer, Map<String, String>> getCategory(int departmentId, String co
7264
}
7365
case "cals" -> {
7466
List<CalsCategoryEntity> calsCategoryEntities = calsCategoryRepository.findByDepartmentId(departmentId);
75-
// logger.info("cals: {}", calsCategoryEntities.toString());
7667

7768
for (CalsCategoryEntity entity : calsCategoryEntities) {
7869
Map<String, String> map = new HashMap<>();
79-
// logger.info("entity.getId():{}", entity.getId());
80-
// logger.info("entity.getCategory():{}", entity.getCategory());
81-
// logger.info("entity.getMi():{}", entity.getMi());
82-
// logger.info("entity.getBbsId():{}", entity.getBbsId());
8370
map.put("category", entity.getCategory());
8471
map.put("mi", String.valueOf(entity.getMi()));
8572
map.put("bbs_id", String.valueOf(entity.getBbsId()));
@@ -242,4 +229,4 @@ public Map<Integer, Map<String, String>> sortCategories(Map<Integer, Map<String,
242229
// 정렬된 맵 반환
243230
return sortedCategories;
244231
}
245-
}
232+
}

src/main/java/com/example/Jinus/service/notice/NoticeService.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,32 +50,23 @@ public NoticeService(
5050

5151
// 공지 가져오기
5252
public List<Map<String, String>> getNotice(int categoryId, String collegeEng) throws ParseException {
53-
// logger.info("getNotice 실행");
54-
// logger.info("collegeEng:{}", collegeEng);
5553
List<Map<String, String>> noticeList = new ArrayList<>(); // 공지 리스트
5654

5755
switch(collegeEng) {
5856
case "biz" -> {
5957
// categoryId 일치하는 공지를 조회
6058
List<BizNoticeEntity> notices = bizNoticeRepository.findByCategoryId(categoryId);
61-
// logger.info("categoryId:{}", categoryId);
62-
// logger.info("biz-notices:{}", notices);
63-
// logger.info("biz-notices 개수:{}", notices.size());
6459

6560
int i = 0;
6661
// 조회된 공지들을 해시맵에 저장
6762
for (BizNoticeEntity notice : notices) {
6863
++i;
69-
// logger.info("notice:{}", i);
70-
// logger.info("biz-notice:{}", notice);
7164
Map<String, String> noticeInfo = new HashMap<>(); // 공지 객체 하나
7265
noticeInfo.put("title", notice.getTitle());
7366
noticeInfo.put("created_at", notice.getCreatedAt());
7467
noticeInfo.put("ntt_sn", String.valueOf(notice.getNttSn()));
7568
noticeList.add(noticeInfo);
76-
// logger.info("biz-noticeInfo:{}", noticeInfo);
7769
}
78-
// logger.info("biz-noticeList:{}", noticeList);
7970
}
8071
case "cals" -> {
8172
// categoryId 일치하는 공지를 조회
@@ -285,4 +276,4 @@ public static List<Map<String, String>> sortDates(List<Map<String, String>> noti
285276
noticeList.sort(Comparator.comparingInt((Map<String, String> o) -> Integer.parseInt(o.get("ntt_sn"))).reversed());
286277
return noticeList;
287278
}
288-
}
279+
}

0 commit comments

Comments
 (0)