Skip to content

Commit

Permalink
Merge pull request #145 from studio-recoding/dev
Browse files Browse the repository at this point in the history
[🚀feat] 26차 배포
  • Loading branch information
JeonHaeseung authored Jul 18, 2024
2 parents 5aa81ed + ca5e841 commit 031b88f
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public OAuth2User loadUser(OAuth2UserRequest oAuth2UserRequest) throws OAuth2Aut
Member member;
/*이메일로 회원 가입 여부 확인*/
if (!memberRepository.existsByEmail(email) && !Objects.equals(password, DEFAULT_STRING)) {
// 이메일 알림 기능은 디폴트로 false
memberService.createMember(email, password, picture, nickname, name, false, false);
// 이메일 알림 기능은 디폴트로 true -> 테스트 안 해볼 사람들에게 보내주기 위해서
memberService.createMember(email, password, picture, nickname, name, true, false);
}
member = memberRepository.findMemberByEmail(email);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package Ness.Backend.domain.bookmark.dto.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.ZonedDateTime;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package Ness.Backend.domain.bookmark.dto.response;

import Ness.Backend.domain.chat.dto.response.GetChatDto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand Down
15 changes: 5 additions & 10 deletions src/main/java/Ness/Backend/domain/chat/ChatService.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
import Ness.Backend.domain.profile.entity.PersonaType;
import Ness.Backend.domain.profile.entity.Profile;
import Ness.Backend.global.fastApi.FastApiChatApi;
import Ness.Backend.global.time.GlobalTime;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.List;

@Service
Expand All @@ -32,11 +32,12 @@ public class ChatService {
private final MemberRepository memberRepository;
private final ProfileRepository profileRepository;
private final FastApiChatApi fastApiChatApi;
private final GlobalTime globalTime;

/* 새로운 채팅 생성 및 RDB에 저장 */
public void createNewChat(String text, ChatType chatType, int caseNumber, Member member){
Chat chat = Chat.builder()
.createdDate(createdZonedDate())
.createdDate(globalTime.createdZonedDate())
.text(text)
.chatType(chatType)
.caseNumber(caseNumber)
Expand All @@ -49,7 +50,7 @@ public void createNewChat(String text, ChatType chatType, int caseNumber, Member
/* 새로운 채팅 생성 및 RDB에 저장 */
public void createNewChatWithMetaData(String text, ChatType chatType, int caseNumber, Member member, String metadata){
Chat chat = Chat.builder()
.createdDate(createdZonedDate())
.createdDate(globalTime.createdZonedDate())
.text(text)
.chatType(chatType)
.caseNumber(caseNumber)
Expand Down Expand Up @@ -84,7 +85,7 @@ public GetChatListDto postNewUserChat(Long memberId, PostUserChatDto postUserCha
Profile profileEntity = profileRepository.findProfileByMember_Id(memberId);
//새로운 유저 채팅 저장
Chat newUserChat = Chat.builder()
.createdDate(createdZonedDate())
.createdDate(globalTime.createdZonedDate())
.text(postUserChatDto.getText())
.chatType(postUserChatDto.getChatType())
.caseNumber(0) //유저는 디폴트로 case 0
Expand Down Expand Up @@ -132,10 +133,4 @@ public PostFastApiAiChatDto postNewAiChat(Long memberId, String text, ChatType c

return aiDto;
}

public ZonedDateTime createdZonedDate(){
return LocalDateTime
.now(ZoneId.of("Asia/Seoul"))
.atZone(ZoneId.of("Asia/Seoul"));
}
}
35 changes: 33 additions & 2 deletions src/main/java/Ness/Backend/domain/member/MemberService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import Ness.Backend.domain.profile.ProfileRepository;
import Ness.Backend.domain.profile.entity.PersonaType;
import Ness.Backend.domain.profile.entity.Profile;
import Ness.Backend.domain.schedule.ScheduleService;
import Ness.Backend.domain.schedule.dto.request.PostScheduleDto;
import Ness.Backend.global.time.GlobalTime;
import lombok.RequiredArgsConstructor;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
Expand All @@ -19,6 +22,9 @@ public class MemberService {
private final ProfileRepository profileRepository;
private final BCryptPasswordEncoder bCryptPasswordEncoder;
private final CategoryRepository categoryRepository;
private final ScheduleService scheduleService;
private final GlobalTime globalTime;

public void deleteMember(Member member) {
profileRepository.delete(member.getProfile());
/* 소프트 삭제 */
Expand All @@ -40,9 +46,9 @@ public void createMember(String email, String password, String picture, String n
.nickname(nickname)
.name(name)
.member(member)
.isEmailActive(isEmailActive) // 디폴트로 false, 온보딩 마치면 true 변환
.isEmailActive(isEmailActive) // 디폴트로 true, 나중에 개인 페이지에서 변경 가능
.personaType(PersonaType.NESS) //디폴트로 NESS를 저장해줌, 나중에 개인 페이지에서 변경 가능
.onBoarding(isOnBoarded)
.onBoarding(isOnBoarded) // 디폴트로 false, 온보딩 마치면 true 변환
.build();

profileRepository.save(profile);
Expand Down Expand Up @@ -89,6 +95,31 @@ public void createMember(String email, String password, String picture, String n
categoryRepository.save(workoutCategory);
categoryRepository.save(restCategory);
categoryRepository.save(meetingCategory);

// 예시 스케쥴 2개 생성
PostScheduleDto oneHourLaterSchedule = PostScheduleDto.builder()
.info("NESS 온보딩 진행하기")
.location("현재 위치")
.person("")
.startTime(globalTime.getUpcomingOneHourTime())
.endTime(globalTime.getUpcomingOneHourTime().plusMinutes(30))
.categoryNum(meetingCategory.getId())
//.chat() //chat 종속성은 없음
.build();

PostScheduleDto twoHourLaterSchedule = PostScheduleDto.builder()
.info("NESS 사용법 공부하기")
.location("")
.person("NESS")
.startTime(globalTime.getUpcomingTwoHourTime())
.endTime(globalTime.getUpcomingTwoHourTime().plusMinutes(30))
.categoryNum(studyCategory.getId())
//.chat() //chat 종속성은 없음
.build();

scheduleService.postNewUserSchedule(member.getId(), oneHourLaterSchedule);
scheduleService.postNewUserSchedule(member.getId(), twoHourLaterSchedule);

return;
}
}
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 @@ -11,7 +11,7 @@
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 Ness.Backend.global.time.GlobalTime;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
Expand All @@ -29,15 +29,15 @@ public class TodoService {
private final ScheduleRepository scheduleRepository;
private final ScheduleService scheduleService;
private final ProfileRepository profileRepository;
private final Time time;
private final GlobalTime globalTime;

/* 일정 관련 한 줄 추천 가져오는 로직 */
public List<GetScheduleDto> getTodo(Long memberId){
log.info("getTodo called by member: " + memberId);

Profile userProfile = profileRepository.findProfileByMember_Id(memberId);
// 오늘 날짜 가져오기
ZonedDateTime now = time.getToday();
ZonedDateTime now = globalTime.getToday();
List<Schedule> upcomingSchedules = scheduleRepository.findUpcomingSchedulesByStart_Time(memberId, now);

List<Schedule> filteredSchedules = upcomingSchedules.stream()
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/Ness/Backend/global/time/GlobalTime.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package Ness.Backend.global.time;

import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;

@Component
public class GlobalTime {
public ZonedDateTime getToday(){
return ZonedDateTime.now(ZoneId.of("Asia/Seoul"));
}

public ZonedDateTime getUpcomingOneHourTime(){
return ZonedDateTime.now(ZoneId.of("Asia/Seoul")).plusHours(1);
}

public ZonedDateTime getUpcomingTwoHourTime(){
return ZonedDateTime.now(ZoneId.of("Asia/Seoul")).plusHours(2);
}

public ZonedDateTime createdZonedDate(){
return LocalDateTime
.now(ZoneId.of("Asia/Seoul"))
.atZone(ZoneId.of("Asia/Seoul"));
}
}
13 changes: 0 additions & 13 deletions src/main/java/Ness/Backend/global/time/Time.java

This file was deleted.

0 comments on commit 031b88f

Please sign in to comment.