Skip to content

Commit 716abb8

Browse files
committed
RINGUS-34 feat: 멘티 프로필 등록 기능 구현
1 parent e16951a commit 716abb8

File tree

7 files changed

+50
-33
lines changed

7 files changed

+50
-33
lines changed

src/main/java/es/princip/ringus/domain/mentee/Mentee.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package es.princip.ringus.domain.mentee;
22

33
import es.princip.ringus.domain.common.Education;
4-
import es.princip.ringus.infra.storage.domain.Certificate;
54
import es.princip.ringus.infra.storage.domain.ProfileImage;
65
import jakarta.persistence.*;
76
import lombok.AccessLevel;
@@ -43,18 +42,13 @@ public Mentee(
4342
final String nickname,
4443
final Education education,
4544
final String introduction,
45+
final ProfileImage profileImage,
4646
final Long memberId
4747
) {
4848
this.nickname = nickname;
4949
this.education = education;
5050
this.introduction = introduction;
51-
this.memberId = memberId;
52-
}
53-
54-
/**
55-
* 프로필 이미지 업데이트
56-
*/
57-
public void updateProfileImage(ProfileImage profileImage) {
5851
this.profileImage = profileImage;
52+
this.memberId = memberId;
5953
}
6054
}

src/main/java/es/princip/ringus/infra/storage/application/StorageService.java

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
package es.princip.ringus.infra.storage.application;
22

33
import es.princip.ringus.domain.member.MemberType;
4-
import es.princip.ringus.domain.mentee.Mentee;
5-
import es.princip.ringus.domain.mentee.MenteeRepository;
6-
import es.princip.ringus.domain.mentor.Mentor;
7-
import es.princip.ringus.domain.mentor.MentorRepository;
84
import es.princip.ringus.infra.storage.domain.CertificateType;
9-
import es.princip.ringus.infra.storage.domain.ProfileImage;
105
import es.princip.ringus.infra.storage.dto.CertificateUploadRequest;
116
import es.princip.ringus.infra.storage.dto.ProfileUploadRequest;
127
import lombok.RequiredArgsConstructor;
@@ -19,8 +14,6 @@
1914
public class StorageService {
2015

2116
private final S3Service s3Service;
22-
private final MenteeRepository menteeRepository;
23-
private final MentorRepository mentorRepository;
2417

2518
@Transactional
2619
public String uploadMenteeCertificate(CertificateUploadRequest request) {
@@ -47,22 +40,8 @@ public String uploadMentorCertificate(CertificateUploadRequest request) {
4740
@Transactional
4841
public String uploadProfileImage(ProfileUploadRequest request) {
4942
String folderPath = buildProfileFolderPath(request.memberType());
50-
String uploadedFilePath = s3Service.uploadFile(request.file(), folderPath);
5143

52-
ProfileImage profileImage = ProfileUploadRequest.toEntity(request, uploadedFilePath);
53-
54-
if(request.memberType() == MemberType.MENTEE) {
55-
Mentee mentee = menteeRepository.findById(request.userId())
56-
.orElseThrow(() -> new IllegalArgumentException("Mentee not found with id: " + request.userId()));
57-
mentee.updateProfileImage(profileImage);
58-
menteeRepository.save(mentee);
59-
} else if(request.memberType() == MemberType.MENTOR) {
60-
Mentor mentor = mentorRepository.findById(request.userId())
61-
.orElseThrow(() -> new IllegalArgumentException("Mentor not found with id: " + request.userId()));
62-
mentor.updateProfileImage(profileImage);
63-
mentorRepository.save(mentor);
64-
}
65-
return uploadedFilePath;
44+
return s3Service.uploadFile(request.file(), folderPath);
6645
}
6746

6847
// 증명서 폴더 경로 생성 (멘티용)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package es.princip.ringus.presentation.common.dto;
2+
3+
import es.princip.ringus.infra.storage.domain.ProfileImage;
4+
import jakarta.validation.constraints.NotBlank;
5+
6+
public record ProfileImageRequest(
7+
@NotBlank String fileName,
8+
@NotBlank String filePath
9+
) {
10+
public ProfileImage toEntity() {
11+
return ProfileImage.builder()
12+
.fileName(fileName)
13+
.filePath(filePath)
14+
.build();
15+
}
16+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
package es.princip.ringus.presentation.mentee;
22

3+
import es.princip.ringus.application.mentee.service.MenteeService;
4+
import es.princip.ringus.global.util.ApiResponseWrapper;
5+
import es.princip.ringus.presentation.mentee.dto.MenteeRequest;
6+
import es.princip.ringus.presentation.mentee.dto.MenteeResponse;
7+
import jakarta.validation.Valid;
8+
import lombok.RequiredArgsConstructor;
9+
import org.springframework.http.HttpStatus;
10+
import org.springframework.http.ResponseEntity;
11+
import org.springframework.web.bind.annotation.PostMapping;
12+
import org.springframework.web.bind.annotation.RequestBody;
13+
import org.springframework.web.bind.annotation.RequestMapping;
14+
import org.springframework.web.bind.annotation.RestController;
15+
16+
@RestController
17+
@RequiredArgsConstructor
18+
@RequestMapping("/mentee")
319
public class MenteeController {
20+
private final MenteeService menteeService;
21+
22+
@PostMapping
23+
public ResponseEntity<ApiResponseWrapper<MenteeResponse>> create(@Valid @RequestBody MenteeRequest request) {
24+
MenteeResponse response = MenteeResponse.from(menteeService.register(request));
25+
return ResponseEntity.ok(ApiResponseWrapper.success(HttpStatus.OK, "성공", response));
26+
}
427
}

src/main/java/es/princip/ringus/presentation/mentee/dto/MenteeRequest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
package es.princip.ringus.presentation.mentee.dto;
22

3-
import es.princip.ringus.domain.mentee.EducationLevelType;
43
import es.princip.ringus.domain.mentee.Mentee;
54
import es.princip.ringus.domain.common.Education;
65
import es.princip.ringus.presentation.common.dto.EducationRequest;
6+
import es.princip.ringus.presentation.common.dto.ProfileImageRequest;
77
import jakarta.validation.constraints.NotBlank;
88

99
public record MenteeRequest(
1010
@NotBlank String email,
1111
@NotBlank String nickname,
1212
EducationRequest education,
13+
ProfileImageRequest image,
1314
@NotBlank String introduction
1415
) {
1516
public Mentee toEntity() {
1617
return Mentee.builder()
1718
.nickname(nickname)
1819
.education(new Education(education.schoolName(), education().major()))
20+
.profileImage(image.toEntity())
1921
.introduction(introduction)
2022
.build();
2123
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package es.princip.ringus.presentation.mentee.dto;
22

33
public record MenteeResponse(
4-
4+
Long menteeId
55
) {
6+
public static MenteeResponse from(Long menteeId) {
7+
return new MenteeResponse(menteeId);
8+
}
69
}

src/main/java/es/princip/ringus/presentation/mentor/dto/MentorResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package es.princip.ringus.presentation.mentor.dto;
22

33
public record MentorResponse(
4-
Long mentorId
4+
Long mentorId
55
) {
66
public static MentorResponse from(Long mentorId) {
77
return new MentorResponse(mentorId);

0 commit comments

Comments
 (0)