Skip to content

Commit 2aa0c65

Browse files
committed
refactor(volunteer): 불필요한 기능 제거
1 parent 322aba5 commit 2aa0c65

File tree

8 files changed

+1
-149
lines changed

8 files changed

+1
-149
lines changed

src/main/java/com/somemore/domains/volunteer/dto/response/VolunteerSimpleInfoResponseDto.java

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/main/java/com/somemore/domains/volunteer/repository/VolunteerRepository.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.somemore.domains.volunteer.domain.Volunteer;
44
import com.somemore.domains.volunteer.repository.mapper.VolunteerOverviewForRankingByHours;
5-
import com.somemore.domains.volunteer.repository.mapper.VolunteerSimpleInfo;
65

76
import java.util.List;
87
import java.util.Optional;
@@ -24,8 +23,6 @@ public interface VolunteerRepository {
2423

2524
List<Volunteer> findAllByIds(List<UUID> volunteerIds);
2625

27-
List<VolunteerSimpleInfo> findSimpleInfoByIds(List<UUID> ids);
28-
2926
boolean existsByVolunteerId(UUID volunteerId);
3027

3128
default boolean doesNotExistsByVolunteerId(UUID volunteerId) {

src/main/java/com/somemore/domains/volunteer/repository/VolunteerRepositoryImpl.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
import com.querydsl.core.types.dsl.BooleanExpression;
66
import com.querydsl.jpa.impl.JPAQueryFactory;
77
import com.somemore.domains.volunteer.domain.QVolunteer;
8-
import com.somemore.domains.volunteer.domain.QVolunteerDetail;
98
import com.somemore.domains.volunteer.domain.Volunteer;
109
import com.somemore.domains.volunteer.repository.mapper.VolunteerOverviewForRankingByHours;
11-
import com.somemore.domains.volunteer.repository.mapper.VolunteerSimpleInfo;
1210
import lombok.RequiredArgsConstructor;
1311
import org.springframework.stereotype.Repository;
1412

@@ -24,7 +22,6 @@ public class VolunteerRepositoryImpl implements VolunteerRepository {
2422
private final JPAQueryFactory queryFactory;
2523

2624
private static final QVolunteer volunteer = QVolunteer.volunteer;
27-
private static final QVolunteerDetail volunteerDetail = QVolunteerDetail.volunteerDetail;
2825

2926
@Override
3027
public Volunteer save(Volunteer volunteer) {
@@ -75,25 +72,6 @@ public List<Volunteer> findAllByIds(List<UUID> volunteerIds) {
7572
return volunteerJpaRepository.findAllByIdInAndDeletedFalse(volunteerIds);
7673
}
7774

78-
@Override
79-
public List<VolunteerSimpleInfo> findSimpleInfoByIds(List<UUID> ids) {
80-
BooleanExpression exp = volunteer.id.in(ids)
81-
.and(isNotDeleted());
82-
83-
return queryFactory
84-
.select(Projections.constructor(VolunteerSimpleInfo.class,
85-
volunteer.id,
86-
volunteerDetail.name,
87-
volunteer.nickname,
88-
volunteerDetail.email,
89-
volunteer.imgUrl,
90-
volunteer.tier))
91-
.from(volunteer)
92-
.join(volunteerDetail).on(volunteer.id.eq(volunteerDetail.volunteerId))
93-
.where(exp)
94-
.fetch();
95-
}
96-
9775
private Optional<Volunteer> findOne(BooleanExpression condition) {
9876

9977
return Optional.ofNullable(

src/main/java/com/somemore/domains/volunteer/repository/mapper/VolunteerSimpleInfo.java

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/main/java/com/somemore/domains/volunteer/service/VolunteerQueryService.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22

33
import com.somemore.domains.volunteer.domain.Volunteer;
44
import com.somemore.domains.volunteer.dto.response.VolunteerRankingResponseDto;
5-
import com.somemore.domains.volunteer.repository.VolunteerDetailRepository;
65
import com.somemore.domains.volunteer.repository.VolunteerRepository;
76
import com.somemore.domains.volunteer.repository.mapper.VolunteerOverviewForRankingByHours;
8-
import com.somemore.domains.volunteer.repository.mapper.VolunteerSimpleInfo;
97
import com.somemore.domains.volunteer.usecase.VolunteerQueryUseCase;
10-
import com.somemore.domains.volunteer.validator.VolunteerDetailAccessValidator;
118
import com.somemore.global.exception.BadRequestException;
129
import lombok.RequiredArgsConstructor;
1310
import lombok.extern.slf4j.Slf4j;
@@ -26,8 +23,6 @@
2623
public class VolunteerQueryService implements VolunteerQueryUseCase {
2724

2825
private final VolunteerRepository volunteerRepository;
29-
private final VolunteerDetailRepository volunteerDetailRepository;
30-
private final VolunteerDetailAccessValidator volunteerDetailAccessValidator;
3126

3227
@Override
3328
public UUID getVolunteerIdByOAuthId(String oAuthId) {
@@ -58,11 +53,6 @@ public List<Volunteer> getAllByIds(List<UUID> volunteerIds) {
5853
return volunteerRepository.findAllByIds(volunteerIds);
5954
}
6055

61-
@Override
62-
public List<VolunteerSimpleInfo> getVolunteerSimpleInfosByIds(List<UUID> ids) {
63-
return volunteerRepository.findSimpleInfoByIds(ids);
64-
}
65-
6656
@Override
6757
public void validateVolunteerExists(UUID volunteerId) {
6858
if (volunteerRepository.doesNotExistsByVolunteerId(volunteerId)) {

src/main/java/com/somemore/domains/volunteer/usecase/VolunteerQueryUseCase.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.somemore.domains.volunteer.domain.Volunteer;
44
import com.somemore.domains.volunteer.dto.response.VolunteerRankingResponseDto;
5-
import com.somemore.domains.volunteer.repository.mapper.VolunteerSimpleInfo;
65

76
import java.util.List;
87
import java.util.UUID;
@@ -17,7 +16,5 @@ public interface VolunteerQueryUseCase {
1716

1817
List<Volunteer> getAllByIds(List<UUID> volunteerIds);
1918

20-
List<VolunteerSimpleInfo> getVolunteerSimpleInfosByIds(List<UUID> ids);
21-
2219
void validateVolunteerExists(UUID volunteerId);
2320
}

src/test/java/com/somemore/domains/volunteer/repository/VolunteerRepositoryImplTest.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
package com.somemore.domains.volunteer.repository;
22

33
import com.somemore.domains.volunteer.domain.Volunteer;
4-
import com.somemore.domains.volunteer.domain.VolunteerDetail;
54
import com.somemore.domains.volunteer.dto.request.VolunteerRegisterRequestDto;
65
import com.somemore.domains.volunteer.repository.mapper.VolunteerOverviewForRankingByHours;
7-
import com.somemore.domains.volunteer.repository.mapper.VolunteerSimpleInfo;
86
import com.somemore.support.IntegrationTestSupport;
97
import org.assertj.core.api.AssertionsForClassTypes;
108
import org.junit.jupiter.api.DisplayName;
119
import org.junit.jupiter.api.Test;
1210
import org.springframework.beans.factory.annotation.Autowired;
1311
import org.springframework.transaction.annotation.Transactional;
1412

15-
import java.util.ArrayList;
1613
import java.util.List;
1714
import java.util.Optional;
1815
import java.util.UUID;
@@ -26,9 +23,6 @@ class VolunteerRepositoryImplTest extends IntegrationTestSupport {
2623
@Autowired
2724
private VolunteerRepository volunteerRepository;
2825

29-
@Autowired
30-
private VolunteerDetailRepository volunteerDetailRepository;
31-
3226
@DisplayName("봉사자의 id로 닉네임을 조회한다.")
3327
@Test
3428
void findNicknameById() {
@@ -160,27 +154,6 @@ void findAllByIds() {
160154
assertThat(volunteers).hasSize(3);
161155
}
162156

163-
@DisplayName("아이디 리스트로 봉사자 간단 정보를 조회할 수 있다.")
164-
@Test
165-
void findSimpleInfoByIds() {
166-
// given
167-
List<UUID> ids = new ArrayList<>();
168-
169-
for (int i = 0; i < 4; i++) {
170-
Volunteer volunteerTest = volunteerRepository.save(Volunteer.createDefault(NAVER, "naver"));
171-
String name = "name" + i;
172-
VolunteerRegisterRequestDto dto = createVolunteerRegisterRequestDto(name);
173-
volunteerDetailRepository.save(VolunteerDetail.of(dto, volunteerTest.getId()));
174-
ids.add(volunteerTest.getId());
175-
}
176-
177-
// when
178-
List<VolunteerSimpleInfo> simpleInfo = volunteerRepository.findSimpleInfoByIds(ids);
179-
180-
// then
181-
assertThat(simpleInfo).hasSize(4);
182-
}
183-
184157
@DisplayName("봉사자 ID로 봉사자가 존재하는지 확인할 수 있다.")
185158
@Test
186159
void existsVolunteerById() {

src/test/java/com/somemore/domains/volunteer/service/VolunteerQueryServiceTest.java

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
import com.somemore.domains.volunteer.domain.VolunteerDetail;
55
import com.somemore.domains.volunteer.dto.request.VolunteerRegisterRequestDto;
66
import com.somemore.domains.volunteer.dto.response.VolunteerRankingResponseDto;
7-
import com.somemore.domains.volunteer.repository.VolunteerDetailRepository;
87
import com.somemore.domains.volunteer.repository.VolunteerRepository;
9-
import com.somemore.domains.volunteer.repository.mapper.VolunteerSimpleInfo;
108
import com.somemore.global.auth.oauth.domain.OAuthProvider;
119
import com.somemore.global.exception.BadRequestException;
1210
import com.somemore.support.IntegrationTestSupport;
@@ -22,9 +20,7 @@
2220
import static com.somemore.global.exception.ExceptionMessage.NOT_EXISTS_VOLUNTEER;
2321
import static org.assertj.core.api.Assertions.assertThat;
2422
import static org.assertj.core.api.Assertions.assertThatThrownBy;
25-
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
26-
import static org.junit.jupiter.api.Assertions.assertEquals;
27-
import static org.junit.jupiter.api.Assertions.assertThrows;
23+
import static org.junit.jupiter.api.Assertions.*;
2824

2925
@Transactional
3026
class VolunteerQueryServiceTest extends IntegrationTestSupport {
@@ -35,9 +31,6 @@ class VolunteerQueryServiceTest extends IntegrationTestSupport {
3531
@Autowired
3632
private VolunteerRepository volunteerRepository;
3733

38-
@Autowired
39-
private VolunteerDetailRepository volunteerDetailRepository;
40-
4134
final String oAuthId = "example-oauth-id";
4235
final OAuthProvider oAuthProvider = OAuthProvider.NAVER;
4336

@@ -158,30 +151,6 @@ void findAllByIds() {
158151
assertThat(volunteers).hasSize(2);
159152
}
160153

161-
@DisplayName("아이디 리스트로 봉사자 간단 정보를 조회할 수 있다")
162-
@Test
163-
void getVolunteerSimpleInfosByIds() {
164-
// given
165-
Volunteer volunteer1 = Volunteer.createDefault(OAuthProvider.NAVER, "1234");
166-
Volunteer volunteer2 = Volunteer.createDefault(OAuthProvider.NAVER, "1234");
167-
168-
volunteerRepository.save(volunteer1);
169-
volunteerRepository.save(volunteer2);
170-
171-
VolunteerDetail detail1 = createVolunteerDetail(volunteer1.getId());
172-
VolunteerDetail detail2 = createVolunteerDetail(volunteer1.getId());
173-
174-
volunteerDetailRepository.save(detail1);
175-
volunteerDetailRepository.save(detail2);
176-
177-
// when
178-
List<VolunteerSimpleInfo> volunteers = volunteerQueryService.getVolunteerSimpleInfosByIds(
179-
List.of(volunteer1.getId(), volunteer2.getId(), UUID.randomUUID()));
180-
181-
// then
182-
assertThat(volunteers).hasSize(2);
183-
}
184-
185154
@DisplayName("봉사자 ID로 봉사자가 존재하는지 확인할 수 있다 (service)")
186155
@Test
187156
void validateVolunteerExists() {

0 commit comments

Comments
 (0)