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: ", ""); + } } 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; } } 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();