Skip to content

Commit 761c2c3

Browse files
authored
Merge pull request #105 from NamVu5404/develop
Develop
2 parents 1c65a71 + 26db1f1 commit 761c2c3

6 files changed

Lines changed: 28 additions & 3 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ Spring Boot 3 / Java 21 — Port 8080
9696

9797
```
9898
POST /api/v2/auctions/{id}/bids
99-
→ FraudDetectionService (5 pre-checks)
10099
→ RedisLuaService.atomicBid (compare-and-swap, single Lua operation)
101100
├── deposit check: SISMEMBER auction:{id}:depositors bidderId (O(1), no extra round trip)
102101
└── price validation + anti-snipe extension

backend/src/main/java/com/namvu/realtimeauctionsystem/modules/auction/controller/AuctionControllerV1.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ public ApiResponse<PageResponse<AuctionResponse>> getAuctionsByStatus(
4747
return ApiResponse.ok(auctionService.filterAuctionForUser(q, finalStatus, pageable));
4848
}
4949

50+
@GetMapping("/seller/{sellerId}")
51+
public ApiResponse<PageResponse<AuctionResponse>> getAuctionsBySeller(
52+
@PathVariable Long sellerId,
53+
@RequestParam(value = "page", defaultValue = "1") int page,
54+
@RequestParam(value = "size", defaultValue = "20") int size
55+
) {
56+
Pageable pageable = PageRequest.of(page - 1, size);
57+
return ApiResponse.ok(auctionService.getPublicAuctionsBySeller(sellerId, pageable));
58+
}
59+
5060
@GetMapping("/{id}")
5161
public ApiResponse<AuctionResponse> getAuctionDetail(
5262
@PathVariable Long id,

backend/src/main/java/com/namvu/realtimeauctionsystem/modules/auction/repository/AuctionRepository.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ Page<Auction> filterAuctions(
7474
Pageable pageable
7575
);
7676

77+
@Query("SELECT a FROM Auction a WHERE " +
78+
"a.seller.id = :sellerId AND " +
79+
"a.privateMode = false AND " +
80+
"a.status IN ('LIVE', 'SCHEDULED', 'ENDED', 'ENDED_NO_SALE') " +
81+
"ORDER BY a.createdAt DESC")
82+
Page<Auction> findPublicAuctionsBySeller(@Param("sellerId") Long sellerId, Pageable pageable);
83+
7784
@Lock(LockModeType.PESSIMISTIC_WRITE)
7885
@Query("SELECT a FROM Auction a WHERE a.id = :id")
7986
Optional<Auction> findByIdWithLock(Long id);

backend/src/main/java/com/namvu/realtimeauctionsystem/modules/auction/service/AuctionService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
public interface AuctionService {
1717
PageResponse<AuctionResponse> filterAuctionForUser(String q, AuctionStatus status, Pageable pageable);
1818

19+
PageResponse<AuctionResponse> getPublicAuctionsBySeller(Long sellerId, Pageable pageable);
20+
1921
AuctionResponse getAuctionDetail(Long id, String token);
2022

2123
AuctionResponse saveDraft(CreateAuctionRequest request);

backend/src/main/java/com/namvu/realtimeauctionsystem/modules/auction/service/impl/AuctionServiceImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ public PageResponse<AuctionResponse> filterAuctionForUser(String q, AuctionStatu
9393
return getResponse(pageable, auctionPage);
9494
}
9595

96+
@Override
97+
@Transactional(readOnly = true)
98+
public PageResponse<AuctionResponse> getPublicAuctionsBySeller(Long sellerId, Pageable pageable) {
99+
Page<Auction> auctionPage = auctionRepository.findPublicAuctionsBySeller(sellerId, pageable);
100+
return getResponse(pageable, auctionPage);
101+
}
102+
96103
@Override
97104
@Transactional(readOnly = true)
98105
public AuctionResponse getAuctionDetail(Long id, String token) {

frontend/src/api/auctionApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ export const auctionApi = {
6464
): Promise<PaginatedAuctions> => {
6565
try {
6666
const response = await axiosClient.get<ApiResponse<PaginatedAuctions>>(
67-
"/auctions",
68-
{ params: { sellerId, page, size } },
67+
`/auctions/seller/${sellerId}`,
68+
{ params: { page, size } },
6969
);
7070
return response.data.result!;
7171
} catch (error) {

0 commit comments

Comments
 (0)