From 6c70bed701b5e188f0927d8570fb0833cbe1e4d7 Mon Sep 17 00:00:00 2001 From: JeonHaeseung <414catherine@gmail.com> Date: Thu, 18 Jul 2024 13:44:20 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[chore]=20GlobalTime=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=8B=9C=EA=B0=84=20=EA=B4=80=EB=A6=AC=20=EB=A6=AC=ED=8E=99?= =?UTF-8?q?=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Backend/domain/report/ReportService.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/Ness/Backend/domain/report/ReportService.java b/src/main/java/Ness/Backend/domain/report/ReportService.java index 3eadd9d..53d2c73 100644 --- a/src/main/java/Ness/Backend/domain/report/ReportService.java +++ b/src/main/java/Ness/Backend/domain/report/ReportService.java @@ -18,6 +18,7 @@ import Ness.Backend.global.fastApi.FastApiMemoryApi; import Ness.Backend.global.fastApi.FastApiRecommendApi; import Ness.Backend.global.fastApi.FastApiTagApi; +import Ness.Backend.global.time.GlobalTime; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -43,13 +44,14 @@ public class ReportService { private final FastApiMemoryApi fastApiMemoryApi; private final MemberRepository memberRepository; private final ProfileRepository profileRepository; + private final GlobalTime globalTime; /* 메모리 가져오는 로직 */ public GetReportMemoryListDto getMemory(Long memberId){ log.info("getMemory called by member: " + memberId); // 오늘 날짜 가져오기 - ZonedDateTime now = getToday(); + ZonedDateTime now = globalTime.getToday(); List reportMemory = reportMemoryRepository.findTodayReportMemoryByMember_Id(memberId); @@ -137,12 +139,12 @@ public GetReportTagListDto getTag(Long memberId){ log.info("getTag called by member: " + memberId); // 오늘 날짜 가져오기 - ZonedDateTime now = getToday(); + ZonedDateTime now = globalTime.getToday(); List reportTags = reportTagRepository.findLastMonthReportTagByMember_Id(memberId); if (reportTags == null || reportTags.isEmpty()) { - PostFastApiAiTagListDto aiDto = postNewAiTag(memberId, getToday()); + PostFastApiAiTagListDto aiDto = postNewAiTag(memberId, globalTime.getToday()); Member memberEntity = memberRepository.findMemberById(memberId); @@ -175,7 +177,7 @@ public GetReportTagListDto createReportTagListDto(List reportTags){ } public PostFastApiAiTagListDto getAiTag(Long memberId){ - return postNewAiTag(memberId, getToday()); + return postNewAiTag(memberId, globalTime.getToday()); } public PostFastApiAiTagListDto postNewAiTag(Long memberId, ZonedDateTime today){ @@ -196,7 +198,7 @@ public PostFastApiAiRecommendActivityDto getRecommendActivity(Long memberId){ log.info("getRecommendActivity called by member: " + memberId); // 오늘 날짜 가져오기 - ZonedDateTime now = getToday(); + ZonedDateTime now = globalTime.getToday(); List reportRecommends = reportRecommendRepository.findTodayReportRecommendByMember_Id(memberId); if(reportRecommends == null || reportRecommends.isEmpty()){ @@ -267,10 +269,6 @@ public String parseAiRecommend(String text){ return text.replace("\"", ""); } - public ZonedDateTime getToday(){ - return ZonedDateTime.now(ZoneId.of("Asia/Seoul")); - } - public String getPersona(Long memberId){ Profile profileEntity = profileRepository.findProfileByMember_Id(memberId); PersonaType personaType = profileEntity.getPersonaType(); From 2b6cd4e2f0bf050e986678024cad67b5bc8cd731 Mon Sep 17 00:00:00 2001 From: JeonHaeseung <414catherine@gmail.com> Date: Thu, 18 Jul 2024 13:50:11 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[feat]=20=EC=B1=84=ED=8C=85=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=A0=91=EB=91=90=EC=82=AC=20=EC=98=A4=EB=8A=94=20?= =?UTF-8?q?=EA=B2=BD=EC=9A=B0=20=ED=8C=8C=EC=8B=B1=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/Ness/Backend/domain/chat/ChatService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/Ness/Backend/domain/chat/ChatService.java b/src/main/java/Ness/Backend/domain/chat/ChatService.java index eb133d5..235c937 100644 --- a/src/main/java/Ness/Backend/domain/chat/ChatService.java +++ b/src/main/java/Ness/Backend/domain/chat/ChatService.java @@ -100,7 +100,7 @@ public GetChatListDto postNewUserChat(Long memberId, PostUserChatDto postUserCha Chat newAiChat = Chat.builder() .createdDate(LocalDateTime.now(ZoneId.of("Asia/Seoul")) .atZone(ZoneId.of("Asia/Seoul"))) - .text(AiDto.getAnswer()) + .text(parseAiChat(AiDto.getAnswer())) .chatType(ChatType.AI) .caseNumber(AiDto.getCaseNumber()) //AI는 받아온 값으로 저장 .metadata(AiDto.getMetadata()) @@ -133,4 +133,9 @@ public PostFastApiAiChatDto postNewAiChat(Long memberId, String text, ChatType c return aiDto; } + + public String parseAiChat(String text){ + // AI에서 이 접두사를 붙여서 반환하는 경우가 많이 발생함 + return text.replace("NESS: ", ""); + } } From dff32463361c09a5c0615b912a13fa70ee0ac426 Mon Sep 17 00:00:00 2001 From: JeonHaeseung <414catherine@gmail.com> Date: Thu, 18 Jul 2024 13:56:10 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[feat]=20=EC=B2=98=EC=9D=8C=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=EA=B0=80=EC=9E=85=20=EC=8B=9C=20=EC=98=88=EC=8B=9C=20?= =?UTF-8?q?=EC=B1=84=ED=8C=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ness/Backend/domain/member/MemberService.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/Ness/Backend/domain/member/MemberService.java b/src/main/java/Ness/Backend/domain/member/MemberService.java index 0f39412..6fb451e 100644 --- a/src/main/java/Ness/Backend/domain/member/MemberService.java +++ b/src/main/java/Ness/Backend/domain/member/MemberService.java @@ -2,6 +2,8 @@ import Ness.Backend.domain.category.CategoryRepository; import Ness.Backend.domain.category.entity.Category; +import Ness.Backend.domain.chat.ChatService; +import Ness.Backend.domain.chat.entity.ChatType; import Ness.Backend.domain.member.entity.Member; import Ness.Backend.domain.profile.ProfileRepository; import Ness.Backend.domain.profile.entity.PersonaType; @@ -20,9 +22,10 @@ public class MemberService { private final MemberRepository memberRepository; private final ProfileRepository profileRepository; - private final BCryptPasswordEncoder bCryptPasswordEncoder; private final CategoryRepository categoryRepository; + private final BCryptPasswordEncoder bCryptPasswordEncoder; private final ScheduleService scheduleService; + private final ChatService chatService; private final GlobalTime globalTime; public void deleteMember(Member member) { @@ -98,7 +101,7 @@ public void createMember(String email, String password, String picture, String n // 예시 스케쥴 2개 생성 PostScheduleDto oneHourLaterSchedule = PostScheduleDto.builder() - .info("NESS 온보딩 진행하기") + .info("NESS 사용법 공부하기") .location("현재 위치") .person("") .startTime(globalTime.getUpcomingOneHourTime()) @@ -108,7 +111,7 @@ public void createMember(String email, String password, String picture, String n .build(); PostScheduleDto twoHourLaterSchedule = PostScheduleDto.builder() - .info("NESS 사용법 공부하기") + .info("NESS와 함께 일정 관리 시작하기") .location("") .person("NESS") .startTime(globalTime.getUpcomingTwoHourTime()) @@ -120,6 +123,10 @@ public void createMember(String email, String password, String picture, String n scheduleService.postNewUserSchedule(member.getId(), oneHourLaterSchedule); scheduleService.postNewUserSchedule(member.getId(), twoHourLaterSchedule); + // 새로운 채팅 생성 + chatService.createNewChat("NESS에 오신 것을 환영해요! 간단하게 채팅을 테스트해볼까요?\n" + + "\"내일 5시 디지털 경진대회 미팅 추가\"라고 채팅을 보내보세요.", ChatType.AI, 1, member); + return; } }