Skip to content

Commit

Permalink
update :: conflict 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
dkflfkd53 committed Aug 20, 2024
1 parent 2667c3a commit 260d33b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.example.whopper.domain.library.application.component;

import com.example.whopper.domain.library.domain.LibraryEntity;

public interface FindLibraryByIdComponent {
LibraryEntity findLibraryById(String libraryId);
}



Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.whopper.domain.library.application.component.impl;

import com.example.whopper.domain.library.application.component.FindLibraryByIdComponent;
import com.example.whopper.domain.library.dao.LibraryMongoRepository;
import com.example.whopper.domain.library.domain.LibraryEntity;
import com.example.whopper.domain.library.exception.LibraryNotFoundException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class FindLibraryByIdComponentImpl implements FindLibraryByIdComponent {

private final LibraryMongoRepository libraryMongoRepository;

public LibraryEntity findLibraryById(String libraryId) {
return libraryMongoRepository.findById(libraryId)
.orElseThrow(()-> LibraryNotFoundException.EXCEPTION);
}
}
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
package com.example.whopper.domain.library.application.impl;

import com.example.whopper.domain.file.application.usecase.PdfUseCase;
import com.example.whopper.domain.library.application.dao.LibraryAdapter;
import com.example.whopper.domain.library.application.usecase.StudentFindLibraryUseCase;
import com.example.whopper.domain.library.dao.LibraryMongoRepository;
import com.example.whopper.domain.library.domain.type.AccessRight;
import com.example.whopper.domain.library.dto.response.LibraryResponse;
import com.example.whopper.global.utils.DataResponseInfo;
import jakarta.annotation.Nullable;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class StudentFindLibraryService implements StudentFindLibraryUseCase {

private final LibraryMongoRepository libraryMongoRepository;
private final PdfUseCase pdfUseCase;
private final LibraryAdapter libraryAdapter;

public DataResponseInfo<LibraryResponse> studentFindLibrary(Integer year) {
var libraries = year == null
? libraryMongoRepository.findFirstByAccessRightNot(AccessRight.PRIVATE)
: libraryMongoRepository.findFirstByAccessRightNotAndYear(AccessRight.PRIVATE, year);
public DataResponseInfo<LibraryResponse> studentFindLibrary(@Nullable Integer year) {
var arthurLibrary = libraryAdapter.getLibrary(AccessRight.PRIVATE, year);

return DataResponseInfo.of(libraries.stream()
.map(library -> new LibraryResponse(
null,
null,
library.getYear(),
library.getGrade(),
library.getGeneration(),
pdfUseCase.getPdfFileUrl(library.getFilePath())
))
.toList());
return DataResponseInfo.of(arthurLibrary.stream()
.map(LibraryResponse::from).toList());
}
}
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
package com.example.whopper.domain.library.application.impl;

import com.example.whopper.domain.file.application.usecase.PdfUseCase;
import com.example.whopper.domain.library.application.dao.LibraryAdapter;
import com.example.whopper.domain.library.application.usecase.TeacherFindLibraryUseCase;
import com.example.whopper.domain.library.dao.LibraryMongoRepository;
import com.example.whopper.domain.library.domain.type.AccessRight;
import com.example.whopper.domain.library.dto.response.LibraryResponse;
import com.example.whopper.global.utils.DataResponseInfo;
import jakarta.annotation.Nullable;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class TeacherFindLibraryService implements TeacherFindLibraryUseCase {

private final LibraryMongoRepository libraryMongoRepository;
private final PdfUseCase pdfUseCase;
private final LibraryAdapter libraryAdapter;

public DataResponseInfo<LibraryResponse> teacherFindLibrary(Integer year) {
var libraries = year == null
? libraryMongoRepository.findFirstByAccessRightNot(AccessRight.PRIVATE)
: libraryMongoRepository.findFirstByAccessRightNotAndYear(AccessRight.PRIVATE, year);
public DataResponseInfo<LibraryResponse> teacherFindLibrary(@Nullable Integer year) {
var arthurLibrary = libraryAdapter.getLibrary(AccessRight.PRIVATE, year);

return DataResponseInfo.of(libraries.stream()
.map(library -> new LibraryResponse(
library.getId(),
library.getAccessRight(),
library.getYear(),
library.getGrade(),
library.getGeneration(),
pdfUseCase.getPdfFileUrl(library.getFilePath())
))
.toList());
return DataResponseInfo.of(arthurLibrary.stream()
.map(LibraryResponse::from).toList());
}
}

0 comments on commit 260d33b

Please sign in to comment.