-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from studio-recoding/fix-everything
[🚀feat] 메인 페이지 일정 한줄 코멘트 API
- Loading branch information
Showing
28 changed files
with
349 additions
and
270 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package Ness.Backend.domain.todo; | ||
|
||
import Ness.Backend.domain.profile.ProfileRepository; | ||
import Ness.Backend.domain.profile.entity.Profile; | ||
import Ness.Backend.domain.schedule.ScheduleRepository; | ||
import Ness.Backend.domain.schedule.ScheduleService; | ||
import Ness.Backend.domain.schedule.dto.response.GetScheduleDto; | ||
import Ness.Backend.domain.schedule.dto.response.GetScheduleListDto; | ||
import Ness.Backend.domain.schedule.entity.Schedule; | ||
import Ness.Backend.domain.todo.dto.request.PostFastApiTodoCategoryDto; | ||
import Ness.Backend.domain.todo.dto.request.PostFastApiTodoDto; | ||
import Ness.Backend.domain.todo.dto.request.PostFastApiTodoListDto; | ||
import Ness.Backend.domain.todo.dto.response.PostFastApiRecommendListDto; | ||
import Ness.Backend.global.fastApi.FastApiTodoApi; | ||
import Ness.Backend.global.time.Time; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.time.ZonedDateTime; | ||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
@Transactional | ||
public class TodoService { | ||
private final FastApiTodoApi fastApiTodoApi; | ||
private final ScheduleRepository scheduleRepository; | ||
private final ScheduleService scheduleService; | ||
private final ProfileRepository profileRepository; | ||
private final Time time; | ||
|
||
/* 일정 관련 한 줄 추천 가져오는 로직 */ | ||
public List<GetScheduleDto> getTodo(Long memberId){ | ||
Profile userProfile = profileRepository.findProfileByMember_Id(memberId); | ||
// 오늘 날짜 가져오기 | ||
ZonedDateTime now = time.getToday(); | ||
List<Schedule> upcomingSchedules = scheduleRepository.findUpcomingSchedulesByStart_Time(memberId, now); | ||
|
||
List<Schedule> filteredSchedules = upcomingSchedules.stream() | ||
.filter(schedule -> schedule.getTodo() == null) | ||
.toList(); | ||
|
||
if(!filteredSchedules.isEmpty()){ | ||
List<PostFastApiTodoDto> todoDtos = filteredSchedules.stream() | ||
.map(schedule -> PostFastApiTodoDto.builder() | ||
.id(schedule.getId()) | ||
.startTime(schedule.getStartTime()) | ||
.category(PostFastApiTodoCategoryDto.builder() | ||
.id(schedule.getCategory().getId()) | ||
.name(schedule.getCategory().getName()) | ||
.color(schedule.getCategory().getColor()) | ||
.build()) | ||
.person(schedule.getPerson()) | ||
.location(schedule.getLocation()) | ||
.info(schedule.getInfo()) | ||
.build()) | ||
.toList(); | ||
|
||
PostFastApiTodoListDto userTodoList = PostFastApiTodoListDto.builder() | ||
.persona(userProfile.getPersonaType()) | ||
.todoList(todoDtos) | ||
.build(); | ||
|
||
PostFastApiRecommendListDto aiTodoList = fastApiTodoApi.creatFastApiTodo(userTodoList); | ||
|
||
//AI에서 받아온 TODO를 업데이트 | ||
aiTodoList.getRecommendationList() | ||
.forEach(todo -> scheduleRepository | ||
.findScheduleById(todo.getTodo().getId()) | ||
.updateTodo(todo.getNessComment())); | ||
} | ||
|
||
List<Schedule> updatedSchedules = scheduleRepository.findUpcomingSchedulesByStart_Time(memberId, now); | ||
|
||
return scheduleService.makeScheduleWithCommentListDto(updatedSchedules); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/Ness/Backend/domain/todo/dto/request/PostFastApiTodoCategoryDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package Ness.Backend.domain.todo.dto.request; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class PostFastApiTodoCategoryDto { | ||
@JsonProperty("categoryId") | ||
private Long id; | ||
|
||
@JsonProperty("categoryName") | ||
private String name; | ||
|
||
@JsonProperty("categoryColor") | ||
private String color; | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/Ness/Backend/domain/todo/dto/request/PostFastApiTodoDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package Ness.Backend.domain.todo.dto.request; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.ZonedDateTime; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class PostFastApiTodoDto { | ||
@JsonProperty("id") | ||
private Long id; | ||
|
||
@JsonProperty("startTime") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING) | ||
private ZonedDateTime startTime; | ||
|
||
@JsonProperty("category") | ||
private PostFastApiTodoCategoryDto category; | ||
|
||
@JsonProperty("person") | ||
private String person; | ||
|
||
@JsonProperty("location") | ||
private String location; | ||
|
||
@JsonProperty("info") | ||
private String info; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/Ness/Backend/domain/todo/dto/request/PostFastApiTodoListDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package Ness.Backend.domain.todo.dto.request; | ||
|
||
import Ness.Backend.domain.profile.entity.PersonaType; | ||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class PostFastApiTodoListDto { | ||
@JsonProperty("persona") | ||
@JsonFormat(shape = JsonFormat.Shape.STRING) | ||
private PersonaType persona; | ||
|
||
@JsonProperty("todoList") | ||
private List<PostFastApiTodoDto> todoList; | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/Ness/Backend/domain/todo/dto/response/PostFastApiRecommendCategoryDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package Ness.Backend.domain.todo.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class PostFastApiRecommendCategoryDto { | ||
@JsonProperty("categoryId") | ||
private Long id; | ||
|
||
@JsonProperty("categoryName") | ||
private String name; | ||
|
||
@JsonProperty("categoryColor") | ||
private String color; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/Ness/Backend/domain/todo/dto/response/PostFastApiRecommendDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package Ness.Backend.domain.todo.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class PostFastApiRecommendDto { | ||
@JsonProperty("todo") | ||
private PostFastApiRecommendTodoDto todo; | ||
|
||
@JsonProperty("nessComment") | ||
private String nessComment; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/Ness/Backend/domain/todo/dto/response/PostFastApiRecommendListDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package Ness.Backend.domain.todo.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class PostFastApiRecommendListDto { | ||
@JsonProperty("recommendationList") | ||
List<PostFastApiRecommendDto> recommendationList; | ||
} |
Oops, something went wrong.