Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[๐Ÿš€feat] 27์ฐจ ๋ฐฐํฌ #146

Merged
merged 3 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading