Skip to content

Commit

Permalink
hotfix: library 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ori0o0p committed Aug 17, 2024
1 parent f3ed894 commit c22511f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@
import com.example.whopper.domain.library.application.usecase.ChangeLibraryAccessRightUseCase;
import com.example.whopper.domain.library.application.usecase.CreateLibraryUseCase;
import com.example.whopper.domain.library.application.usecase.FindLibraryDetailUseCase;
import com.example.whopper.domain.library.application.usecase.FindLibraryIndexUseCase;
import com.example.whopper.domain.library.application.usecase.StudentFindLibraryUseCase;
import com.example.whopper.domain.library.application.usecase.TeacherFindLibraryUseCase;
import com.example.whopper.domain.library.domain.type.AccessRight;
import com.example.whopper.domain.library.dto.LibraryDetailResponse;
import com.example.whopper.domain.library.dto.LibraryIndexResponse;
import com.example.whopper.domain.library.dto.LibraryResponse;
import com.example.whopper.global.annotation.OnlyStudent;
import com.example.whopper.global.annotation.OnlyTeacher;
import com.example.whopper.global.utils.DataResponseInfo;
import jakarta.annotation.Nullable;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
Expand All @@ -37,38 +34,36 @@ public class LibraryController {
private final PdfUseCase pdfUseCase;
private final StudentFindLibraryUseCase studentFindLibraryUseCase;
private final TeacherFindLibraryUseCase teacherFindLibraryUseCase;
private final FindLibraryIndexUseCase findLibraryIndexUseCase;
private final ChangeLibraryAccessRightUseCase changeLibraryAccessRightUseCase;
private final FindLibraryDetailUseCase findLibraryDetailUseCase;

@PostMapping
public void saveLibraryDocument(
@RequestParam(name = "grade") Integer grade,
@RequestPart("pdf") MultipartFile pdfPart,
@RequestPart("index") MultipartFile indexPart) {


@RequestPart("index") MultipartFile indexPart
) {
String filePath = pdfUseCase.savePdf(pdfPart);
createLibraryUseCase.createLibrary(grade, filePath, parseDocumentIndexComponent.parseDocumentIndex(indexPart));
}

@GetMapping("/{libraryId}")
public LibraryDetailResponse getLibraryDetailResponse(@PathVariable String libraryId) {
return findLibraryDetailUseCase.findLibraryDetail(libraryId);
}

@OnlyStudent
@GetMapping("/student")
public DataResponseInfo<LibraryResponse> studentFindLibrary(@RequestParam Integer year) {
public DataResponseInfo<LibraryResponse> studentFindLibrary(@RequestParam(defaultValue = "0") Integer year) {
return studentFindLibraryUseCase.studentFindLibrary(year);
}

@OnlyTeacher
@GetMapping("/teacher")
public DataResponseInfo<LibraryResponse> teacherFindLibrary(@RequestParam(required = false) @Nullable Integer year) {
public DataResponseInfo<LibraryResponse> teacherFindLibrary(@RequestParam(defaultValue = "0") Integer year) {
return teacherFindLibraryUseCase.teacherFindLibrary(year);
}

@GetMapping("/{libraryId}/index")
public LibraryIndexResponse findLibrary(@PathVariable String libraryId) {
return findLibraryIndexUseCase.findLibraryIndex(libraryId);
}

@OnlyTeacher
@PatchMapping("/{libraryId}/access-right")
public void changeLibraryAccessRight(@PathVariable String libraryId, @RequestParam AccessRight accessRight) {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ public record LibraryResponse(
AccessRight access_right,
Integer year,
Integer grade,
Integer generation,
String document_url
Integer generation
) {

public static LibraryResponse from(Library library) {
Expand All @@ -18,9 +17,7 @@ public static LibraryResponse from(Library library) {
library.accessRight(),
library.year(),
library.grade(),
library.getGeneration(),
library.pdfFileUrl()
library.getGeneration()
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
Expand Down Expand Up @@ -67,6 +68,7 @@ protected SecurityFilterChain configure(HttpSecurity httpSecurity) throws Except

.authorizeHttpRequests(authorize -> authorize
.requestMatchers("/auth/**").permitAll()
.requestMatchers(HttpMethod.GET, "/library/{libraryId}/public").permitAll()
.anyRequest().authenticated()
)

Expand Down

0 comments on commit c22511f

Please sign in to comment.