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] 9์ฐจ ๋ฐฐํฌ #103

Merged
merged 4 commits into from
May 27, 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
4 changes: 2 additions & 2 deletions src/main/java/Ness/Backend/domain/chat/ChatService.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public PostFastApiAiChatDto postNewAiChat(Long memberId, String text, ChatType c
if (personaType == PersonaType.HARDNESS){
persona = "hard";
}
if (personaType == PersonaType.CLAMNESS){
persona = "easy";
if (personaType == PersonaType.CALMNESS){
persona = "calm";
}

PostFastApiUserChatDto userDto = PostFastApiUserChatDto.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import Ness.Backend.domain.profile.email.dto.request.PostFastApiUserEmailDto;
import Ness.Backend.domain.profile.email.dto.response.PostFastApiAiEmailDto;
import Ness.Backend.domain.profile.entity.PersonaType;
import Ness.Backend.global.fastApi.FastApiEmailApi;
import jakarta.mail.internet.MimeMessage;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -30,10 +31,17 @@ public class AsyncEmailService {
private final SpringTemplateEngine templateEngine;
private final FastApiEmailApi fastApiEmailApi;
@Async
public void sendEmailNotice(Long memberId, String email){
public void sendEmailNotice(Long memberId, String email, PersonaType personaType){
log.info("Trying to send Email to " + email);
String persona = "default";
if (personaType == PersonaType.HARDNESS){
persona = "hard";
}
if (personaType == PersonaType.CALMNESS){
persona = "calm";
}
try {
PostFastApiAiEmailDto aiDto = postTodayAiAnalysis(memberId, getToday());
PostFastApiAiEmailDto aiDto = postTodayAiAnalysis(memberId, getToday(), persona);
String image = aiDto.getImage();
String text = aiDto.getText().replace("<br>", "\n");

Expand All @@ -50,10 +58,10 @@ public void sendEmailNotice(Long memberId, String email){
}
}

public PostFastApiAiEmailDto postTodayAiAnalysis(Long id, ZonedDateTime today){
public PostFastApiAiEmailDto postTodayAiAnalysis(Long id, ZonedDateTime today, String persona){
PostFastApiUserEmailDto userDto = PostFastApiUserEmailDto.builder()
.member_id(id.intValue())
.user_persona("")
.user_persona(persona)
.schedule_datetime_start(today)
.schedule_datetime_end(today)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ public void scheduleEmailCron(){
List<Member> activeMembers = memberRepository.findMembersByProfileIsEmailActive(true);

for (Member member : activeMembers) {
asyncEmailService.sendEmailNotice(member.getId(), member.getEmail());
Profile profile = profileRepository.findProfileByMember_Id(member.getId());
asyncEmailService.sendEmailNotice(member.getId(), member.getEmail(), profile.getPersonaType());
}
}

public void sendEmailTest(Long memberId, String email){
asyncEmailService.sendEmailNotice(memberId, email);
Profile profile = profileRepository.findProfileByMember_Id(memberId);
asyncEmailService.sendEmailNotice(memberId, email, profile.getPersonaType());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Ness.Backend.domain.profile.entity;

public enum PersonaType {
NESS, HARDNESS, CLAMNESS
NESS, HARDNESS, CALMNESS
}
6 changes: 3 additions & 3 deletions src/main/java/Ness/Backend/domain/todo/TodoService.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public List<GetScheduleDto> getTodo(Long memberId){
.name(schedule.getCategory().getName())
.color(schedule.getCategory().getColor())
.build())
.person(schedule.getPerson())
.location(schedule.getLocation())
.info(schedule.getInfo())
.person(schedule.getPerson() != null ? schedule.getPerson() : "")
.location(schedule.getLocation() != null ? schedule.getLocation() : "")
.info(schedule.getInfo() != null ? schedule.getInfo() : "")
.build())
.toList();

Expand Down
Loading