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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@RestController
@RequestMapping("/storage/certificate")
@RequiredArgsConstructor
public class CertificateController {
public class CertificateController implements CertificateControllerDocs{

private final StorageCertificateService storageCertificateService;
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package es.princip.ringus.infra.storage.api;

import es.princip.ringus.global.util.ApiResponseWrapper;
import es.princip.ringus.infra.storage.dto.CertificateUploadRequest;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
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 = "멘티 및 멘토 증명서를 업로드하는 API")
@RequestMapping("/storage/certificate")
public interface CertificateControllerDocs {

@Operation(summary = "멘티 증명서 업로드",
description = "멘티의 증명서를 업로드합니다. \n\n ⚠️ **multipart/form-data 형식**으로 요청해야 합니다",
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
content = @Content(mediaType = "multipart/form-data",
schema = @Schema(implementation = CertificateUploadRequest.class))

))
@ApiResponse(responseCode = "200", description = "멘티 증명서 업로드 성공",
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ApiResponseWrapper.class)))
@ApiResponse(responseCode = "401", description = "세션이 만료됨")
@PostMapping("/mentee")
ResponseEntity<ApiResponseWrapper<Void>> uploadMenteeCertificate(
@Parameter(description = "멘티 증명서 업로드 요청 데이터", required = true)
@ModelAttribute CertificateUploadRequest certificateUploadRequest,

@Parameter(hidden = true)
HttpSession session
);

@Operation(summary = "멘토 증명서 업로드", description = "멘토의 증명서를 업로드합니다.")
@ApiResponse(responseCode = "200", description = "멘토 증명서 업로드 성공",
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ApiResponseWrapper.class)))
@ApiResponse(responseCode = "401", description = "세션이 만료됨")
@PostMapping("/mentor")
ResponseEntity<ApiResponseWrapper<Void>> uploadMentorCertificate(
@Parameter(description = "멘토 증명서 업로드 요청 데이터", required = true)
@ModelAttribute CertificateUploadRequest certificateUploadRequest,

@Parameter(hidden = true)
HttpSession session
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@RestController
@RequestMapping("/storage/profile")
@RequiredArgsConstructor
public class ProfileImageController {
public class ProfileImageController implements ProfileImageControllerDocs {

private final StorageProfileImageService storageProfileService;

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

import es.princip.ringus.global.util.ApiResponseWrapper;
import es.princip.ringus.infra.storage.dto.ProfileUploadRequest;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
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 = "프로필 이미지를 업로드하는 API")
@RequestMapping("/storage/profile")
public interface ProfileImageControllerDocs {

@Operation(
summary = "프로필 이미지 업로드",
description = "사용자의 프로필 이미지를 업로드합니다. \n\n ⚠️ **multipart/form-data 형식**으로 요청해야 합니다.",
requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(
content = @Content(mediaType = "multipart/form-data",
schema = @Schema(implementation = ProfileUploadRequest.class))
)
)
@ApiResponse(responseCode = "200", description = "프로필 이미지 업로드 성공",
content = @Content(mediaType = "application/json", schema = @Schema(implementation = ApiResponseWrapper.class)))
@ApiResponse(responseCode = "401", description = "세션이 만료됨")
@PostMapping(value = "/image", consumes = "multipart/form-data")
ResponseEntity<ApiResponseWrapper<Void>> uploadProfileImage(
@Parameter(description = "프로필 이미지 업로드 요청 데이터 (폼데이터 형식)", required = true)
@ModelAttribute ProfileUploadRequest request,

@Parameter(hidden = true)
HttpSession session
);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package es.princip.ringus.infra.storage.domain;

import io.swagger.v3.oas.annotations.media.Schema;

@Schema(description = "증명서 타입")
public enum CertificateType {
@Schema(description = "재학증명서")
ENROLLMENT, // 재학증명서
@Schema(description = "졸업증명서")
GRADUATION, // 졸업증명서
@Schema(description = "재직증명서")
EMPLOYMENT, // 재직증명서
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

import es.princip.ringus.infra.storage.domain.CertificateType;
import es.princip.ringus.infra.storage.domain.FileMember;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.web.multipart.MultipartFile;

@Schema(description = "증명서 업로드 요청 데이터")
public record CertificateUploadRequest(
@Schema(description = "파일", required = true, example = "file.pdf")
MultipartFile file,
@Schema(description = "증명서 유형 ENUM", required = true, example = "ENROLLMENT")
CertificateType certificateType
) {
// form-data 형식에서는 record 클래스는 자동 바인딩이 안돼서 생성자를 명시적으로 만들어줘야 함
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import es.princip.ringus.domain.member.MemberType;
import es.princip.ringus.infra.storage.domain.ProfileImage;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.web.multipart.MultipartFile;

@Schema(description = "프로필 이미지 업로드 요청 데이터")
public record ProfileUploadRequest(
@Schema(description = "파일", required = true, example = "profile.jpg")
MultipartFile file,
MemberType memberType,
Long userId // 업로드 요청 시 사용자 ID도 함께 받음
@Schema(description = "유저 타입 ENUM", required = true, example = "MENTOR")
MemberType memberType
) {
// 기본생성자 명시적 정의
public ProfileUploadRequest {
Expand All @@ -17,9 +20,6 @@ public record ProfileUploadRequest(
if (memberType == null) {
throw new IllegalArgumentException("유저타입은 필수입니다. ");
}
if (userId == null) {
throw new IllegalArgumentException("userId는 필수입니다.");
}
}
public static ProfileImage toEntity(ProfileUploadRequest request, String filePath) {
return ProfileImage.builder()
Expand Down