bounswe / bounswe2022group7

8 stars 3 forks source link

Auction / Bid Endpoints #574

Closed askabderon closed 1 year ago

askabderon commented 1 year ago

Auction and Bid Endpoints for Art Item is implemented in this PR.

Auction Endpoint:

No additional body required for this endpoint.

This sets the art item with the given id on sale if it had not been setted already. If the given art item is already on sale, then removes from the sale. This is indicated with the onAuction field of Art Item. It is a boolean field; true means on sale and false means not on sale.

This requires the art item belonging to the user with the token.

This requires a body that indicates the amount of bid:

{
    "bidAmount": 30
}

First of all, we check whether the corresponding art item is on sale. If it is not, then throw error.

Then, it is checked whether the user had given a bid before, if so then update the previous bid amount. If not then creates a new Bid entity with the fields of bidAmount (Double), biddedArtItem (Art Item), and bidder (Registered User).

I implemented a new DTO class for Bid in order to not return Art Item and return the RegisteredUserDTO as bidder.

askabderon commented 1 year ago

By latest commit, I add a new error if an artist try to bid their own art item.