11package es .princip .ringus .infra .storage .api ;
22
3+ import es .princip .ringus .domain .exception .MemberErrorCode ;
4+ import es .princip .ringus .global .exception .CustomRuntimeException ;
35import es .princip .ringus .global .util .ApiResponseWrapper ;
46import es .princip .ringus .infra .storage .application .StorageService ;
5- import es .princip .ringus .infra .storage .domain .CertificateType ;
67import es .princip .ringus .infra .storage .dto .CertificateUploadRequest ;
78import es .princip .ringus .infra .storage .dto .ProfileUploadRequest ;
9+ import jakarta .servlet .http .HttpSession ;
810import lombok .RequiredArgsConstructor ;
911import org .springframework .http .HttpStatus ;
1012import org .springframework .http .ResponseEntity ;
11- import org .springframework .web .bind .annotation .*;
12- import org .springframework .web .multipart .MultipartFile ;
13+ import org .springframework .web .bind .annotation .ModelAttribute ;
14+ import org .springframework .web .bind .annotation .PostMapping ;
15+ import org .springframework .web .bind .annotation .RequestMapping ;
16+ import org .springframework .web .bind .annotation .RestController ;
1317
1418@ RestController
1519@ RequestMapping ("/storage" )
@@ -23,9 +27,16 @@ public class StorageController {
2327 */
2428 @ PostMapping ("/certificate/mentee" )
2529 public ResponseEntity <ApiResponseWrapper <Void >> uploadMenteeCertificate (
26- @ ModelAttribute CertificateUploadRequest certificateUploadRequest
30+ @ ModelAttribute CertificateUploadRequest certificateUploadRequest ,
31+ HttpSession session
2732 ) {
28- String filePath = storageService .uploadMenteeCertificate (certificateUploadRequest );
33+
34+ Long memberId = (Long )session .getAttribute ("memberId" );
35+ if (memberId == null ){
36+ throw new CustomRuntimeException (MemberErrorCode .SESSION_EXPIRED );
37+ }
38+
39+ String filePath = storageService .uploadMenteeCertificate (certificateUploadRequest ,memberId );
2940 return ResponseEntity .ok (ApiResponseWrapper .success (HttpStatus .OK , filePath ));
3041 }
3142
@@ -34,9 +45,15 @@ public ResponseEntity<ApiResponseWrapper<Void>> uploadMenteeCertificate(
3445 */
3546 @ PostMapping ("/certificate/mentor" )
3647 public ResponseEntity <ApiResponseWrapper <Void >> uploadMentorCertificate (
37- @ ModelAttribute CertificateUploadRequest certificateUploadRequest
48+ @ ModelAttribute CertificateUploadRequest certificateUploadRequest ,
49+ HttpSession session
3850 ) {
39- String filePath = storageService .uploadMentorCertificate (certificateUploadRequest );
51+ Long memberId = (Long )session .getAttribute ("memberId" );
52+ if (memberId == null ){
53+ throw new CustomRuntimeException (MemberErrorCode .SESSION_EXPIRED );
54+ }
55+
56+ String filePath = storageService .uploadMentorCertificate (certificateUploadRequest , memberId );
4057 return ResponseEntity .ok (ApiResponseWrapper .success (HttpStatus .OK , filePath ));
4158 }
4259
@@ -45,8 +62,15 @@ public ResponseEntity<ApiResponseWrapper<Void>> uploadMentorCertificate(
4562 */
4663 @ PostMapping ("/profile/image" )
4764 public ResponseEntity <ApiResponseWrapper <Void >> uploadProfileImage (
48- @ ModelAttribute ProfileUploadRequest request
65+ @ ModelAttribute ProfileUploadRequest request ,
66+ HttpSession session
4967 ) {
68+
69+ Long memberId = (Long )session .getAttribute ("memberId" );
70+ if (memberId == null ){
71+ throw new CustomRuntimeException (MemberErrorCode .SESSION_EXPIRED );
72+ }
73+
5074 String filePath = storageService .uploadProfileImage (request );
5175 return ResponseEntity .ok (ApiResponseWrapper .success (HttpStatus .OK , filePath ));
5276 }
0 commit comments