Subversion Repositories SmartDukaan

Rev

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

Rev 29677 Rev 29682
Line 27... Line 27...
27
import org.springframework.http.HttpStatus;
27
import org.springframework.http.HttpStatus;
28
import org.springframework.http.ResponseEntity;
28
import org.springframework.http.ResponseEntity;
29
import org.springframework.stereotype.Controller;
29
import org.springframework.stereotype.Controller;
30
import org.springframework.ui.Model;
30
import org.springframework.ui.Model;
31
import org.springframework.web.bind.annotation.PathVariable;
31
import org.springframework.web.bind.annotation.PathVariable;
-
 
32
import org.springframework.web.bind.annotation.PostMapping;
32
import org.springframework.web.bind.annotation.RequestBody;
33
import org.springframework.web.bind.annotation.RequestBody;
33
import org.springframework.web.bind.annotation.RequestMapping;
34
import org.springframework.web.bind.annotation.RequestMapping;
34
import org.springframework.web.bind.annotation.RequestMethod;
35
import org.springframework.web.bind.annotation.RequestMethod;
35
import org.springframework.web.bind.annotation.RequestParam;
36
import org.springframework.web.bind.annotation.RequestParam;
-
 
37
import org.springframework.web.bind.annotation.RequestPart;
-
 
38
import org.springframework.web.multipart.MultipartFile;
36
 
39
 
37
import com.google.gson.Gson;
40
import com.google.gson.Gson;
38
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
41
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
39
import com.spice.profitmandi.common.model.CustomRetailer;
42
import com.spice.profitmandi.common.model.CustomRetailer;
40
import com.spice.profitmandi.common.model.ProfitMandiConstants;
43
import com.spice.profitmandi.common.model.ProfitMandiConstants;
Line 151... Line 154...
151
 
154
 
152
	@RequestMapping(value = "/offerHistory", method = RequestMethod.GET)
155
	@RequestMapping(value = "/offerHistory", method = RequestMethod.GET)
153
	public String getPaginatedOffers(HttpServletRequest request, @RequestParam YearMonth yearMonth, Model model)
156
	public String getPaginatedOffers(HttpServletRequest request, @RequestParam YearMonth yearMonth, Model model)
154
			throws ProfitMandiBusinessException {
157
			throws ProfitMandiBusinessException {
155
 
158
 
156
		List<CreateOfferRequest> publishedOffers = offerService.getAllOffers(yearMonth);
159
		List<CreateOfferRequest> publishedOffers = offerService.getAllOffers(yearMonth)
-
 
160
				.stream().sorted(Comparator.comparing(CreateOfferRequest::getId).reversed()).collect(Collectors.toList());
157
		model.addAttribute("offers", publishedOffers);
161
		model.addAttribute("offers", publishedOffers);
158
		model.addAttribute("yearMonth", yearMonth);
162
		model.addAttribute("yearMonth", yearMonth);
159
 
163
 
160
		return "offer_history";
164
		return "offer_history";
161
	}
165
	}
Line 240... Line 244...
240
		List<CreateOfferRequest> createOffers = offerService.getPublishedOffers(fofoId, YearMonth.from(LocalDate.now()).minusMonths(yearMonth));
244
		List<CreateOfferRequest> createOffers = offerService.getPublishedOffers(fofoId, YearMonth.from(LocalDate.now()).minusMonths(yearMonth));
241
		
245
		
242
		model.addAttribute("publishedOffers", createOffers);
246
		model.addAttribute("publishedOffers", createOffers);
243
		
247
		
244
		return "published-offers";
248
		return "published-offers";
245
		
249
	}
-
 
250
	
-
 
251
	@PostMapping(value = "/offers/upload")
-
 
252
	public String uploadOffers(HttpServletRequest request, @RequestPart("file") MultipartFile targetFile, Model model)
-
 
253
			throws Exception {
-
 
254
		offerService.createOffers(targetFile.getInputStream());
-
 
255
		model.addAttribute("response", true);
-
 
256
		return "response";
246
	}
257
	}
247
 
258
 
248
	@RequestMapping(value = "/getOfferMargins", method = RequestMethod.GET)
259
	@RequestMapping(value = "/getOfferMargins", method = RequestMethod.GET)
249
	public String getOfferMargins(HttpServletRequest request,
260
	public String getOfferMargins(HttpServletRequest request,
250
			@RequestParam(name = "offerId", defaultValue = "0") int offerId, Model model) throws Exception {
261
			@RequestParam(name = "offerId", defaultValue = "0") int offerId, Model model) throws Exception {