-
Notifications
You must be signed in to change notification settings - Fork 1
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 #235 from SKY-HORSE-MAN-POWER/develop
[DEPLOYMENT] 동시성 문제 해결 중에 있습니다.
- Loading branch information
Showing
5 changed files
with
47 additions
and
3 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
3 changes: 2 additions & 1 deletion
3
src/main/java/com/skyhorsemanpower/auction/repository/AuctionCloseStateRepository.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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
package com.skyhorsemanpower.auction.repository; | ||
|
||
import com.skyhorsemanpower.auction.domain.AuctionCloseState; | ||
import com.skyhorsemanpower.auction.repository.mongotemplate.CustomAuctionCloseStateRepository; | ||
import org.springframework.data.mongodb.repository.MongoRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface AuctionCloseStateRepository extends MongoRepository<AuctionCloseState, String> { | ||
public interface AuctionCloseStateRepository extends MongoRepository<AuctionCloseState, String>, CustomAuctionCloseStateRepository { | ||
Optional<AuctionCloseState> findByAuctionUuid(String auctionUuid); | ||
} |
5 changes: 5 additions & 0 deletions
5
.../skyhorsemanpower/auction/repository/mongotemplate/CustomAuctionCloseStateRepository.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,5 @@ | ||
package com.skyhorsemanpower.auction.repository.mongotemplate; | ||
|
||
public interface CustomAuctionCloseStateRepository { | ||
boolean setAuctionClosedInNotExists(String auctionUuid); | ||
} |
26 changes: 26 additions & 0 deletions
26
...manpower/auction/repository/mongotemplate/impl/CustomAuctionCloseStateRepositoryImpl.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,26 @@ | ||
package com.skyhorsemanpower.auction.repository.mongotemplate.impl; | ||
|
||
import com.skyhorsemanpower.auction.domain.AuctionCloseState; | ||
import com.skyhorsemanpower.auction.repository.mongotemplate.CustomAuctionCloseStateRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.mongodb.core.MongoTemplate; | ||
import org.springframework.data.mongodb.core.query.Criteria; | ||
import org.springframework.data.mongodb.core.query.Query; | ||
import org.springframework.data.mongodb.core.query.Update; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class CustomAuctionCloseStateRepositoryImpl implements CustomAuctionCloseStateRepository { | ||
|
||
private final MongoTemplate mongoTemplate; | ||
|
||
@Override | ||
public boolean setAuctionClosedInNotExists(String auctionUuid) { | ||
Query query = new Query(Criteria.where("auctionUuid").is(auctionUuid) | ||
.and("auctionCloseState").is(false)); | ||
Update update = new Update().set("auctionCloseState", true); | ||
AuctionCloseState updatedDocument = mongoTemplate.findAndModify(query, update, AuctionCloseState.class); | ||
return updatedDocument != null; | ||
} | ||
} |