Rev 21581 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.web.controller;import java.util.List;import javax.servlet.http.HttpServletRequest;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.ModelAttribute;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestParam;import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;import com.spice.profitmandi.common.model.ProfitMandiConstants;import com.spice.profitmandi.dao.entity.CurrentInventorySnapshot;import com.spice.profitmandi.dao.entity.FofoItemId;import com.spice.profitmandi.dao.repository.CurrentInventorySnapshotRepository;import com.spice.profitmandi.web.model.FofoDetails;import com.spice.profitmandi.web.util.CookiesFetcher;import com.spice.profitmandi.web.util.MVCResponseSender;@Controllerpublic class InventoryController {private static final Logger LOGGER = LoggerFactory.getLogger(InventoryController.class);@AutowiredCurrentInventorySnapshotRepository currentInventorySnapshotRepository;@AutowiredMVCResponseSender mvcResponseSender;@AutowiredCookiesFetcher cookiesFetcher;@RequestMapping(value = "/checkCurrentAvailability")public String getCurrentAvailability(HttpServletRequest request, @ModelAttribute Model model) throws Exception{FofoDetails fofoDetails;try {fofoDetails = cookiesFetcher.getCookiesObject(request);} catch (ProfitMandiBusinessException e) {return mvcResponseSender.createResponseString("RTLR_1009", false, "/login");}try{List<CurrentInventorySnapshot> currentInventorySnapshots = currentInventorySnapshotRepository.getByFofoId(fofoDetails.getFofoId());model.addAttribute("currentInventorySnapshots", currentInventorySnapshots);return "dashboard";}catch(ProfitMandiBusinessException profitMandiBusinessException){return mvcResponseSender.createResponseString("INVNTRY_SNPSHT", false, "/dashboard");}}@RequestMapping(value = "/checkItemAvailability")public String getItemAvailability(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.ITEM_ID) int itemId, @ModelAttribute Model model) throws Exception{FofoDetails fofoDetails;try {fofoDetails = cookiesFetcher.getCookiesObject(request);} catch (ProfitMandiBusinessException e) {return mvcResponseSender.createResponseString("RTLR_1009", false, "/login");}try{FofoItemId fofoItemId = new FofoItemId();fofoItemId.setFofoId(fofoDetails.getFofoId());fofoItemId.setItemId(itemId);CurrentInventorySnapshot currentInventorySnapshot = currentInventorySnapshotRepository.selectByFofoItemId(fofoItemId);model.addAttribute("currentInventorySnapshots", currentInventorySnapshot);return "dashboard";}catch(ProfitMandiBusinessException profitMandiBusinessException){return mvcResponseSender.createResponseString("INVNTRY_SNPSHT", false, "/dashboard");}}}