Skip to content

Commit

Permalink
Merge pull request #22 from Fairy-Taless/dev
Browse files Browse the repository at this point in the history
Dev Merge
  • Loading branch information
junhaa authored Jun 14, 2024
2 parents 9602f39 + 738e2ae commit efd1497
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Optional;

import fairytale.tbd.domain.user.entity.User;
import fairytale.tbd.domain.user.web.dto.UserResponseDTO;

public interface UserQueryService {

Expand All @@ -11,4 +12,6 @@ public interface UserQueryService {
void updateRefreshToken(User user, String reIssuedRefreshToken);

Optional<User> getUserWithUserId(Long userId);

UserResponseDTO.MyPageGetResultDto getUserMyPage(User user);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import fairytale.tbd.domain.user.entity.User;
import fairytale.tbd.domain.user.repository.UserRepository;
import fairytale.tbd.domain.user.web.dto.UserResponseDTO;
import lombok.RequiredArgsConstructor;

@Service
Expand Down Expand Up @@ -41,4 +42,12 @@ public Optional<User> getUserWithUserId(Long userId) {
return userRepository.findById(userId);
}

@Override
public UserResponseDTO.MyPageGetResultDto getUserMyPage(User user) {
return UserResponseDTO.MyPageGetResultDto.builder()
.userName(user.getUsername())
.imageUrl(user.getFaceImageUrl())
.uploadedVoice(user.getVoice() != null)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface ExistUsername {
String message() default("이미 존재하는 닉네임입니다.");

Class<?>[] groups() default {};
String message() default ("이미 존재하는 닉네임입니다.");

Class<? extends Payload>[] payload() default {};
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -10,8 +11,10 @@
import fairytale.tbd.domain.user.converter.UserConverter;
import fairytale.tbd.domain.user.entity.User;
import fairytale.tbd.domain.user.service.UserCommandService;
import fairytale.tbd.domain.user.service.UserQueryService;
import fairytale.tbd.domain.user.web.dto.UserRequestDTO;
import fairytale.tbd.domain.user.web.dto.UserResponseDTO;
import fairytale.tbd.global.annotation.LoginUser;
import fairytale.tbd.global.response.ApiResponse;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand All @@ -22,6 +25,7 @@
public class UserRestController {

private final UserCommandService userCommandService;
private final UserQueryService userQueryService;
private static final Logger LOGGER = LogManager.getLogger(UserRestController.class);

/**
Expand All @@ -33,4 +37,14 @@ public ApiResponse<UserResponseDTO.AddUserResultDTO> join(@Valid @RequestBody Us
User user = userCommandService.addUser(request);
return ApiResponse.onSuccess(UserConverter.toAddUserResultDTO(user));
}

/**
* 사용자 마이페이지 데이터 조회
*/

@GetMapping("")
public ApiResponse<UserResponseDTO.MyPageGetResultDto> getMyPage(@LoginUser User user) {
UserResponseDTO.MyPageGetResultDto result = userQueryService.getUserMyPage(user);
return ApiResponse.onSuccess(result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,19 @@ public class UserResponseDTO {
@Getter
@NoArgsConstructor
@AllArgsConstructor
public static class AddUserResultDTO{
public static class AddUserResultDTO {
private Long userId;
private LocalDateTime createdAt;
}

@Builder
@Getter
@NoArgsConstructor
@AllArgsConstructor
public static class MyPageGetResultDto {
private String imageUrl;
private String userName;

private Boolean uploadedVoice;
}
}

0 comments on commit efd1497

Please sign in to comment.