Skip to content

Commit

Permalink
Merge pull request #146 from studio-recoding/dev
Browse files Browse the repository at this point in the history
[🚀feat] 27차 배포
  • Loading branch information
JeonHaeseung authored Jul 18, 2024
2 parents 031b88f + dff3246 commit 1db4337
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
7 changes: 6 additions & 1 deletion src/main/java/Ness/Backend/domain/chat/ChatService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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: ", "");
}
}
13 changes: 10 additions & 3 deletions src/main/java/Ness/Backend/domain/member/MemberService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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())
Expand All @@ -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())
Expand All @@ -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;
}
}
16 changes: 7 additions & 9 deletions src/main/java/Ness/Backend/domain/report/ReportService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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> reportMemory = reportMemoryRepository.findTodayReportMemoryByMember_Id(memberId);

Expand Down Expand Up @@ -137,12 +139,12 @@ public GetReportTagListDto getTag(Long memberId){
log.info("getTag called by member: " + memberId);

// 오늘 날짜 가져오기
ZonedDateTime now = getToday();
ZonedDateTime now = globalTime.getToday();

List<ReportTag> 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);

Expand Down Expand Up @@ -175,7 +177,7 @@ public GetReportTagListDto createReportTagListDto(List<ReportTag> reportTags){
}

public PostFastApiAiTagListDto getAiTag(Long memberId){
return postNewAiTag(memberId, getToday());
return postNewAiTag(memberId, globalTime.getToday());
}

public PostFastApiAiTagListDto postNewAiTag(Long memberId, ZonedDateTime today){
Expand All @@ -196,7 +198,7 @@ public PostFastApiAiRecommendActivityDto getRecommendActivity(Long memberId){
log.info("getRecommendActivity called by member: " + memberId);

// 오늘 날짜 가져오기
ZonedDateTime now = getToday();
ZonedDateTime now = globalTime.getToday();
List<ReportRecommend> reportRecommends = reportRecommendRepository.findTodayReportRecommendByMember_Id(memberId);

if(reportRecommends == null || reportRecommends.isEmpty()){
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 1db4337

Please sign in to comment.