Subversion Repositories SmartDukaan

Rev

Rev 26705 | Rev 26763 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 26705 Rev 26719
Line 635... Line 635...
635
 
635
 
636
	}
636
	}
637
 
637
 
638
	@RequestMapping(value = "/getOffers", method = RequestMethod.GET)
638
	@RequestMapping(value = "/getOffers", method = RequestMethod.GET)
639
	public String createOffer(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
639
	public String createOffer(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
640
			@RequestParam(name = "limit", defaultValue = "50") int limit, Model model) throws Exception {
640
			@RequestParam(name = "limit", defaultValue = "10") int limit,
-
 
641
			@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
-
 
642
			throws Exception {
641
 
643
 
-
 
644
		List<Offer> offers = null;
-
 
645
		long size = 0;
-
 
646
 
642
		List<Offer> offers = offerRepository.selectAll(offset, limit);
647
		offers = offerRepository.selectAll(offset, limit);
-
 
648
		size = offerRepository.selectAllCount();
643
 
649
 
644
		model.addAttribute("offers", offers);
650
		model.addAttribute("offers", offers);
-
 
651
		model.addAttribute("start", offset + 1);
-
 
652
		model.addAttribute("size", size);
-
 
653
		model.addAttribute("searchTerm", searchTerm);
-
 
654
 
-
 
655
		if (offers.size() < limit) {
-
 
656
			model.addAttribute("end", offset + offers.size());
-
 
657
		} else {
-
 
658
			model.addAttribute("end", offset + limit);
-
 
659
		}
645
 
660
 
646
		return "offer_history";
661
		return "offer_history";
647
 
662
 
648
	}
663
	}
649
 
664
 
-
 
665
	@RequestMapping(value = "/getPaginatedOffers", method = RequestMethod.GET)
-
 
666
	public String getPaginatedOffers(HttpServletRequest request,
-
 
667
			@RequestParam(name = "offset", defaultValue = "0") int offset,
-
 
668
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
-
 
669
			throws ProfitMandiBusinessException {
-
 
670
 
-
 
671
		List<Offer> offers = null;
-
 
672
		offers = offerRepository.selectAll(offset, limit);
-
 
673
		model.addAttribute("offers", offers);
-
 
674
 
-
 
675
		return "offer_history_paginated";
-
 
676
	}
-
 
677
 
-
 
678
	@RequestMapping(value = "/searchOffer")
-
 
679
	public String getOfferById(HttpServletRequest request,
-
 
680
			@RequestParam(name = "offset", defaultValue = "0") int offset,
-
 
681
			@RequestParam(name = "limit", defaultValue = "10") int limit,
-
 
682
			@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
-
 
683
			throws ProfitMandiBusinessException {
-
 
684
		List<Offer> offers = null;
-
 
685
		long size = 0;
-
 
686
		if (!(searchTerm.equals(""))) {
-
 
687
			offers = offerRepository.selectBySearchTerm(searchTerm, offset, limit);
-
 
688
			if (!(offers.size() == 0)) {
-
 
689
				size = offerRepository.selectAllCount();
-
 
690
				LOGGER.info("offers" + offers);
-
 
691
				model.addAttribute("offers", offers);
-
 
692
				model.addAttribute("start", offset + 1);
-
 
693
				model.addAttribute("size", size);
-
 
694
				model.addAttribute("searchTerm", searchTerm);
-
 
695
				if (offers.size() < limit) {
-
 
696
					model.addAttribute("end", offset + offers.size());
-
 
697
				} else {
-
 
698
					model.addAttribute("end", offset + limit);
-
 
699
				}
-
 
700
			} else {
-
 
701
				throw new ProfitMandiBusinessException("OfferId", searchTerm, "offerId Not Found");
-
 
702
			}
-
 
703
		} else {
-
 
704
 
-
 
705
			offers = offerRepository.selectAll(offset, limit);
-
 
706
			size = schemeRepository.selectAllCount();
-
 
707
 
-
 
708
			model.addAttribute("offers", offers);
-
 
709
			model.addAttribute("start", offset + 1);
-
 
710
			model.addAttribute("size", size);
-
 
711
			model.addAttribute("searchTerm", searchTerm);
-
 
712
 
-
 
713
			if (offers.size() < limit) {
-
 
714
				model.addAttribute("end", offset + offers.size());
-
 
715
			} else {
-
 
716
				model.addAttribute("end", offset + limit);
-
 
717
			}
-
 
718
		}
-
 
719
		return "offer_history";
-
 
720
	}
-
 
721
 
650
	@RequestMapping(value = "/updateOfferStatus", method = RequestMethod.POST)
722
	@RequestMapping(value = "/updateOfferStatus", method = RequestMethod.POST)
651
	public String updateOfferStatus(HttpServletRequest request, @RequestParam int id, Model model) throws Exception {
723
	public String updateOfferStatus(HttpServletRequest request, @RequestParam int id, Model model) throws Exception {
652
 
724
 
653
		Offer offer = offerRepository.selectById(id);
725
		Offer offer = offerRepository.selectById(id);
654
		LOGGER.info("status" + offer.getStatus());
726
		LOGGER.info("status" + offer.getStatus());
Line 753... Line 825...
753
 
825
 
754
		return "offer_margin_detail";
826
		return "offer_margin_detail";
755
 
827
 
756
	}
828
	}
757
 
829
 
-
 
830
	@RequestMapping(value = "/offerById", method = RequestMethod.GET)
-
 
831
	public String offerById(HttpServletRequest request, int offerId, Model model) throws ProfitMandiBusinessException {
-
 
832
		Offer offer = offerRepository.selectById(offerId);
-
 
833
 
-
 
834
		model.addAttribute("offer", offer);
-
 
835
 
-
 
836
		return "offer-edit";
-
 
837
 
-
 
838
	}
-
 
839
 
-
 
840
	@RequestMapping(value = "/extendByOfferId", method = RequestMethod.POST)
-
 
841
	public String extendByOfferId(HttpServletRequest request,
-
 
842
 
-
 
843
			int offerId, @RequestBody LocalDateTime extendDatetime, Model model) throws Exception {
-
 
844
 
-
 
845
		LOGGER.info("ExtendDatetime" + extendDatetime);
-
 
846
		LOGGER.info("schemeId" + offerId);
-
 
847
		Offer offer = offerRepository.selectById(offerId);
-
 
848
 
-
 
849
		offer.setEndDateTime(extendDatetime);
-
 
850
		offerRepository.persist(offer);
-
 
851
		model.addAttribute("response", mvcResponseSender.createResponseString(true));
-
 
852
 
-
 
853
		return "response";
-
 
854
	}
-
 
855
 
758
}
856
}
759
857