-
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.
- Loading branch information
1 parent
5b7ddef
commit c102d63
Showing
24 changed files
with
495 additions
and
16 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
52 changes: 52 additions & 0 deletions
52
Api/src/main/java/tify/server/api/user/service/AcceptanceNeighborApplicationUseCase.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,52 @@ | ||
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.core.annotation.UseCase; | ||
import tify.server.domain.domains.user.adaptor.NeighborAdaptor; | ||
import tify.server.domain.domains.user.domain.Neighbor; | ||
import tify.server.domain.domains.user.domain.NeighborApplication; | ||
import tify.server.domain.domains.user.exception.AlreadyExistNeighborRelationshipException; | ||
import tify.server.domain.domains.user.validator.NeighborValidator; | ||
|
||
@UseCase | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class AcceptanceNeighborApplicationUseCase { | ||
|
||
private final NeighborAdaptor neighborAdaptor; | ||
private final NeighborValidator neighborValidator; | ||
|
||
public void execute(Long neighborApplicationId) { | ||
|
||
// 나 (친구 신청을 받은 사람) | ||
Long currentUserId = SecurityUtils.getCurrentUserId(); | ||
NeighborApplication neighborApplication = | ||
neighborAdaptor.queryNeighborApplication(neighborApplicationId); | ||
|
||
neighborValidator.userIdAndNeighborApplicationValidate(neighborApplication, currentUserId); | ||
|
||
neighborApplication.accept(); | ||
|
||
// 상대방 (친구 신청을 보낸 사람) | ||
Long toUserId = neighborApplication.getFromUserId(); | ||
|
||
// 친구 맺기 (toUserId, fromUserId inversion) | ||
if (neighborAdaptor.existsNeighbor(currentUserId, toUserId)) { | ||
throw AlreadyExistNeighborRelationshipException.EXCEPTION; | ||
} | ||
|
||
List<Neighbor> neighbors = neighborAdaptor.queryAllByFromUserId(currentUserId); | ||
|
||
neighborAdaptor.save( | ||
Neighbor.builder() | ||
.fromUserId(currentUserId) | ||
.toUserId(toUserId) | ||
.isView(true) | ||
.order((long) neighbors.size() + 1L) | ||
.build()); | ||
} | ||
} |
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
29 changes: 29 additions & 0 deletions
29
Api/src/main/java/tify/server/api/user/service/RejectNeighborApplicationUseCase.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,29 @@ | ||
package tify.server.api.user.service; | ||
|
||
|
||
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.domain.NeighborApplication; | ||
import tify.server.domain.domains.user.validator.NeighborValidator; | ||
|
||
@UseCase | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class RejectNeighborApplicationUseCase { | ||
|
||
private final NeighborAdaptor neighborAdaptor; | ||
private final NeighborValidator neighborValidator; | ||
|
||
public void execute(Long neighborApplicationId) { | ||
Long currentUserId = SecurityUtils.getCurrentUserId(); | ||
NeighborApplication neighborApplication = | ||
neighborAdaptor.queryNeighborApplication(neighborApplicationId); | ||
|
||
neighborValidator.userIdAndNeighborApplicationValidate(neighborApplication, currentUserId); | ||
|
||
neighborApplication.reject(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Api/src/main/java/tify/server/api/user/service/RetrieveNeighborApplicationUseCase.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,24 @@ | ||
package tify.server.api.user.service; | ||
|
||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Slice; | ||
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.dto.model.RetrieveNeighborApplicationDTO; | ||
|
||
@UseCase | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class RetrieveNeighborApplicationUseCase { | ||
|
||
private final NeighborAdaptor neighborAdaptor; | ||
|
||
public Slice<RetrieveNeighborApplicationDTO> execute(Pageable pageable) { | ||
Long toUserId = SecurityUtils.getCurrentUserId(); | ||
return neighborAdaptor.searchNeighborApplications(pageable, toUserId); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
Api/src/main/java/tify/server/api/user/service/RetrieveUserListUseCase.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,23 @@ | ||
package tify.server.api.user.service; | ||
|
||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Slice; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import tify.server.core.annotation.UseCase; | ||
import tify.server.domain.common.vo.UserInfoVo; | ||
import tify.server.domain.domains.user.adaptor.UserAdaptor; | ||
import tify.server.domain.domains.user.dto.condition.UserCondition; | ||
|
||
@UseCase | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class RetrieveUserListUseCase { | ||
|
||
private final UserAdaptor userAdaptor; | ||
|
||
public Slice<UserInfoVo> execute(Pageable pageable, UserCondition condition) { | ||
return userAdaptor.searchUsers(pageable, condition).map(UserInfoVo::from); | ||
} | ||
} |
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
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
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
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.