-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/main/java/com/mindway/server/v2/domain/image/presentation/ImageController.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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.mindway.server.v2.domain.image.presentation; | ||
|
||
import com.mindway.server.v2.domain.image.presentation.dto.response.ImageUploadResponseDto; | ||
import com.mindway.server.v2.domain.image.service.ImageUploadService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestPart; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class ImageController { | ||
|
||
private final ImageUploadService imageUploadService; | ||
|
||
@PostMapping | ||
public ResponseEntity<ImageUploadResponseDto> uploadImage(@RequestPart MultipartFile image) { | ||
ImageUploadResponseDto response = imageUploadService.execute(image); | ||
return ResponseEntity.ok(response); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
.../com/mindway/server/v2/domain/image/presentation/dto/response/ImageUploadResponseDto.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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.mindway.server.v2.domain.image.presentation.dto.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class ImageUploadResponseDto { | ||
private String img_url; | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/com/mindway/server/v2/domain/image/service/ImageUploadService.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.mindway.server.v2.domain.image.service; | ||
|
||
import com.mindway.server.v2.domain.image.presentation.dto.response.ImageUploadResponseDto; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
public interface ImageUploadService { | ||
ImageUploadResponseDto execute(MultipartFile image); | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/mindway/server/v2/domain/image/service/impl/ImageUploadServiceImpl.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.mindway.server.v2.domain.image.service.impl; | ||
|
||
import com.mindway.server.v2.domain.image.presentation.dto.response.ImageUploadResponseDto; | ||
import com.mindway.server.v2.domain.image.service.ImageUploadService; | ||
import com.mindway.server.v2.domain.image.util.ImageConverter; | ||
import com.mindway.server.v2.global.annotation.ServiceWithTransaction; | ||
import com.mindway.server.v2.global.thirdparty.aws.S3Util; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
@ServiceWithTransaction | ||
@RequiredArgsConstructor | ||
public class ImageUploadServiceImpl implements ImageUploadService { | ||
|
||
private final S3Util s3Util; | ||
private final ImageConverter imageConverter; | ||
|
||
public ImageUploadResponseDto execute(MultipartFile image) { | ||
String img_url = s3Util.imageUpload(image); | ||
return imageConverter.toDto(img_url); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/mindway/server/v2/domain/image/util/ImageConverter.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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.mindway.server.v2.domain.image.util; | ||
|
||
import com.mindway.server.v2.domain.image.presentation.dto.response.ImageUploadResponseDto; | ||
|
||
public interface ImageConverter { | ||
ImageUploadResponseDto toDto(String img_url); | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/mindway/server/v2/domain/image/util/impl/ImageConverterImpl.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.mindway.server.v2.domain.image.util.impl; | ||
|
||
import com.mindway.server.v2.domain.image.presentation.dto.response.ImageUploadResponseDto; | ||
import com.mindway.server.v2.domain.image.util.ImageConverter; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class ImageConverterImpl implements ImageConverter { | ||
|
||
public ImageUploadResponseDto toDto(String img_url) { | ||
return ImageUploadResponseDto.builder() | ||
.img_url(img_url) | ||
.build(); | ||
} | ||
} |