Skip to content

Commit

Permalink
[FEATURE] 유저 정보 조회 관련 Response 수정 (#89)
Browse files Browse the repository at this point in the history
* feat : User 관련 기능 API 작성 #83

* spotlessApply #83

* feat : User 차단 관련 검색, 조회 API 로직 변경 #83

* feat : User 신고 정보 조회 API 작성 #83

* spotless Apply #83

* edit : @transactional 추가 #83

* feat : 유저 검색 시 친구 여부 보여지도록 수정, 검색 로직 수정, 신고 api에서 request body 삭제 #83

* spotless Apply #83

* feat : 유저 검색 시 친구, 차단 여부 표시 #83
  • Loading branch information
bongsh0112 authored Nov 6, 2023
1 parent f2bdf31 commit 3c3aeda
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package tify.server.api.user.service;


import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;
import tify.server.api.config.security.SecurityUtils;
import tify.server.core.annotation.UseCase;
import tify.server.domain.domains.user.adaptor.NeighborAdaptor;
import tify.server.domain.domains.user.adaptor.UserAdaptor;
import tify.server.domain.domains.user.adaptor.UserBlockAdaptor;
import tify.server.domain.domains.user.domain.Neighbor;
import tify.server.domain.domains.user.domain.UserBlock;
import tify.server.domain.domains.user.vo.UserInfoVo;
import tify.server.domain.domains.user.vo.UserProfileVo;

Expand All @@ -15,9 +20,18 @@
public class UserInfoUseCase {

private final UserAdaptor userAdaptor;
private final NeighborAdaptor neighborAdaptor;
private final UserBlockAdaptor userBlockAdaptor;

public UserProfileVo execute(Long userId) {
return userAdaptor.query(userId).toUserProfileVo();
Long currentUserId = SecurityUtils.getCurrentUserId();
Long searchedUserId = userAdaptor.query(userId).getId();
Optional<Neighbor> neighbor =
neighborAdaptor.queryByFromUserIdAndToUserId(currentUserId, searchedUserId);
Optional<UserBlock> userBlock =
userBlockAdaptor.queryByFromUserIdAndToUserId(currentUserId, searchedUserId);
return UserProfileVo.of(
userAdaptor.query(userId), neighbor.isPresent(), userBlock.isPresent());
}

public UserInfoVo executeByToken() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

import java.util.Optional;
import lombok.Builder;
import lombok.Getter;
import lombok.Data;
import tify.server.domain.domains.user.domain.Gender;
import tify.server.domain.domains.user.domain.Profile;
import tify.server.domain.domains.user.domain.User;
import tify.server.domain.domains.user.domain.UserOnBoardingStatus;

@Getter
@Data
@Builder
public class UserProfileVo {

Expand All @@ -29,6 +29,10 @@ public class UserProfileVo {

private final String onBoardingStatus;

private boolean isFriend;

private boolean isBlocked;

public static UserProfileVo from(User user) {
return UserProfileVo.builder()
.userName(
Expand All @@ -54,4 +58,11 @@ public static UserProfileVo from(User user) {
.orElse(null))
.build();
}

public static UserProfileVo of(User user, boolean isFriend, boolean isBlocked) {
UserProfileVo result = from(user);
result.setFriend(isFriend);
result.setBlocked(isBlocked);
return result;
}
}

0 comments on commit 3c3aeda

Please sign in to comment.