-
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.
feat(subscriber): cancel auction service
- Loading branch information
1 parent
3a6b676
commit 102dbe0
Showing
2 changed files
with
34 additions
and
1 deletion.
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
31 changes: 31 additions & 0 deletions
31
chainhook-subscriber/src/modules/auctionhistory/services/cancel.auction.service.ts
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,31 @@ | ||
import { Inject, Injectable } from "@nestjs/common"; | ||
import { StartAuction } from "src/models"; | ||
import { AuctionEntityRepository } from "src/modules/auctions/repositories/auction.repository"; | ||
import { AuctionEntityRepositoryToken } from "src/modules/auctions/providers/auction.repository.provider"; | ||
import { Transactional } from "src/common/transaction/transaction"; | ||
import { runOnTransactionComplete, runOnTransactionRollback } from "src/common/transaction/hook"; | ||
import { AuctionEntity } from "src/modules/auctions/entities/auction.entity"; | ||
|
||
@Injectable() | ||
export class CancelAuctionService { | ||
constructor( | ||
@Inject(AuctionEntityRepositoryToken) | ||
private auctionRepository: AuctionEntityRepository | ||
) {} | ||
|
||
@Transactional() | ||
public async startAuction(startAuctionModel: StartAuction): Promise<void> { | ||
|
||
runOnTransactionRollback((cb) => | ||
console.log('Rollback error ' + cb.message), | ||
); | ||
|
||
runOnTransactionComplete((_) => console.log('Transaction Complete')); | ||
|
||
const auction = await this.auctionRepository.findOneOrFail({auctionId: Number(startAuctionModel["auction-id"].value)}) | ||
|
||
auction.status = startAuctionModel["auction-status"].value; | ||
|
||
await this.auctionRepository.save(auction); | ||
} | ||
} |