Subversion Repositories SmartDukaan

Rev

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

Rev 24052 Rev 24106
Line 30... Line 30...
30
import org.springframework.web.bind.annotation.RequestParam;
30
import org.springframework.web.bind.annotation.RequestParam;
31
 
31
 
32
import com.google.gson.Gson;
32
import com.google.gson.Gson;
33
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
33
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
34
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
34
import com.spice.profitmandi.common.model.CustomCurrentInventorySnapshot;
-
 
35
import com.spice.profitmandi.common.model.CustomRetailer;
35
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
36
import com.spice.profitmandi.common.model.InventoryItemAgingModel;
-
 
37
import com.spice.profitmandi.common.model.ItemFeatureDataModel;
-
 
38
import com.spice.profitmandi.common.model.NotificationDataModel;
36
import com.spice.profitmandi.common.model.ProfitMandiConstants;
39
import com.spice.profitmandi.common.model.ProfitMandiConstants;
37
import com.spice.profitmandi.common.util.ExcelUtils;
40
import com.spice.profitmandi.common.util.ExcelUtils;
38
import com.spice.profitmandi.common.util.Utils;
41
import com.spice.profitmandi.common.util.Utils;
-
 
42
import com.spice.profitmandi.dao.entity.catalog.TagRanking;
-
 
43
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
-
 
44
import com.spice.profitmandi.dao.entity.transaction.AddWalletRequest;
-
 
45
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
-
 
46
import com.spice.profitmandi.dao.repository.catalog.TagRankingRepository;
39
import com.spice.profitmandi.service.inventory.InventoryService;
47
import com.spice.profitmandi.service.inventory.InventoryService;
40
import com.spice.profitmandi.web.model.LoginDetails;
48
import com.spice.profitmandi.web.model.LoginDetails;
41
import com.spice.profitmandi.web.util.CookiesProcessor;
49
import com.spice.profitmandi.web.util.CookiesProcessor;
-
 
50
import com.spice.profitmandi.web.util.MVCResponseSender;
42
 
51
 
43
@Controller
52
@Controller
44
@Transactional(rollbackFor=Throwable.class)
53
@Transactional(rollbackFor=Throwable.class)
45
public class InventoryController {
54
public class InventoryController {
46
 
55
 
Line 50... Line 59...
50
	private CookiesProcessor cookiesProcessor;
59
	private CookiesProcessor cookiesProcessor;
51
	
60
	
52
	@Autowired
61
	@Autowired
53
	@Qualifier("fofoInventoryService")
62
	@Qualifier("fofoInventoryService")
54
	private InventoryService inventoryService;
63
	private InventoryService inventoryService;
-
 
64
	
-
 
65
	@Autowired
-
 
66
	private TagRankingRepository tagRankingRepository;
55
 
67
	
-
 
68
	@Autowired
-
 
69
	private MVCResponseSender mvcResponseSender;
-
 
70
	
56
	@Value("${saholic.api.host}")
71
	@Value("${saholic.api.host}")
57
	private String host;
72
	private String host;
58
 
73
 
59
	@Value("${saholic.api.port}")
74
	@Value("${saholic.api.port}")
60
	private int port;
75
	private int port;
Line 261... Line 276...
261
		final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
276
		final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
262
		return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
277
		return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
263
 
278
 
264
		// return responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
279
		// return responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
265
	}
280
	}
-
 
281
	
-
 
282
	@RequestMapping(value = "/featurePanel", method = RequestMethod.GET)
-
 
283
	public String FeaturePanel(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
-
 
284
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
-
 
285
 
-
 
286
		
-
 
287
		List<TagRanking> tagRanking = null;
-
 
288
 
-
 
289
		long size = 0;
-
 
290
		tagRanking =tagRankingRepository.selectAllTagRanking(offset, limit);
-
 
291
		size =tagRankingRepository.selectAllCount();
-
 
292
		LOGGER.info("tagRanking" + tagRanking);
-
 
293
		if (!tagRanking.isEmpty()) {
-
 
294
			
-
 
295
			model.addAttribute("tagRanking", tagRanking);
-
 
296
			model.addAttribute("start", offset + 1);
-
 
297
			model.addAttribute("size", size);
-
 
298
			model.addAttribute("url", "/getPaginatedfeature");
-
 
299
 
-
 
300
			if (tagRanking.size() < limit) {
-
 
301
				model.addAttribute("end", offset + tagRanking.size());
-
 
302
			} else {
-
 
303
				model.addAttribute("end", offset + limit);
-
 
304
			}
-
 
305
		} else {
-
 
306
			model.addAttribute("tagRanking", tagRanking);
-
 
307
			model.addAttribute("size", size);
-
 
308
		}
-
 
309
 
-
 
310
		return "feature";
-
 
311
 
-
 
312
	}
-
 
313
	
-
 
314
	@RequestMapping(value = "/getPaginatedfeature", method = RequestMethod.GET)
-
 
315
	public String getPaginatedFeaturePanel(HttpServletRequest request,
-
 
316
			@RequestParam(name = "offset", defaultValue = "0") int offset,
-
 
317
			@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
-
 
318
			throws ProfitMandiBusinessException {
-
 
319
		LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
-
 
320
		List<TagRanking> tagRanking = null;
-
 
321
 
-
 
322
		long size = 0;
-
 
323
		tagRanking =tagRankingRepository.selectAllTagRanking(offset, limit);
-
 
324
		if (!tagRanking.isEmpty()) {
-
 
325
					
-
 
326
			model.addAttribute("tagRanking", tagRanking);
-
 
327
			model.addAttribute("start", offset + 1);
-
 
328
			model.addAttribute("size", size);
-
 
329
			model.addAttribute("url", "/getPaginatedfeature");
-
 
330
 
-
 
331
		} else {
-
 
332
			model.addAttribute("tagRanking", tagRanking);
-
 
333
		}
-
 
334
		return "feature-paginated";
-
 
335
	}
-
 
336
	
-
 
337
	@RequestMapping(value = "/itemfeature", method = RequestMethod.POST)
-
 
338
	public String Itemfeature(HttpServletRequest request,
-
 
339
			@RequestBody  ItemFeatureDataModel itemFeatureDatatModel, Model model) throws Exception {
-
 
340
 
-
 
341
		TagRanking tagRanking = new TagRanking();
-
 
342
		tagRanking.setRankPoints(itemFeatureDatatModel.getRankPoints());
-
 
343
		tagRanking.setCatalogItemId(itemFeatureDatatModel.getCatalogItemId());
-
 
344
		tagRanking.setFeature(itemFeatureDatatModel.getFeature());
-
 
345
		
-
 
346
		LOGGER.info("tagRanking"+ tagRanking);
-
 
347
        tagRankingRepository.persist(tagRanking);
-
 
348
		model.addAttribute("response", mvcResponseSender.createResponseString(true));
-
 
349
		return "response";
-
 
350
	}
266
 
351
 
267
}
352
}