列表中的"默认"、"人气"、"价格"实现的相关知识

list.html

<div class="btn-group btn-group-sm btn-sort col-sm-6" role="group" >
<span th:if="${#strings.isEmpty(goodsForm.commodityName)}"><!-- 登录上 -->
 <a th:href="@{initGoods(commodityTypeId=${goodsForm.commodityTypeId})}" th:class="${orderTypeId}==1?'btn btn-default btn-danger':'btn btn-default'">&nbsp;默&nbsp;认&nbsp;</a>
	<a th:href="@{initGoodsByPopularDesc(commodityTypeId=${goodsForm.commodityTypeId})}" th:class="${orderTypeId}==3?'btn btn-default btn-danger':'btn btn-default'" th:if="${orderTypeId}!=2">&nbsp;人&nbsp;气<i></i>&nbsp;</a>
	<a th:href="@{initGoodsByPopular(commodityTypeId=${goodsForm.commodityTypeId})}" th:class="${orderTypeId}==2?'btn btn-default btn-danger':'btn btn-default'" th:if="${orderTypeId}==2">&nbsp;人&nbsp;气<i class="up"></i>&nbsp;</a>
	 <a th:href="@{initGoodsByPriceDesc(commodityTypeId=${goodsForm.commodityTypeId})}" th:class="${orderTypeId}==5?'btn btn-default btn-danger':'btn btn-default'" th:if="${orderTypeId}!=4">&nbsp;价&nbsp;格<i></i>&nbsp;</a>
	<a th:href="@{initGoodsByPrice(commodityTypeId=${goodsForm.commodityTypeId})}" th:class="${orderTypeId}==4?'btn btn-default btn-danger':'btn btn-default'" th:if="${orderTypeId}==4">&nbsp;价&nbsp;格<i class="up"></i>&nbsp;</a>
	  </span>
	<span th:if="${not #strings.isEmpty(goodsForm.commodityName)}"><!-- 不登录 -->
	 <a th:href="@{selectGoods1(commodityName=${goodsForm.commodityName})}" th:class="${orderTypeId}==1?'btn btn-default btn-danger':'btn btn-default'">&nbsp;默&nbsp;认&nbsp;</a>
	  <a th:href="@{selectGoodsByPopularDesc(commodityName=${goodsForm.commodityName})}" th:class="${orderTypeId}==3?'btn btn-default btn-danger':'btn btn-default'" th:if="${orderTypeId}!=2">&nbsp;人&nbsp;气<i></i>&nbsp;</a>
	 <a th:href="@{selectGoodsByPopular(commodityName=${goodsForm.commodityName})}" th:class="${orderTypeId}==2?'btn btn-default btn-danger':'btn btn-default'" th:if="${orderTypeId}==2">&nbsp;人&nbsp;气<i class="up"></i>&nbsp;</a>
	 <a th:href="@{selectGoodsByPriceDesc(commodityName=${goodsForm.commodityName})}" th:class="${orderTypeId}==5?'btn btn-default btn-danger':'btn btn-default'" th:if="${orderTypeId}!=4">&nbsp;价&nbsp;格<i></i>&nbsp;</a>
	<a th:href="@{selectGoodsByPrice(commodityName=${goodsForm.commodityName})}" th:class="${orderTypeId}==4?'btn btn-default btn-danger':'btn btn-default'" th:if="${orderTypeId}==4">&nbsp;价&nbsp;格<i class="up"></i>&nbsp;</a>
			  </span>
			</div>

GoodsController.java

 @RequestMapping(value = "initGoods", method = RequestMethod.GET)
    public String initGoods(Model model, HttpSession session, GoodsForm goodsForm, Device device) throws UnsupportedEncodingException {
    	log.info("商品列表初始化");
    	List<GoodsForm> commodityType = goodsService.getType();
    	model.addAttribute("commodityType", goodsService.getType());
    	if(goodsForm.getCommodityTypeId()==null)
    	{
			goodsForm.setCommodityTypeId(commodityType.get(0).getCommodityTypeId());
			model.addAttribute("list", goodsService.getTypeList(goodsForm));
	    	model.addAttribute("goodsForm", goodsForm);
    	}
    	else
    		{model.addAttribute("goodsForm", goodsForm);
    		model.addAttribute("list", goodsService.getTypeList(goodsForm));
    		}
    	UVO uvo = (UVO)session.getAttribute("UVO");
    	if (uvo == null) {
    		uvo = new UVO();
    		session.setAttribute("UVO", uvo);
    	}
    	model.addAttribute("orderTypeId", 1);
    	CartForm cartForm = new CartForm();
    	cartForm.setGuestId(uvo.getGuestId());
    	model.addAttribute("cartList", cartService.searchCartList(cartForm));
    	if(device.isNormal()) {
    		return "shop/list";
    	} else {
    		return "mobile/list";
    	}
    }
    @RequestMapping(value = "initGoodsByPopularDesc", method = RequestMethod.GET)
    public String initGoodsByPopularDesc(Model model, HttpSession session, GoodsForm goodsForm, Device device) {
    	log.info("以人气为条件商品列表初始化");
    	List<GoodsForm> commodityType = goodsService.getType();
    	model.addAttribute("commodityType", goodsService.getType());
    	if(goodsForm.getCommodityTypeId()==null)
    	{
			goodsForm.setCommodityTypeId(commodityType.get(0).getCommodityTypeId());
			model.addAttribute("list", goodsService.getTypeList(goodsForm));
	    	model.addAttribute("goodsForm", goodsForm);
    	}
    	else
    		{model.addAttribute("goodsForm", goodsForm);
    		model.addAttribute("list", goodsService.getTypeList(goodsForm));
    		}
    	UVO uvo = (UVO)session.getAttribute("UVO");
    	if (uvo == null) {
    		uvo = new UVO();
    		session.setAttribute("UVO", uvo);
    	}
    	model.addAttribute("list", goodsService.searchGoodsListByPopularDesc(goodsForm));
    	model.addAttribute("orderTypeId", 2);
    	CartForm cartForm = new CartForm();
    	cartForm.setGuestId(uvo.getGuestId());
    	model.addAttribute("cartList", cartService.searchCartList(cartForm));
    	if(device.isNormal()) {
    		return "shop/list";
    	} else {
    		return "mobile/list";
    	}
    }
    @RequestMapping(value = "initGoodsByPopular", method = RequestMethod.GET)
    public String initGoodsByPopular(Model model, HttpSession session, GoodsForm goodsForm, Device device) {
    	log.info("以人气为条件商品列表初始化");
    	List<GoodsForm> commodityType = goodsService.getType();
    	model.addAttribute("commodityType", goodsService.getType());
    	if(goodsForm.getCommodityTypeId()==null)
    	{
			goodsForm.setCommodityTypeId(commodityType.get(0).getCommodityTypeId());
			model.addAttribute("list", goodsService.getTypeList(goodsForm));
	    	model.addAttribute("goodsForm", goodsForm);
    	}
    	else
    		{model.addAttribute("goodsForm", goodsForm);
    		model.addAttribute("list", goodsService.getTypeList(goodsForm));
    		}
    	UVO uvo = (UVO)session.getAttribute("UVO");
    	if (uvo == null) {
    		uvo = new UVO();
    		session.setAttribute("UVO", uvo);
    	}
    	model.addAttribute("list", goodsService.searchGoodsListByPopular(goodsForm));
    	model.addAttribute("orderTypeId", 3);
    	CartForm cartForm = new CartForm();
    	cartForm.setGuestId(uvo.getGuestId());
    	model.addAttribute("cartList", cartService.searchCartList(cartForm));
    	if(device.isNormal()) {
    		return "shop/list";
    	} else {
    		return "mobile/list";
    	}
    }
    @RequestMapping(value = "initGoodsByPriceDesc", method = RequestMethod.GET)
    public String initGoodsByPriceDesc(Model model, HttpSession session, GoodsForm goodsForm, Device device) {
    	log.info("以价格为条件商品列表初始化");
    	List<GoodsForm> commodityType = goodsService.getType();
    	model.addAttribute("commodityType", goodsService.getType());
    	if(goodsForm.getCommodityTypeId()==null)
    	{
			goodsForm.setCommodityTypeId(commodityType.get(0).getCommodityTypeId());
			model.addAttribute("list", goodsService.getTypeList(goodsForm));
	    	model.addAttribute("goodsForm", goodsForm);
    	}
    	else
    		{model.addAttribute("goodsForm", goodsForm);
    		model.addAttribute("list", goodsService.getTypeList(goodsForm));
    		}
    	UVO uvo = (UVO)session.getAttribute("UVO");
    	if (uvo == null) {
    		uvo = new UVO();
    		session.setAttribute("UVO", uvo);
    	}
    	model.addAttribute("list", goodsService.searchGoodsListByPriceDesc(goodsForm));
    	model.addAttribute("orderTypeId", 4);
    	CartForm cartForm = new CartForm();
    	cartForm.setGuestId(uvo.getGuestId());
    	model.addAttribute("cartList", cartService.searchCartList(cartForm));
    	if(device.isNormal()) {
    		return "shop/list";
    	} else {
    		return "mobile/list";
    	}
    }
    @RequestMapping(value = "initGoodsByPrice", method = RequestMethod.GET)
    public String initGoodsByPrice(Model model, HttpSession session, GoodsForm goodsForm, Device device) {
    	log.info("以价格为条件商品列表初始化");
    	List<GoodsForm> commodityType = goodsService.getType();
    	model.addAttribute("commodityType", goodsService.getType());
    	if(goodsForm.getCommodityTypeId()==null)
    	{
			goodsForm.setCommodityTypeId(commodityType.get(0).getCommodityTypeId());
			model.addAttribute("list", goodsService.getTypeList(goodsForm));
	    	model.addAttribute("goodsForm", goodsForm);
    	}
    	else
    		{model.addAttribute("goodsForm", goodsForm);
    		model.addAttribute("list", goodsService.getTypeList(goodsForm));
    		}
    	UVO uvo = (UVO)session.getAttribute("UVO");
    	if (uvo == null) {
    		uvo = new UVO();
    		session.setAttribute("UVO", uvo);
    	}
    	model.addAttribute("list", goodsService.searchGoodsListByPrice(goodsForm));
    	model.addAttribute("orderTypeId", 5);
    	CartForm cartForm = new CartForm();
    	cartForm.setGuestId(uvo.getGuestId());
    	model.addAttribute("cartList", cartService.searchCartList(cartForm));
    	if(device.isNormal()) {
    		return "shop/list";
    	} else {
    		return "mobile/list";
    	}
    }


转载于:https://my.oschina.net/u/2412052/blog/491732

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值