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
5 changes: 5 additions & 0 deletions src/main/java/es/princip/ringus/domain/mentee/Mentee.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public class Mentee {
private String introduction;

@Embedded
@AttributeOverrides({
@AttributeOverride(name = "fileName", column = @Column(name = "profile_image_file_name")),
@AttributeOverride(name = "filePath", column = @Column(name = "profile_image_file_path")),
@AttributeOverride(name = "fileSize", column = @Column(name = "profile_image_file_size"))
})
private ProfileImage profileImage;

@Column(name = "member_id")
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/es/princip/ringus/domain/mentor/Mentor.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,19 @@ public class Mentor {

// 포트폴리오
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "fileName", column = @Column(name = "portfolio_file_name")),
@AttributeOverride(name = "filePath", column = @Column(name = "portfolio_file_path")),
@AttributeOverride(name = "fileSize", column = @Column(name = "portfolio_file_size"))
})
private Portfolio portfolio;

@Embedded
@AttributeOverrides({
@AttributeOverride(name = "fileName", column = @Column(name = "profile_image_file_name")),
@AttributeOverride(name = "filePath", column = @Column(name = "profile_image_file_path")),
@AttributeOverride(name = "fileSize", column = @Column(name = "profile_image_file_size"))
})
private ProfileImage profileImage;

@Column(name = "member_id")
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/es/princip/ringus/domain/mentor/vo/Portfolio.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package es.princip.ringus.domain.mentor.vo;

import es.princip.ringus.infra.storage.domain.File;
import jakarta.persistence.Embeddable;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.*;

@Getter
@Embeddable
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Portfolio {
private String url;
private String description;
public class Portfolio extends File {

@Builder
public Portfolio(String fileName, String filePath, Integer fileSize) {
super(fileName, filePath, fileSize);
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
package es.princip.ringus.infra.storage.api;

import es.princip.ringus.domain.exception.MemberErrorCode;
import es.princip.ringus.global.annotation.SessionCheck;
import es.princip.ringus.global.annotation.SessionMemberId;
import es.princip.ringus.global.exception.CustomRuntimeException;
import es.princip.ringus.global.util.ApiResponseWrapper;
import es.princip.ringus.infra.storage.application.StoragePortfolioService;
import es.princip.ringus.infra.storage.dto.PortfolioUploadRequest;
import es.princip.ringus.presentation.common.dto.PortfolioRequest;
import jakarta.servlet.http.HttpSession;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/portfolio")
@RequiredArgsConstructor
public class PortfolioController {
public class PortfolioController implements PortfolioControllerDocs{

private final StoragePortfolioService storagePortfolioService;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package es.princip.ringus.infra.storage.api;

import es.princip.ringus.global.annotation.SessionMemberId;
import es.princip.ringus.global.util.ApiResponseWrapper;
import es.princip.ringus.infra.storage.dto.PortfolioUploadRequest;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpSession;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Tag(name = "포트폴리오 업로드 API", description = "멘토 포트폴리오 파일 업로드")
@RequestMapping("/portfolio")
public interface PortfolioControllerDocs {
@Operation(summary = "멘토 포트폴리오 업로드",
description = "멘토가 포트폴리오 파일을 업로드합니다. 응답 데이터는 S3에 저장된 파일 경로입니다.",
requestBody = @RequestBody(
description = "업로드할 포트폴리오 파일",
required = true,
content = @Content(mediaType = "multipart/form-data")
),
responses = {
@ApiResponse(responseCode = "200", description = "업로드 성공, data = filePath",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ApiResponseWrapper.class)
)
),
@ApiResponse(responseCode = "401", description = "세션 만료 혹은 로그인 필요")
}
)
@PostMapping
ResponseEntity<ApiResponseWrapper<Void>> uploadPortfolio(@ModelAttribute PortfolioUploadRequest request, HttpSession session);

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public String uploadFile(MultipartFile file, String folderPath, boolean isPublic
PutObjectRequest.builder()
.bucket(bucketName)
.key(s3Key)
.acl(isPublic ? "public-read" : "private")
.contentType(file.getContentType())
.build(),
RequestBody.fromInputStream(file.getInputStream(), file.getSize())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public class Certificate extends File {
private CertificateType certificateType;

@Builder
public Certificate(String fileName, String filePath, CertificateType certificateType) {
super(fileName, filePath);
public Certificate(String fileName, String filePath, CertificateType certificateType, Integer fileSize) {
super(fileName, filePath,fileSize);
this.certificateType = certificateType;
}
}
11 changes: 10 additions & 1 deletion src/main/java/es/princip/ringus/infra/storage/domain/File.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ public abstract class File {
@Column(nullable = false)
private String filePath; // S3 경로

protected File(String fileName, String filePath) {
@Column
private Integer fileSize; // 파일 크기 MB 단위

protected File(String fileName, String filePath, Integer fileSize) {
this.fileName = fileName;
this.filePath = filePath;
this.fileSize = fileSize;
}

public File(String fileName, String filePath) {
this.fileName = fileName;
this.filePath = filePath;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

public record PortfolioRequest(
String url,
String description
String description,
Integer fileSize
) {
public Portfolio toEntity() {
return new Portfolio(url, description);
return new Portfolio(url, description, fileSize);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

public record PortfolioResponse(
String url,
String description
String description,
Integer fileSize
) {
public static PortfolioResponse from(final Portfolio portfolio) {
return new PortfolioResponse(portfolio.getUrl(), portfolio.getDescription());
return new PortfolioResponse(portfolio.getFilePath(), portfolio.getFileName(), portfolio.getFileSize());
}
}