Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
update DocumentController.java
Browse files Browse the repository at this point in the history
add Image Upload API
  • Loading branch information
ori0o0p committed Mar 11, 2024
1 parent bb2e1b4 commit 02186a7
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
import com.example.daemawiki.domain.document.dto.response.SimpleDocumentResponse;
import com.example.daemawiki.domain.document.model.DocumentSearchResult;
import com.example.daemawiki.domain.info.dto.UpdateInfoRequest;
import com.example.daemawiki.domain.info.service.DocumentImageUpload;
import com.example.daemawiki.domain.info.service.UpdateInfo;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.codec.multipart.FilePart;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
Expand All @@ -25,13 +28,15 @@ public class DocumentController {
private final DeleteDocument deleteDocumentService;
private final UpdateDocument updateDocumentService;
private final UpdateInfo updateInfoService;
private final DocumentImageUpload documentImageUpload;

public DocumentController(CreateDocument createDocument, GetDocument getDocument, DeleteDocument deleteDocument, UpdateDocument updateDocument, UpdateInfo updateInfoService) {
public DocumentController(CreateDocument createDocument, GetDocument getDocument, DeleteDocument deleteDocument, UpdateDocument updateDocument, UpdateInfo updateInfoService, DocumentImageUpload documentImageUpload) {
this.createDocumentService = createDocument;
this.getDocumentService = getDocument;
this.deleteDocumentService = deleteDocument;
this.updateDocumentService = updateDocument;
this.updateInfoService = updateInfoService;
this.documentImageUpload = documentImageUpload;
}

@PostMapping
Expand Down Expand Up @@ -83,4 +88,10 @@ public Mono<Void> updateInfo(@Valid @RequestBody UpdateInfoRequest request) {
return updateInfoService.execute(request);
}

@PatchMapping(value = "/{documentId}/image", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public Mono<Void> updateImage(@PathVariable String documentId, @RequestPart(value = "file", required = true) FilePart filePart) {
return documentImageUpload.execute(filePart, documentId);
}

}

0 comments on commit 02186a7

Please sign in to comment.