Skip to content

Commit

Permalink
[merge] 게스트 프로필 조회 API 구현
Browse files Browse the repository at this point in the history
[feat] 게스트 프로필 조회 API 구현
  • Loading branch information
lreowy authored Sep 11, 2024
2 parents d6b8e65 + 32ad72f commit 3a370c2
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import com.pickple.server.api.guest.dto.request.GuestUpdateRequest;
import com.pickple.server.api.guest.service.GuestCommandService;
import com.pickple.server.api.guest.service.GuestQueryService;
import com.pickple.server.global.response.ApiResponseDto;
import com.pickple.server.global.response.enums.SuccessCode;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -15,14 +17,21 @@
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class GuestController {
public class GuestController implements GuestControllerDocs {

private final GuestCommandService guestCommandService;
private final GuestQueryService guestQueryService;

@PatchMapping("/v2/guest/{guestId}")
public ApiResponseDto updateGuestProfile(@PathVariable final Long guestId,
@RequestBody @Valid final GuestUpdateRequest guestUpdateRequest) {
guestCommandService.updateGuestNickname(guestId, guestUpdateRequest);
return ApiResponseDto.success(SuccessCode.GUEST_PROFILE_UPDATE_SUCCESS);
}

@GetMapping("/v2/guest/{guestId}")
public ApiResponseDto getGuest(@PathVariable final Long guestId) {
return ApiResponseDto.success(SuccessCode.GUEST_GET_SUCCESS, guestQueryService.getGuest(guestId));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.pickple.server.api.guest.controller;

import com.pickple.server.api.guest.dto.request.GuestUpdateRequest;
import com.pickple.server.global.response.ApiResponseDto;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;

@Tag(name = "Guest", description = "Guest 관련 API")
public interface GuestControllerDocs {

@Operation(summary = "게스트 프로필 수정")
@ApiResponses(
value = {
@ApiResponse(responseCode = "20034", description = "게스트 프로필 수정 성공"),
@ApiResponse(responseCode = "40008", description = "이미 존재하는 닉네임입니다."),
@ApiResponse(responseCode = "40403", description = "존재하지 않는 게스트입니다.")
}
)
ApiResponseDto updateGuestProfile(
final Long guestId,
final GuestUpdateRequest guestUpdateRequest
);

@Operation(summary = "게스트 프로필 조회")
@ApiResponses(
value = {
@ApiResponse(responseCode = "20041", description = "게스트 프로필 조회 성공"),
@ApiResponse(responseCode = "40403", description = "존재하지 않는 게스트입니다.")
}
)
ApiResponseDto getGuest(
final Long guestId
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.pickple.server.api.guest.dto.response;

import lombok.Builder;

@Builder
public record GuestGetResponse(

String guestImageUrl,

String guestNickname
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.pickple.server.api.guest.service;

import com.pickple.server.api.guest.domain.Guest;
import com.pickple.server.api.guest.dto.response.GuestGetResponse;
import com.pickple.server.api.guest.repository.GuestRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class GuestQueryService {

private final GuestRepository guestRepository;

public GuestGetResponse getGuest(final Long guestId) {
Guest guest = guestRepository.findGuestByUserId(guestId);
return GuestGetResponse.builder()
.guestImageUrl(guest.getImageUrl())
.guestNickname(guest.getNickname())
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public enum SuccessCode {
REVIEW_LIST_BY_MOIM_GET_SUCCESS(20037, HttpStatus.OK, "모임에 해당하는 리뷰 조회 성공"),
REVIEW_LIST_BY_HOST_GET_SUCCESS(20038, HttpStatus.OK, "호스트에 해당하는 리뷰 전체 조회 성공"),
MOIM_FOR_REVIEW_GET_SUCCESS(20039, HttpStatus.OK, "리뷰 작성 시 모임 정보 조회 성공"),

MOIM_LIST_BY_HOST(20040, HttpStatus.OK, "호스트에 해당하는 모임 조회 성공"),
GUEST_GET_SUCCESS(20041, HttpStatus.OK, "게스트 프로필 조회 성공"),

// 201 Created
MOIM_CREATE_SUCCESS(20100, HttpStatus.CREATED, "모임 개설 성공"),
Expand Down

0 comments on commit 3a370c2

Please sign in to comment.