-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #229 from Team-BC-1/refactor/divide-sell-service-b…
…y-command-query SellService -> SellCommandService / SellQueryService 분리
- Loading branch information
Showing
8 changed files
with
69 additions
and
48 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
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
43 changes: 43 additions & 0 deletions
43
src/main/java/bc1/gream/domain/sell/service/command/SellCommandService.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,43 @@ | ||
package bc1.gream.domain.sell.service.command; | ||
|
||
import static bc1.gream.global.common.ResultCase.SELL_BID_PRODUCT_NOT_FOUND; | ||
|
||
import bc1.gream.domain.sell.entity.Sell; | ||
import bc1.gream.domain.sell.repository.SellRepository; | ||
import bc1.gream.domain.user.entity.User; | ||
import bc1.gream.global.exception.GlobalException; | ||
import java.time.LocalDateTime; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class SellCommandService { | ||
|
||
private final SellRepository sellRepository; | ||
|
||
/** | ||
* 판매입찰아이디와 판매입찰자에 대한 판매입찰을 삭제, 삭제된 판매입찰 반환 | ||
* | ||
* @param sellId 판매입찰아이디 | ||
* @param seller 판매입찰자 | ||
* @return 삭제된 판매입찰 | ||
*/ | ||
public Sell deleteSellByIdAndUser(Long sellId, User seller) { | ||
Sell sell = sellRepository.findByIdAndUser(sellId, seller).orElseThrow( | ||
() -> new GlobalException(SELL_BID_PRODUCT_NOT_FOUND) | ||
); | ||
sellRepository.delete(sell); | ||
return sell; | ||
} | ||
|
||
public void delete(Sell sell) { | ||
sellRepository.delete(sell); | ||
} | ||
|
||
public void deleteSellsOfDeadlineBefore(LocalDateTime dateTime) { | ||
sellRepository.deleteSellsOfDeadlineBefore(dateTime); | ||
} | ||
} |
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