Skip to content

Commit

Permalink
Merge pull request #103 from studio-recoding/dev
Browse files Browse the repository at this point in the history
[🚀feat] 9차 배포
  • Loading branch information
JeonHaeseung authored May 27, 2024
2 parents 0066e98 + a0534fc commit 99aca1d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
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

0 comments on commit 99aca1d

Please sign in to comment.