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 @@ -42,7 +42,7 @@ public Long register(Long memberId, MenteeRequest request) {

@Transactional
public Long edit(Long memberId, EditMenteeRequest request) {
Mentee mentee = menteeRepository.findById(memberId)
Mentee mentee = menteeRepository.findByMemberId(memberId)
.orElseThrow(() -> new CustomRuntimeException(MenteeErrorCode.MENTEE_PROFILE_NOT_FOUND));

mentee.edit(request);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package es.princip.ringus.application.mentee.service;

import es.princip.ringus.domain.exception.MenteeErrorCode;
import es.princip.ringus.domain.mentee.Mentee;
import es.princip.ringus.domain.mentee.MenteeRepository;
import es.princip.ringus.global.exception.CustomRuntimeException;
import es.princip.ringus.presentation.mentee.dto.MyMenteeResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class MyMenteeService {
private final MenteeRepository menteeRepository;

public MyMenteeResponse getDetailBy(Long mentorId) {
Mentee mentee = menteeRepository.findByMemberId(mentorId)
.orElseThrow(() -> new CustomRuntimeException(MenteeErrorCode.MENTEE_NOT_FOUND));
return MyMenteeResponse.from(mentee);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package es.princip.ringus.application.mentor.service;

import es.princip.ringus.domain.exception.MentorErrorCode;
import es.princip.ringus.domain.mentor.Mentor;
import es.princip.ringus.domain.mentor.MentorRepository;
import es.princip.ringus.global.exception.CustomRuntimeException;
import es.princip.ringus.presentation.mentor.dto.MyMentorResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class MyMentorService {
private final MentorRepository mentorRepository;

public MyMentorResponse getDetailBy(Long memberId) {
Mentor mentor = mentorRepository.findByMemberId(memberId)
.orElseThrow(() -> new CustomRuntimeException(MentorErrorCode.MENTOR_PROFILE_NOT_FOUND));
return MyMentorResponse.from(mentor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,11 @@ public interface MentorRepository extends JpaRepository<Mentor, Long> {
@Query("SELECT m.profileImage FROM Mentor m WHERE m.memberId = :memberId")
ProfileImage findProfileByMemberId(Long memberId);

@Query("SELECT m.organization FROM Mentor m WHERE m.memberId = :memberId")
Organization findOrganizationByMemberId(Long memberId);

@Query("SELECT m FROM Mentor m WHERE m.memberId = :memberId")
Optional<Mentor> findByMemberId(Long memberId);

boolean existsByNickname(String nickname);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ResponseEntity<ApiResponseWrapper<EditMenteeResponse>> update(
}

@Override
public ResponseEntity<ApiResponseWrapper<MyMenteeResponse>> getMyMentee(Long menteeId) {
public ResponseEntity<ApiResponseWrapper<MenteeDetailResponse>> getMyMentee(Long menteeId) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ ResponseEntity<ApiResponseWrapper<EditMenteeResponse>> update(
@ApiResponse(responseCode = "404", description = "해당 id의 멘티가 존재하지 않음")
})
@GetMapping
ResponseEntity<ApiResponseWrapper<MyMenteeResponse>> getMyMentee(Long menteeId);
ResponseEntity<ApiResponseWrapper<MenteeDetailResponse>> getMyMentee(Long menteeId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package es.princip.ringus.presentation.mentee;

import es.princip.ringus.application.mentee.service.MyMenteeService;
import es.princip.ringus.global.annotation.SessionCheck;
import es.princip.ringus.global.annotation.SessionMemberId;
import es.princip.ringus.global.util.ApiResponseWrapper;
import es.princip.ringus.presentation.mentee.dto.MyMenteeResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/mentee/me")
public class MyMenteeController implements MyMenteeControllerDocs {
private final MyMenteeService menteeService;

@SessionCheck
@Override
public ResponseEntity<ApiResponseWrapper<MyMenteeResponse>> getMyMentee(
@SessionMemberId Long memberId
) {
MyMenteeResponse response = menteeService.getDetailBy(memberId);
return ResponseEntity.ok(ApiResponseWrapper.success(HttpStatus.OK, "성공", response));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
@RequestMapping("/mentee/me")
public interface MyMenteeControllerDocs {

@Operation(summary = "내 멘티 조회(구현 중)", description = "기존 멘티 정보를 수정합니다.")
@Operation(summary = "내 멘티 상세 조회", description = " 멘티 상세 정보를 조회합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "나의 멘티 조회 성공"),
@ApiResponse(responseCode = "200", description = "나의 멘티 상세 정보 조회 성공"),
@ApiResponse(responseCode = "404", description = "멘티 프로필을 등록한 적이 없음")
})
@GetMapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
public record MyMenteeResponse(
String nickname,
EducationResponse education,
String introduction
String introduction,
String imgUrl
) {
public static MyMenteeResponse from(final Mentee mentee) {
return new MyMenteeResponse(
mentee.getNickname(),
EducationResponse.from(mentee.getEducation()),
mentee.getIntroduction()
mentee.getIntroduction(),
mentee.getProfileImage().getFilePath()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@Slf4j

@RestController
@RequiredArgsConstructor
@RequestMapping("/mentor")
Expand Down Expand Up @@ -49,8 +49,6 @@ public ResponseEntity<ApiResponseWrapper<CursorResponse<MentorCardResponse>>> ge
@ModelAttribute final CursorRequest request,
@PageableDefault(sort = "mentorId", direction = Sort.Direction.DESC) final Pageable pageable
) {
log.info(request.toString());
log.info(pageable.toString());
CursorResponse<MentorCardResponse> response = mentorService.getMentorBy(request, pageable);
return ResponseEntity.ok(ApiResponseWrapper.success(HttpStatus.OK, "성공", response));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package es.princip.ringus.presentation.mentor;

import es.princip.ringus.application.mentor.service.MyMentorService;
import es.princip.ringus.global.annotation.SessionCheck;
import es.princip.ringus.global.annotation.SessionMemberId;
import es.princip.ringus.global.util.ApiResponseWrapper;
import es.princip.ringus.presentation.mentor.dto.MyMentorResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/mentor/me")
public class MyMentorController implements MyMentorControllerDocs {
private final MyMentorService mentorService;

@SessionCheck
@Override
public ResponseEntity<ApiResponseWrapper<MyMentorResponse>> getMyMentor(
@SessionMemberId Long memberId
) {
MyMentorResponse response = mentorService.getDetailBy(memberId);
return ResponseEntity.ok(ApiResponseWrapper.success(HttpStatus.OK, "성공", response));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import es.princip.ringus.global.annotation.SessionMemberId;
import es.princip.ringus.global.util.ApiResponseWrapper;
import es.princip.ringus.presentation.mentor.dto.MentorCardResponse;
import es.princip.ringus.presentation.mentor.dto.MyMentorResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
Expand All @@ -16,7 +15,7 @@
@RequestMapping("/mentor/me")
public interface MyMentorControllerDocs {

@Operation(summary = "내 멘토 조회(구현 중)", description = "기존 멘토 정보를 수정합니다.")
@Operation(summary = "내 멘토 조회", description = "기존 멘토 정보를 수정합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "나의 멘토 조회 성공"),
@ApiResponse(responseCode = "404", description = "멘토 프로필을 등록한 적이 없음")
Expand Down
Loading