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

[refactor] : 조회 메서드에 @Transactional(readOnly = true)를 적용한다 #85

Merged
merged 1 commit into from
Oct 21, 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
10 changes: 6 additions & 4 deletions src/main/java/side/onetime/service/EventService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package side.onetime.service;

import jakarta.transaction.Transactional;
import org.springframework.transaction.annotation.Transactional;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import side.onetime.domain.*;
Expand All @@ -16,6 +16,7 @@
import java.util.*;
import java.util.stream.Collectors;


@Service
@RequiredArgsConstructor
public class EventService {
Expand Down Expand Up @@ -106,6 +107,7 @@ protected void createAndSaveDaySchedules(Event event, List<String> ranges, Strin
}

// 이벤트 조회 메서드
@Transactional(readOnly = true)
public EventDto.GetEventResponse getEvent(String eventId) {
Event event = eventRepository.findByEventId(UUID.fromString(eventId))
.orElseThrow(() -> new EventException(EventErrorResult._NOT_FOUND_EVENT));
Expand All @@ -121,7 +123,7 @@ public EventDto.GetEventResponse getEvent(String eventId) {
}

// 참여자 조회 메서드
@Transactional
@Transactional(readOnly = true)
public EventDto.GetParticipantsResponse getParticipants(String eventId) {
Event event = eventRepository.findByEventId(UUID.fromString(eventId))
.orElseThrow(() -> new EventException(EventErrorResult._NOT_FOUND_EVENT));
Expand All @@ -145,7 +147,7 @@ public EventDto.GetParticipantsResponse getParticipants(String eventId) {
}

// 가장 많이 되는 시간 조회 메서드
@Transactional
@Transactional(readOnly = true)
public List<EventDto.GetMostPossibleTime> getMostPossibleTime(String eventId) {
Event event = eventRepository.findByEventId(UUID.fromString(eventId))
.orElseThrow(() -> new EventException(EventErrorResult._NOT_FOUND_EVENT));
Expand Down Expand Up @@ -261,7 +263,7 @@ private boolean isDateFormat(String range) {
}

// 유저 참여 이벤트 반환 메서드
@Transactional
@Transactional(readOnly = true)
public List<EventDto.GetUserParticipatedEventsResponse> getUserParticipatedEvents(String authorizationHeader) {
User user = jwtUtil.getUserFromHeader(authorizationHeader);

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/side/onetime/service/MemberService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package side.onetime.service;

import jakarta.transaction.Transactional;
import org.springframework.transaction.annotation.Transactional;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import side.onetime.domain.Event;
Expand Down Expand Up @@ -52,6 +52,7 @@ public MemberDto.RegisterMemberResponse registerMember(MemberDto.RegisterMemberR
return MemberDto.RegisterMemberResponse.of(member, event);
}

// 멤버 요일 선택 목록을 만드는 메서드
private List<Selection> createMembersDaySelections(Event event, Member member, MemberDto.RegisterMemberRequest registerMemberRequest) {
List<MemberDto.Schedule> schedules = registerMemberRequest.getSchedules();
List<Selection> selections = new ArrayList<>();
Expand All @@ -73,6 +74,7 @@ private List<Selection> createMembersDaySelections(Event event, Member member, M
return selections;
}

// 멤버 날짜 선택 목록을 만드는 메서드
private List<Selection> createMembersDateSelections(Event event, Member member, MemberDto.RegisterMemberRequest registerMemberRequest) {
List<MemberDto.Schedule> schedules = registerMemberRequest.getSchedules();
List<Selection> selections = new ArrayList<>();
Expand All @@ -95,6 +97,7 @@ private List<Selection> createMembersDateSelections(Event event, Member member,
}

// 멤버 로그인 메서드
@Transactional(readOnly = true)
public MemberDto.LoginMemberResponse loginMember(MemberDto.LoginMemberRequest loginMemberRequest) {
UUID eventId = UUID.fromString(loginMemberRequest.getEventId());
Event event = eventRepository.findByEventId(eventId)
Expand All @@ -107,6 +110,7 @@ public MemberDto.LoginMemberResponse loginMember(MemberDto.LoginMemberRequest lo
}

// 멤버 이름 중복 체크 메서드
@Transactional(readOnly = true)
public MemberDto.IsDuplicateResponse isDuplicate(MemberDto.IsDuplicateRequest isDuplicateRequest) {
UUID eventId = UUID.fromString(isDuplicateRequest.getEventId());
Event event = eventRepository.findByEventId(eventId)
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/side/onetime/service/ScheduleService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package side.onetime.service;

import jakarta.transaction.Transactional;
import org.springframework.transaction.annotation.Transactional;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import side.onetime.domain.*;
Expand Down Expand Up @@ -169,7 +169,7 @@ public void createDateSchedulesForAuthenticatedUser(ScheduleDto.CreateDateSchedu
}

// 전체 요일 스케줄 반환 메서드
@Transactional
@Transactional(readOnly = true)
public List<ScheduleDto.PerDaySchedulesResponse> getAllDaySchedules(String eventId) {
Event event = eventRepository.findByEventId(UUID.fromString(eventId))
.orElseThrow(() -> new EventException(EventErrorResult._NOT_FOUND_EVENT));
Expand Down Expand Up @@ -225,7 +225,7 @@ public List<ScheduleDto.PerDaySchedulesResponse> getAllDaySchedules(String event
}

// 개인 요일 스케줄 반환 메서드 (비로그인)
@Transactional
@Transactional(readOnly = true)
public ScheduleDto.PerDaySchedulesResponse getMemberDaySchedules(String eventId, String memberId) {
Event event = eventRepository.findByEventId(UUID.fromString(eventId))
.orElseThrow(() -> new EventException(EventErrorResult._NOT_FOUND_EVENT));
Expand All @@ -248,7 +248,7 @@ public ScheduleDto.PerDaySchedulesResponse getMemberDaySchedules(String eventId,
}

// 개인 요일 스케줄 반환 메서드 (로그인)
@Transactional
@Transactional(readOnly = true)
public ScheduleDto.PerDaySchedulesResponse getUserDaySchedules(String eventId, String authorizationHeader) {
Event event = eventRepository.findByEventId(UUID.fromString(eventId))
.orElseThrow(() -> new EventException(EventErrorResult._NOT_FOUND_EVENT));
Expand All @@ -271,7 +271,7 @@ public ScheduleDto.PerDaySchedulesResponse getUserDaySchedules(String eventId, S
}

// 전체 날짜 스케줄 반환 메서드
@Transactional
@Transactional(readOnly = true)
public List<ScheduleDto.PerDateSchedulesResponse> getAllDateSchedules(String eventId) {
Event event = eventRepository.findByEventId(UUID.fromString(eventId))
.orElseThrow(() -> new EventException(EventErrorResult._NOT_FOUND_EVENT));
Expand Down Expand Up @@ -327,7 +327,7 @@ public List<ScheduleDto.PerDateSchedulesResponse> getAllDateSchedules(String eve
}

// 개인 날짜 스케줄 반환 메서드 (비로그인)
@Transactional
@Transactional(readOnly = true)
public ScheduleDto.PerDateSchedulesResponse getMemberDateSchedules(String eventId, String memberId) {
Event event = eventRepository.findByEventId(UUID.fromString(eventId))
.orElseThrow(() -> new EventException(EventErrorResult._NOT_FOUND_EVENT));
Expand All @@ -350,7 +350,7 @@ public ScheduleDto.PerDateSchedulesResponse getMemberDateSchedules(String eventI
}

// 개인 날짜 스케줄 반환 메서드 (로그인)
@Transactional
@Transactional(readOnly = true)
public ScheduleDto.PerDateSchedulesResponse getUserDateSchedules(String eventId, String authorizationHeader) {
Event event = eventRepository.findByEventId(UUID.fromString(eventId))
.orElseThrow(() -> new EventException(EventErrorResult._NOT_FOUND_EVENT));
Expand All @@ -373,7 +373,7 @@ public ScheduleDto.PerDateSchedulesResponse getUserDateSchedules(String eventId,
}

// 멤버 필터링 요일 스케줄 반환 메서드
@Transactional
@Transactional(readOnly = true)
public List<ScheduleDto.PerDaySchedulesResponse> getFilteredDaySchedules(ScheduleDto.GetFilteredSchedulesRequest getFilteredSchedulesRequest) {
Event event = eventRepository.findByEventId(UUID.fromString(getFilteredSchedulesRequest.getEventId()))
.orElseThrow(() -> new EventException(EventErrorResult._NOT_FOUND_EVENT));
Expand All @@ -399,7 +399,7 @@ public List<ScheduleDto.PerDaySchedulesResponse> getFilteredDaySchedules(Schedul
}

// 멤버 필터링 날짜 스케줄 반환 메서드
@Transactional
@Transactional(readOnly = true)
public List<ScheduleDto.PerDateSchedulesResponse> getFilteredDateSchedules(ScheduleDto.GetFilteredSchedulesRequest getFilteredSchedulesRequest) {
Event event = eventRepository.findByEventId(UUID.fromString(getFilteredSchedulesRequest.getEventId()))
.orElseThrow(() -> new EventException(EventErrorResult._NOT_FOUND_EVENT));
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/side/onetime/service/UserService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package side.onetime.service;

import jakarta.transaction.Transactional;
import org.springframework.transaction.annotation.Transactional;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -67,6 +67,7 @@ public UserDto.OnboardUserResponse onboardUser(UserDto.OnboardUserRequest onboar
}

// 유저 정보 조회 메서드
@Transactional(readOnly = true)
public UserDto.GetUserProfileResponse getUserProfile(String authorizationHeader) {
User user = jwtUtil.getUserFromHeader(authorizationHeader);

Expand Down
Loading