diff --git a/src/main/java/com/soongsil/CoffeeChat/controller/MentorController.java b/src/main/java/com/soongsil/CoffeeChat/controller/MentorController.java index ff3d010..e4ea70c 100644 --- a/src/main/java/com/soongsil/CoffeeChat/controller/MentorController.java +++ b/src/main/java/com/soongsil/CoffeeChat/controller/MentorController.java @@ -4,6 +4,7 @@ import java.util.List; +import com.soongsil.CoffeeChat.dto.*; import org.springframework.http.ResponseEntity; import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.GetMapping; @@ -15,11 +16,6 @@ import org.springframework.web.bind.annotation.RestController; import com.soongsil.CoffeeChat.controller.handler.ApiResponseGenerator; -import com.soongsil.CoffeeChat.dto.MentorGetListResponseDto; -import com.soongsil.CoffeeChat.dto.MentorGetUpdateDetailDto; -import com.soongsil.CoffeeChat.dto.MentorIntroductionUpdateRequestDto; -import com.soongsil.CoffeeChat.dto.MentorIntroductionUpdateResponseDto; -import com.soongsil.CoffeeChat.dto.MentorUpdateRequestDto; import com.soongsil.CoffeeChat.dto.Oauth.CustomOAuth2User; import com.soongsil.CoffeeChat.enums.ClubEnum; import com.soongsil.CoffeeChat.enums.PartEnum; @@ -79,7 +75,7 @@ public ResponseEntity> getMentorI @PatchMapping("/introductions") @Operation(summary = "멘토 자기소개 입력") @ApiResponse(responseCode = "200", description = "자기소개의 수정된 버전을 반환") - public ResponseEntity> updateMentoIntroduction( + public ResponseEntity> updateMentoIntroduction( Authentication authentication, @RequestBody MentorIntroductionUpdateRequestDto dto ) throws Exception { @@ -90,6 +86,21 @@ public ResponseEntity> ); } + @GetMapping("/introductions") + @Operation(summary = "토큰으로 멘토 자기소개 항목 4개 조회") + @ApiResponse(responseCode = "200", description = "토큰으로 멘토 본인의 자기소개 조회") + public ResponseEntity> getMentorIntroduction( + Authentication authentication + ) throws Exception{ + return ResponseEntity.ok().body( + ApiResponseGenerator.onSuccessOK( + mentorService.getMentorIntroduction( + getUserNameByAuthentication(authentication) + ) + ) + ); + } + @GetMapping("/part") @Operation(summary = "파트별 멘토 리스트 가져오기") @ApiResponse(responseCode = "200", description = "DTO LIST형식으로 정보 반환") diff --git a/src/main/java/com/soongsil/CoffeeChat/dto/MentorIntroductionUpdateResponseDto.java b/src/main/java/com/soongsil/CoffeeChat/dto/MentorIntroductionGetUpdateResponseDto.java similarity index 89% rename from src/main/java/com/soongsil/CoffeeChat/dto/MentorIntroductionUpdateResponseDto.java rename to src/main/java/com/soongsil/CoffeeChat/dto/MentorIntroductionGetUpdateResponseDto.java index 6ce95a7..70bef7c 100644 --- a/src/main/java/com/soongsil/CoffeeChat/dto/MentorIntroductionUpdateResponseDto.java +++ b/src/main/java/com/soongsil/CoffeeChat/dto/MentorIntroductionGetUpdateResponseDto.java @@ -8,7 +8,7 @@ @Builder @Getter -public class MentorIntroductionUpdateResponseDto { +public class MentorIntroductionGetUpdateResponseDto { @JsonProperty("introduction_title") @NonNull diff --git a/src/main/java/com/soongsil/CoffeeChat/service/MentorService.java b/src/main/java/com/soongsil/CoffeeChat/service/MentorService.java index ced35e6..99b1262 100644 --- a/src/main/java/com/soongsil/CoffeeChat/service/MentorService.java +++ b/src/main/java/com/soongsil/CoffeeChat/service/MentorService.java @@ -5,15 +5,11 @@ import java.util.List; +import com.soongsil.CoffeeChat.dto.*; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.soongsil.CoffeeChat.controller.exception.CustomException; -import com.soongsil.CoffeeChat.dto.MentorGetListResponseDto; -import com.soongsil.CoffeeChat.dto.MentorGetUpdateDetailDto; -import com.soongsil.CoffeeChat.dto.MentorIntroductionUpdateRequestDto; -import com.soongsil.CoffeeChat.dto.MentorIntroductionUpdateResponseDto; -import com.soongsil.CoffeeChat.dto.MentorUpdateRequestDto; import com.soongsil.CoffeeChat.entity.Introduction; import com.soongsil.CoffeeChat.entity.Mentor; import com.soongsil.CoffeeChat.entity.User; @@ -87,7 +83,7 @@ public MentorGetUpdateDetailDto updateMentorInfo(String username, MentorUpdateRe } @Transactional - public MentorIntroductionUpdateResponseDto updateMentorIntroduction( + public MentorIntroductionGetUpdateResponseDto updateMentorIntroduction( String userName, MentorIntroductionUpdateRequestDto dto) { User findUser = userRepository.findByUsername(userName).orElseThrow( @@ -106,11 +102,22 @@ public MentorIntroductionUpdateResponseDto updateMentorIntroduction( findMentorIntroduction.updateIntroduction(dto); - return MentorIntroductionUpdateResponseDto.builder() + return MentorIntroductionGetUpdateResponseDto.builder() .title(findMentorIntroduction.getTitle()) .description(findMentorIntroduction.getDescription()) .answer1(findMentorIntroduction.getAnswer1()) .answer2(findMentorIntroduction.getAnswer2()) .build(); } + + public MentorIntroductionGetUpdateResponseDto getMentorIntroduction(String username){ + User findUser = userRepository.findByUsername(username).orElseThrow(); + Introduction introduction = findUser.getMentor().getIntroduction(); + return MentorIntroductionGetUpdateResponseDto.builder() + .answer1(introduction.getAnswer1()) + .answer2(introduction.getAnswer2()) + .title(introduction.getTitle()) + .description(introduction.getDescription()) + .build(); + } }