-
Notifications
You must be signed in to change notification settings - Fork 17
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 #1460 from innovationacademy-kr/be/dev/fix_extensi…
…on_delete#1457 [BE] 연장권 삭제 로직 변경 및 변경에 따른 조회 로직 수정
- Loading branch information
Showing
10 changed files
with
477 additions
and
397 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
55 changes: 36 additions & 19 deletions
55
backend/src/main/java/org/ftclub/cabinet/user/repository/LentExtensionOptionalFetcher.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 |
---|---|---|
@@ -1,39 +1,56 @@ | ||
package org.ftclub.cabinet.user.repository; | ||
|
||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
import org.ftclub.cabinet.user.domain.LentExtension; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageImpl; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Log4j2 | ||
public class LentExtensionOptionalFetcher { | ||
|
||
private final LentExtensionRepository lentExtensionRepository; | ||
private final LentExtensionRepository lentExtensionRepository; | ||
|
||
/*-------------------------------------------FIND-------------------------------------------*/ | ||
@Transactional(readOnly = true) | ||
public Page<LentExtension> findAllNotDeleted(PageRequest pageable) { | ||
return new PageImpl<>(lentExtensionRepository.findAll(pageable) | ||
.stream().filter(e -> !e.isDeleted()).collect(Collectors.toList())); | ||
} | ||
|
||
/*-------------------------------------------FIND-------------------------------------------*/ | ||
@Transactional(readOnly = true) | ||
public Page<LentExtension> findAllLentExtension(PageRequest pageable) { | ||
return lentExtensionRepository.findAll(pageable); | ||
} | ||
@Transactional(readOnly = true) | ||
public Page<LentExtension> findAllNotExpiredAndNotDeleted(PageRequest pageable) { | ||
return lentExtensionRepository.findAllNotExpired(pageable) | ||
.stream().filter(e -> !e.isUsed() && !e.isDeleted()) | ||
.collect(Collectors.collectingAndThen(Collectors.toList(), PageImpl::new)); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public Page<LentExtension> findAllNotExpired(PageRequest pageable) { | ||
return lentExtensionRepository.findAllNotExpired(pageable); | ||
} | ||
@Transactional(readOnly = true) | ||
public List<LentExtension> findAllNotExpiredAndNotDeleted() { | ||
return lentExtensionRepository.findAll() | ||
.stream().filter(e -> !e.isUsed() && !e.isDeleted()) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public List<LentExtension> findLentExtensionByUserId(Long userId) { | ||
return lentExtensionRepository.findAllByUserId(userId); | ||
} | ||
@Transactional(readOnly = true) | ||
public List<LentExtension> findNotDeletedByUserId(Long userId) { | ||
return lentExtensionRepository.findAllByUserId(userId) | ||
.stream().filter(e -> !e.isDeleted()).collect(Collectors.toList()); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
public List<LentExtension> findActiveLentExtensionsByUserId(Long userId) { | ||
return lentExtensionRepository.findAllByUserIdAndUsedAtIsNull(userId); | ||
} | ||
// Active라는 표현 자체가 비즈니스적 의미를 담고 있으므로 변경해야할 필요가 있음. | ||
// 추후 리팩터링 필요. | ||
@Transactional(readOnly = true) | ||
public List<LentExtension> findActiveByUserId(Long userId) { | ||
return lentExtensionRepository.findAllByUserIdAndUsedAtIsNull(userId) | ||
.stream().filter(e -> !e.isDeleted()).collect(Collectors.toList()); | ||
} | ||
} |
15 changes: 8 additions & 7 deletions
15
backend/src/main/java/org/ftclub/cabinet/user/service/LentExtensionService.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 |
---|---|---|
@@ -1,22 +1,23 @@ | ||
package org.ftclub.cabinet.user.service; | ||
|
||
import java.util.List; | ||
import org.ftclub.cabinet.dto.LentExtensionResponseDto; | ||
import org.ftclub.cabinet.dto.UserSessionDto; | ||
|
||
import java.util.List; | ||
|
||
public interface LentExtensionService { | ||
|
||
void issueLentExtension(); | ||
void issueLentExtension(); | ||
|
||
void deleteLentExtension(); | ||
void deleteExpiredExtensions(); | ||
|
||
void useLentExtension(Long userId, String username); | ||
void useLentExtension(Long userId, String username); | ||
|
||
void assignLentExtension(String username); | ||
void assignLentExtension(String username); | ||
|
||
List<LentExtensionResponseDto> getActiveLentExtensionList(UserSessionDto userSessionDto); | ||
List<LentExtensionResponseDto> getActiveLentExtensionList(UserSessionDto userSessionDto); | ||
|
||
LentExtensionResponseDto getActiveLentExtension(UserSessionDto userSessionDto); | ||
LentExtensionResponseDto getActiveLentExtension(UserSessionDto userSessionDto); | ||
|
||
|
||
} |
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
Oops, something went wrong.