Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface StoreService {

StoreDepartmentReadResponse getAllStoresByPageAndDeparments(Pageable pageable);

StoreReadDto getStoreByStoreId(Long storeId);
StorePageReadDto getStoreByStoreId(Long storeId);

List<StorePageReadDto> searchStoresByName(String name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,22 @@ public StoreDepartmentReadResponse getAllStoresByPageAndDeparments(Pageable page

@Override
@Transactional(readOnly = true)
public StoreReadDto getStoreByStoreId(Long storeId) {
public StorePageReadDto getStoreByStoreId(Long storeId) {
if (storeId == null) throw new StoreParamEmptyException();

Store store = storeRepository.findByStoreIdAndDeletedFalse(storeId)
.orElseThrow(StoreNotFoundException::new);

String departmentName = departmentRepository.findById(store.getDepartmentId())
.map(Department::getName)
.orElse("Unknown Department");

List<StoreImage> images = storeImageRepository.findByStore(store);
List<StoreImageUploadResponse> imageDto = images.stream()
.map(StoreImageUploadResponse::fromEntity)
.toList();

return StoreReadDto.fromEntity(store, imageDto);
return StorePageReadDto.fromEntity(store, imageDto, departmentName);
}

@Override
Expand Down