This repository has been archived by the owner on Aug 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
#3 그룹 팔로워 신청 기능 개발 #6
Open
lee-maru
wants to merge
1
commit into
develop
Choose a base branch
from
feature/3
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
.../me/maru/seeTogether/api/v1/group/accout/groupFollower/GroupFollowerCreateController.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,32 @@ | ||
package me.maru.seeTogether.api.v1.group.accout.groupFollower; | ||
|
||
import me.maru.seeTogether.service.group.accout.groupFollower.create.GroupFollowerCreator; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("api/v1") | ||
public class GroupFollowerCreateController { | ||
|
||
private final Logger logger = LoggerFactory.getLogger(GroupFollowerCreateController.class); | ||
|
||
@Autowired | ||
private final GroupFollowerCreator groupFollowerCreator; | ||
|
||
public GroupFollowerCreateController(final GroupFollowerCreator groupFollowerCreator) { | ||
this.groupFollowerCreator = groupFollowerCreator; | ||
} | ||
|
||
@PostMapping(value = "/groupFollower") | ||
public ResponseEntity<GroupFollowerCreateResponse> create(final GroupFollowerCreateRequest groupFollowerCreateRequest){ | ||
logger.info("api/v1/groupFollower request : {}", groupFollowerCreateRequest.toString()); | ||
final var groupFollowerCreateResponse = groupFollowerCreator.create(groupFollowerCreateRequest); | ||
logger.info("api/v1/groupFollower response : {}", groupFollowerCreateResponse.toString()); | ||
return ResponseEntity.status(201).body(groupFollowerCreateResponse); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ava/me/maru/seeTogether/api/v1/group/accout/groupFollower/GroupFollowerCreateRequest.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,12 @@ | ||
package me.maru.seeTogether.api.v1.group.accout.groupFollower; | ||
|
||
import lombok.Getter; | ||
import javax.validation.constraints.NotNull; | ||
|
||
@Getter | ||
public class GroupFollowerCreateRequest { | ||
@NotNull | ||
private Long userId; | ||
@NotNull | ||
private Long ottProductId; | ||
} |
22 changes: 22 additions & 0 deletions
22
...va/me/maru/seeTogether/api/v1/group/accout/groupFollower/GroupFollowerCreateResponse.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,22 @@ | ||
package me.maru.seeTogether.api.v1.group.accout.groupFollower; | ||
|
||
import lombok.Builder; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public class GroupFollowerCreateResponse { | ||
private final String productName; | ||
private final String ottId; | ||
private final String ottPassword; | ||
private final Integer currentParticipantsSize; | ||
private final LocalDateTime createdAt; | ||
|
||
@Builder | ||
public GroupFollowerCreateResponse(final String productName, final String ottId, final String ottPassword, final Integer currentParticipantsSize, final LocalDateTime createdAt) { | ||
this.productName = productName; | ||
this.ottId = ottId; | ||
this.ottPassword = ottPassword; | ||
this.currentParticipantsSize = currentParticipantsSize; | ||
this.createdAt = createdAt; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/java/me/maru/seeTogether/api/v1/payment/create/CardInfoCreateController.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
2 changes: 1 addition & 1 deletion
2
src/main/java/me/maru/seeTogether/api/v1/payment/query/CardInfoQueryController.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
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
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
14 changes: 14 additions & 0 deletions
14
src/main/java/me/maru/seeTogether/repository/group/GroupAccountRepository.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,14 @@ | ||
package me.maru.seeTogether.repository.group; | ||
|
||
import me.maru.seeTogether.domain.group.ProductGroup; | ||
import me.maru.seeTogether.domain.group.account.GroupAccount; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface GroupAccountRepository extends JpaRepository<GroupAccount, Long> { | ||
Optional<GroupAccount> findGroupAccountByProductGroupAndDelete(ProductGroup productGroup, Boolean delete); | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/me/maru/seeTogether/repository/group/ProductGroupRepository.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,13 @@ | ||
package me.maru.seeTogether.repository.group; | ||
|
||
import me.maru.seeTogether.domain.group.ProductGroup; | ||
import me.maru.seeTogether.domain.product.OttProduct; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface ProductGroupRepository extends JpaRepository<ProductGroup, Long> { | ||
Optional<ProductGroup> findTopByOttProductAndCurrentParticipantsSizeBeforeAndDelete(OttProduct ottProduct, Integer currentParticipantsSize, Boolean delete); | ||
} |
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
10 changes: 10 additions & 0 deletions
10
src/main/java/me/maru/seeTogether/repository/product/OttProductRepository.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,10 @@ | ||
package me.maru.seeTogether.repository.product; | ||
|
||
import me.maru.seeTogether.domain.product.OttProduct; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface OttProductRepository extends JpaRepository<OttProduct, Long> { | ||
Optional<OttProduct> findOttProductByOttProductIdAndDelete(Long ottProductId, Boolean delete); | ||
} |
8 changes: 8 additions & 0 deletions
8
...a/me/maru/seeTogether/service/group/accout/groupFollower/create/GroupFollowerCreator.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,8 @@ | ||
package me.maru.seeTogether.service.group.accout.groupFollower.create; | ||
|
||
import me.maru.seeTogether.api.v1.group.accout.groupFollower.GroupFollowerCreateRequest; | ||
import me.maru.seeTogether.api.v1.group.accout.groupFollower.GroupFollowerCreateResponse; | ||
|
||
public interface GroupFollowerCreator { | ||
GroupFollowerCreateResponse create(GroupFollowerCreateRequest groupFollowerCreateRequest); | ||
} |
63 changes: 63 additions & 0 deletions
63
.../maru/seeTogether/service/group/accout/groupFollower/create/GroupFollowerCreatorImpl.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,63 @@ | ||
package me.maru.seeTogether.service.group.accout.groupFollower.create; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. impl 들은 /impl 패키지로 분리해보세요. 구현과 스펙을 구분하기 좋습니다 |
||
|
||
import me.maru.seeTogether.api.v1.group.accout.groupFollower.GroupFollowerCreateRequest; | ||
import me.maru.seeTogether.api.v1.group.accout.groupFollower.GroupFollowerCreateResponse; | ||
import me.maru.seeTogether.domain.group.account.GroupAccount; | ||
import me.maru.seeTogether.repository.group.GroupAccountRepository; | ||
import me.maru.seeTogether.repository.group.ProductGroupRepository; | ||
import me.maru.seeTogether.repository.payment.CardInfoRepository; | ||
import me.maru.seeTogether.repository.product.OttProductRepository; | ||
import me.maru.seeTogether.repository.user.UserRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.security.core.userdetails.UsernameNotFoundException; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.NoSuchElementException; | ||
|
||
@Service | ||
public class GroupFollowerCreatorImpl implements GroupFollowerCreator{ | ||
|
||
private final CardInfoRepository cardInfoRepository; | ||
private final UserRepository userRepository; | ||
private final ProductGroupRepository productGroupRepository; | ||
private final OttProductRepository ottProductRepository; | ||
private final GroupAccountRepository groupAccountRepository; | ||
|
||
@Autowired | ||
public GroupFollowerCreatorImpl(CardInfoRepository cardInfoRepository, UserRepository userRepository, ProductGroupRepository productGroupRepository, OttProductRepository ottProductRepository, GroupAccountRepository groupAccountRepository) { | ||
this.cardInfoRepository = cardInfoRepository; | ||
this.userRepository = userRepository; | ||
this.productGroupRepository = productGroupRepository; | ||
this.ottProductRepository = ottProductRepository; | ||
this.groupAccountRepository = groupAccountRepository; | ||
} | ||
|
||
@Override | ||
public GroupFollowerCreateResponse create(GroupFollowerCreateRequest groupFollowerCreateRequest) { | ||
final var user = userRepository.findById(groupFollowerCreateRequest.getUserId()) | ||
.orElseThrow(() -> new UsernameNotFoundException("서버에 등록된 유저가 아닙니다.")); | ||
|
||
final var cardInfo = cardInfoRepository.findCardInfoByUserAndDeleteYn(user, false).orElseThrow( | ||
() -> new NoSuchElementException("카드가 등록되어있지 않는 유저입니다.")); | ||
|
||
final var ottProduct = ottProductRepository.findOttProductByOttProductIdAndDelete(groupFollowerCreateRequest.getOttProductId(), false) | ||
.orElseThrow(() -> new IllegalArgumentException("해당 OTT 아이디는 등록되어있지 않습니다.")); | ||
final var productGroup = productGroupRepository.findTopByOttProductAndCurrentParticipantsSizeBeforeAndDelete(ottProduct, ottProduct.getTotalParticipantsSize(), false) | ||
.orElseThrow(() -> new NoSuchElementException("제공되는 그룹이 존재하지 않습니다.")); | ||
|
||
// TODO:결제진행 은 PG사를 mocking 하고싶다. | ||
|
||
productGroup.setCurrentParticipantsSize(productGroup.getCurrentParticipantsSize() + 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. get/set 으로 진행하기 보다는 "증가" 를 수행하는 역할을 정의해보는게 좋을 것 같아요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네 알겠습니다. ! |
||
productGroupRepository.save(productGroup); | ||
|
||
final var groupAccount= groupAccountRepository.findGroupAccountByProductGroupAndDelete(productGroup, false) | ||
.orElseThrow(() -> new NoSuchElementException("해당 아이디가 존재하지 않습니다.")); | ||
|
||
// TODO : id 와 password 를 getter 를 이용한 방식은 고쳐야함. | ||
return GroupFollowerCreateResponse.builder() | ||
.productName(ottProduct.getProductName()) | ||
.ottId(groupAccount.getOttId()) | ||
.ottPassword(groupAccount.getOttPassword()) | ||
.build(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...rvice/payment/create/CardInfoCreator.java → .../payment/card/create/CardInfoCreator.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
2 changes: 1 addition & 1 deletion
2
...e/payment/create/CardInfoCreatorImpl.java → ...ment/card/create/CardInfoCreatorImpl.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
2 changes: 1 addition & 1 deletion
2
...service/payment/query/CardInfoReader.java → ...ce/payment/card/query/CardInfoReader.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
4 changes: 1 addition & 3 deletions
4
...ice/payment/query/CardInfoReaderImpl.java → ...ayment/card/query/CardInfoReaderImpl.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
2 changes: 1 addition & 1 deletion
2
...rvice/payment/update/CardInfoUpdater.java → .../payment/card/update/CardInfoUpdater.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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 숫자는 어떤 의미의 숫자인가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current_participants_size 현재 그룹의 몇 명의 인원이 들어가 있는지 나타내는 숫자입니다. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
뭔가 참여자 수를 세어 넣을 수 있다면 좋을 것 같은데 지금 구조로는 어렵군요
참여자와 참여자 수를 각각 다루고 있어서 데이터가 꼬이지 않도록 신경을 써야겠어요 ㅎㅎ