-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat : 유저 취향 상자 관련 API 추가 #125 * feat : UserFavor(유저 취향 상자) order 삭제, 수정 로직 변경 #125 * fix : UserFaovr order 관련 에러 수정 #125 * edit : 취향 상자 수정 시 @NotNull 추가 #125 * spotless Apply #125 * feat : 유저 프로필 조회 시 취향 상자 정보 포함 #125 * feat : 친구 프로필, 취향 정보 조회 API 작성 #125 * feat : VO 필드 변경 #125 * spotless Apply #125
- Loading branch information
1 parent
3f004af
commit ff1a942
Showing
28 changed files
with
345 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Api/src/main/java/tify/server/api/user/model/dto/UserFavorDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package tify.server.api.user.model.dto; | ||
|
||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import tify.server.domain.domains.user.domain.DetailCategory; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class UserFavorDto { | ||
|
||
@Schema(description = "취향의 종류입니다.", example = "LIP") | ||
private DetailCategory detailCategory; | ||
} |
15 changes: 15 additions & 0 deletions
15
Api/src/main/java/tify/server/api/user/model/dto/request/PatchUserFavorRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package tify.server.api.user.model.dto.request; | ||
|
||
|
||
import java.util.List; | ||
import javax.validation.constraints.NotNull; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import tify.server.api.user.model.dto.UserFavorDto; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class PatchUserFavorRequest { | ||
|
||
@NotNull private List<UserFavorDto> userFavorDtoList; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
Api/src/main/java/tify/server/api/user/model/dto/vo/RetrieveUserFavorBoxVo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package tify.server.api.user.model.dto.vo; | ||
|
||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import java.util.List; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import tify.server.domain.domains.user.domain.DetailCategory; | ||
import tify.server.domain.domains.user.domain.User; | ||
import tify.server.domain.domains.user.domain.UserFavor; | ||
|
||
@Getter | ||
@Builder | ||
public class RetrieveUserFavorBoxVo { | ||
|
||
@Schema(description = "친구의 pk값입니다.", example = "1") | ||
private final Long id; | ||
|
||
@Schema(description = "친구의 프로필 이미지입니다.") | ||
private final String thumbnail; | ||
|
||
@Schema(description = "친구의 id입니다.", example = "@aaa") | ||
private final String userId; | ||
|
||
@Schema(description = "친구의 이름입니다.", example = "홍길동") | ||
private final String userName; | ||
|
||
@Schema(description = "친구의 취향 상자 정보입니다.", example = "PLACE, TOP, FAS_PRODUCT") | ||
private final List<DetailCategory> userFavorList; | ||
|
||
@Schema(description = "친구의 온보딩 상태 정보입니다.") | ||
private final String userOnBoardingStatus; | ||
|
||
public static RetrieveUserFavorBoxVo from(User user) { | ||
return RetrieveUserFavorBoxVo.builder() | ||
.id(user.getId()) | ||
.thumbnail(user.getProfile().getThumbNail()) | ||
.userId(user.getUserId()) | ||
.userName(user.getProfile().getUserName()) | ||
.userFavorList( | ||
user.getUserFavors().stream().map(UserFavor::getDetailCategory).toList()) | ||
.userOnBoardingStatus(user.getOnBoardingStatus().getName()) | ||
.build(); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
Api/src/main/java/tify/server/api/user/model/dto/vo/UserFavorBoxVo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package tify.server.api.user.model.dto.vo; | ||
|
||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import tify.server.domain.domains.user.domain.DetailCategory; | ||
import tify.server.domain.domains.user.domain.LargeCategory; | ||
import tify.server.domain.domains.user.domain.SmallCategory; | ||
import tify.server.domain.domains.user.vo.UserFavorVo; | ||
|
||
@Getter | ||
@Builder | ||
public class UserFavorBoxVo { | ||
|
||
@Schema(description = "유저 취향 박스 내 취향의 pk값입니다.", example = "1") | ||
private final Long userFavorId; | ||
|
||
@Schema(description = "유저 취향 박스 내 취향의 대분류입니다.", example = "BEAUTY") | ||
private final LargeCategory largeCategory; | ||
|
||
@Schema(description = "유저 취향 박스 내 취향의 중분류입니다.", example = "MAKEUP") | ||
private final SmallCategory smallCategory; | ||
|
||
@Schema(description = "유저 취향 박스 내 취향의 소분류입니다.", example = "LIP") | ||
private final DetailCategory detailCategory; | ||
|
||
public static UserFavorBoxVo from(UserFavorVo userFavorVo) { | ||
return UserFavorBoxVo.builder() | ||
.userFavorId(userFavorVo.getUserFavor().getId()) | ||
.largeCategory(userFavorVo.getLargeCategory()) | ||
.smallCategory(userFavorVo.getUserFavor().getDetailCategory().getSmallCategory()) | ||
.detailCategory(userFavorVo.getUserFavor().getDetailCategory()) | ||
.build(); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
Api/src/main/java/tify/server/api/user/service/RetrieveNeighborFavorBoxUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package tify.server.api.user.service; | ||
|
||
|
||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import tify.server.api.config.security.SecurityUtils; | ||
import tify.server.api.user.model.dto.vo.RetrieveUserFavorBoxVo; | ||
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.dto.condition.NeighborCondition; | ||
|
||
@UseCase | ||
@RequiredArgsConstructor | ||
public class RetrieveNeighborFavorBoxUseCase { | ||
|
||
private final UserAdaptor userAdaptor; | ||
private final UserBlockAdaptor userBlockAdaptor; | ||
private final NeighborAdaptor neighborAdaptor; | ||
|
||
@Transactional(readOnly = true) | ||
public List<RetrieveUserFavorBoxVo> execute() { | ||
Long currentUserId = SecurityUtils.getCurrentUserId(); | ||
|
||
List<Long> blockedUserList = | ||
userBlockAdaptor.queryAllByFromUserId(currentUserId).stream() | ||
.map(UserBlock::getToUserId) | ||
.toList(); | ||
List<Long> friendIdList = | ||
neighborAdaptor.queryAllByToUserId(currentUserId).stream() | ||
.map(Neighbor::getFromUserId) | ||
.toList(); | ||
NeighborCondition neighborCondition = | ||
new NeighborCondition(currentUserId, blockedUserList, friendIdList); | ||
|
||
return userAdaptor.queryUserFavorBox(currentUserId, neighborCondition).stream() | ||
.map(RetrieveUserFavorBoxVo::from) | ||
.toList(); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
Api/src/main/java/tify/server/api/user/service/UpdateUserFavorUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package tify.server.api.user.service; | ||
|
||
|
||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import tify.server.api.user.model.dto.request.PatchUserFavorRequest; | ||
import tify.server.core.annotation.UseCase; | ||
import tify.server.core.exception.BaseException; | ||
import tify.server.domain.domains.user.adaptor.UserAdaptor; | ||
import tify.server.domain.domains.user.adaptor.UserFavorAdaptor; | ||
import tify.server.domain.domains.user.domain.User; | ||
import tify.server.domain.domains.user.domain.UserFavor; | ||
import tify.server.domain.domains.user.exception.UserException; | ||
|
||
@UseCase | ||
@RequiredArgsConstructor | ||
public class UpdateUserFavorUseCase { | ||
|
||
private final UserAdaptor userAdaptor; | ||
private final UserFavorAdaptor userFavorAdaptor; | ||
|
||
@Transactional | ||
public void execute(Long userId, PatchUserFavorRequest body) { | ||
if (body.getUserFavorDtoList().size() != 3) { | ||
throw new BaseException(UserException.USER_FAVOR_UPDATE_ERROR); | ||
} | ||
User user = userAdaptor.query(userId); | ||
|
||
List<UserFavor> updateFavors = | ||
body.getUserFavorDtoList().stream() | ||
.map( | ||
dto -> | ||
UserFavor.builder() | ||
.user(user) | ||
.detailCategory(dto.getDetailCategory()) | ||
.build()) | ||
.toList(); | ||
user.updateUserFavors(updateFavors); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.