Class DealController
java.lang.Object
com.JesacaLin.GrubGoblin_v13.controllers.DealController
@PreAuthorize("isAuthenticated()")
@RestController
@RequestMapping("/deal")
public class DealController
extends Object
Controller for managing Deal entities.
-
Constructor Summary
ConstructorsConstructorDescriptionDealController
(DealDAO dealDAO) Constructs a new DealController with the given DealDAO. -
Method Summary
Modifier and TypeMethodDescriptioncreateDeal
(Deal deal, Principal principal) Creates a new Deal.int
deleteDeal
(int id) Deletes a Deal by its ID.getDealById
(int id) Retrieves a Deal by its ID.Retrieves full details for all Deals.getFullDealDetailsByDayOfWeek
(String dayOfWeek) Retrieves full details for all Deals that occur on a given day of the week.getFullDealDetailsByKeyword
(String keyword) Retrieves full details for all Deals that match a given keyword.getFullDealDetailsFromDealId
(int deal_id) Retrieves full details for a Deal by its ID.getFullDealDetailsFromPlace
(int place_id) Retrieves full details for all Deals from a given place.Retrieves full details for all top-rated Deals.Retrieves all Deals.updateDeal
(Deal deal, Principal principal) Updates a Deal.
-
Constructor Details
-
DealController
Constructs a new DealController with the given DealDAO.- Parameters:
dealDAO
- the DealDAO to use for deal management
-
-
Method Details
-
listOfDeals
-
getDealById
Retrieves a Deal by its ID.- Parameters:
id
- the ID of the Deal to retrieve- Returns:
- the Deal with the given ID
-
createDeal
-
updateDeal
@PreAuthorize("hasAuthority(\'contributor\') or hasAuthority(\'admin\')") @PutMapping("/{id}") public Deal updateDeal(@RequestBody Deal deal, Principal principal) Updates a Deal.- Parameters:
deal
- the Deal data to updateprincipal
- the authenticated user- Returns:
- the updated Deal if authenticated user is the same as the creator.
-
deleteDeal
@PreAuthorize("hasAuthority(\'admin\')") @DeleteMapping("/{id}") public int deleteDeal(@PathVariable int id) Deletes a Deal by its ID.- Parameters:
id
- the ID of the Deal to delete- Returns:
- the number of rows affected by the delete
-
getFullDealDetails
Retrieves full details for all Deals.- Returns:
- a list of full details for all Deals
-
getFullDealDetailsByKeyword
@GetMapping("/details/keyword/{keyword}") public List<FullDealDetails> getFullDealDetailsByKeyword(@PathVariable String keyword) Retrieves full details for all Deals that match a given keyword.- Parameters:
keyword
- the keyword to match Deals against- Returns:
- a list of full details for all matching Deals
-
getFullDealDetailsByDayOfWeek
@GetMapping("/details/day/{dayOfWeek}") public List<FullDealDetails> getFullDealDetailsByDayOfWeek(@PathVariable String dayOfWeek) Retrieves full details for all Deals that occur on a given day of the week.- Parameters:
dayOfWeek
- the day of the week to match Deals against- Returns:
- a list of full details for all matching Deals
-
getFullDealDetailsTopRated
Retrieves full details for all top-rated Deals.- Returns:
- a list of full details for all top-rated Deals
-
getFullDealDetailsFromPlace
@GetMapping("/details/place/{place_id}") public List<FullDealDetails> getFullDealDetailsFromPlace(@PathVariable int place_id) Retrieves full details for all Deals from a given place.- Parameters:
place_id
- the ID of the place to match Deals against- Returns:
- a list of full details for all matching Deals
-
getFullDealDetailsFromDealId
@GetMapping("/details/deal/{deal_id}") public List<FullDealDetails> getFullDealDetailsFromDealId(@PathVariable int deal_id) Retrieves full details for a Deal by its ID.- Parameters:
deal_id
- the ID of the Deal to retrieve details for- Returns:
- a list of full details for the Deal
-