Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pl.bpo.archiwumallegro.controller;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.data.domain.Pageable;
- import org.springframework.http.MediaType;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import pl.bpo.archiwumallegro.model.Auction;
- import pl.bpo.archiwumallegro.model.index.auctions.AuctionIndexSearchParams;
- import pl.bpo.archiwumallegro.services.AuctionContentReaderService;
- import pl.bpo.archiwumallegro.services.AuctionService;
- import java.util.List;
- import java.util.Map;
- @RestController
- public class AuctionQueryController {
- private AuctionService auctionService;
- private AuctionContentReaderService auctionContentReaderService;
- @Autowired
- public AuctionQueryController(AuctionService auctionService, AuctionContentReaderService auctionContentReaderService) {
- this.auctionService = auctionService;
- this.auctionContentReaderService = auctionContentReaderService;
- }
- @RequestMapping(value = "/auctions/getById/{auctionId}", produces = MediaType.APPLICATION_JSON_VALUE)
- private Auction getById(@PathVariable("auctionId") Long auctionId) {
- return auctionService.findAuctionById(auctionId);
- }
- @RequestMapping(value = "/auctions/getByUserId/{userId}", produces = MediaType.APPLICATION_JSON_VALUE)
- private List<Auction> getByUserId(@PathVariable("userId") Long userId) {
- return auctionService.findByUserId(userId);
- }
- @RequestMapping(value = "/auctions/content/{auctionId}", produces = MediaType.APPLICATION_JSON_VALUE)
- private String getContent(@PathVariable("auctionId") Long auctionId) {
- return auctionContentReaderService.findContent(auctionId);
- }
- @RequestMapping(value = "/auctions/search", produces = MediaType.APPLICATION_JSON_VALUE)
- private Map search(
- @RequestParam(value = "categoryId", required = false) Long categoryId,
- @RequestParam(value = "treeCategoryId", required = false) Long treeCategoryId,
- @RequestParam(value = "currency", required = false) String currency,
- @RequestParam(value = "priceFrom", required = false) Long priceFrom,
- @RequestParam(value = "priceTo", required = false) Long priceTo,
- @RequestParam(value = "startDateFrom", required = false) Long startDateFrom,
- @RequestParam(value = "startDateTo", required = false) Long startDateTo,
- @RequestParam(value = "endDateFrom", required = false) Long endDateFrom,
- @RequestParam(value = "endDateTo", required = false) Long endDateTo,
- @RequestParam(value = "title", required = false) String title,
- @RequestParam(value = "uid", required = false) Long uid,
- @RequestParam(value = "uids", required = false) String uids,
- @RequestParam(value = "categories", required = false) String categories,
- @RequestParam(value = "item", required = false) String itemId,
- @RequestParam(value = "orderBy", required = false) String orderBy,
- @RequestParam(value = "orderDir", required = false) String orderDir,
- @RequestParam(value = "loc", required = false) String loc,
- @RequestParam(value = "pow", required = false) String pow,
- @RequestParam(value = "woj", required = false) String woj,
- @RequestParam(value = "catdec", required = false) Long catdec,
- Pageable pageable) {
- final AuctionIndexSearchParams searchParams = AuctionIndexSearchParams.builder()
- .itemId(itemId)
- .categoryId(categoryId)
- .treeCategoryId(treeCategoryId)
- .currency(currency)
- .priceFrom(priceFrom)
- .priceTo(priceTo)
- .startDateFrom(startDateFrom)
- .startDateTo(startDateTo)
- .endDateFrom(endDateFrom)
- .endDateTo(endDateTo)
- .title(title)
- .loc(loc)
- .pow(pow)
- .woj(woj)
- .uid(uid)
- .catdec(catdec)
- .uids(uids)
- .categories(categories)
- .orderBy(orderBy)
- .orderDir(orderDir)
- .build();
- return auctionService.searchByIndexParams(searchParams, pageable);
- }
- @RequestMapping(value = "/auctions/findAll", produces = MediaType.APPLICATION_JSON_VALUE)
- private Map findAll(
- @RequestParam(value = "categoryId", required = false) Long categoryId,
- @RequestParam(value = "treeCategoryId", required = false) Long treeCategoryId,
- @RequestParam(value = "currency", required = false) String currency,
- @RequestParam(value = "priceFrom", required = false) Long priceFrom,
- @RequestParam(value = "priceTo", required = false) Long priceTo,
- @RequestParam(value = "startDateFrom", required = false) Long startDateFrom,
- @RequestParam(value = "startDateTo", required = false) Long startDateTo,
- @RequestParam(value = "endDateFrom", required = false) Long endDateFrom,
- @RequestParam(value = "endDateTo", required = false) Long endDateTo,
- @RequestParam(value = "title", required = false) String title,
- @RequestParam(value = "uid", required = false) Long uid,
- @RequestParam(value = "uids", required = false) String uids,
- @RequestParam(value = "categories", required = false) String categories,
- @RequestParam(value = "item", required = false) String itemId,
- @RequestParam(value = "orderBy", required = false) String orderBy,
- @RequestParam(value = "orderDir", required = false) String orderDir) {
- final AuctionIndexSearchParams searchParams = AuctionIndexSearchParams.builder()
- .categoryId(categoryId)
- .itemId(itemId)
- .treeCategoryId(treeCategoryId)
- .currency(currency)
- .priceFrom(priceFrom)
- .priceTo(priceTo)
- .startDateFrom(startDateFrom)
- .startDateTo(startDateTo)
- .endDateFrom(endDateFrom)
- .endDateTo(endDateTo)
- .title(title)
- .uid(uid)
- .uids(uids)
- .orderBy(orderBy)
- .orderDir(orderDir)
- .categories(categories)
- .build();
- return auctionService.findAllByIndexParams(searchParams, null);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement