检索《商品》

header.html

<form action="selectGoods" th:object="${goodsForm}" method="post">
								<input type="text" class="inpt" placeholder="请输入关键字" name="commodityName"/>
								<input type="submit" value="检索" class="btnS"/>
								</form>

GoodsController.java

 @RequestMapping(value = "selectGoods", method = RequestMethod.POST)
    public String  selectGoods(Model model,HttpSession session,GoodsForm goodsForm,Device device){
    	log.info("检索相关商品");
    	model.addAttribute("commodityType", goodsService.getType());
    	List<GoodsForm> list=goodsService.searchGoodsListrelative(goodsForm);
    	model.addAttribute("list",list);
    	model.addAttribute("orderTypeId", 1);
    	UVO uvo = (UVO)session.getAttribute("UVO");
    	if (uvo == null) {
    		uvo = new UVO();
    		session.setAttribute("UVO", uvo);
    	}
    	CartForm cartForm = new CartForm();
    	cartForm.setGuestId(uvo.getGuestId());
    	model.addAttribute("cartList", cartService.searchCartList(cartForm));
    	model.addAttribute("goodsForm", goodsForm);
    	if(device.isNormal()) {
    		return "shop/list";
    	} else {
    		return "mobile/list";
    	}
    }

GoodsService.java

public List<GoodsForm> searchGoodsListrelative(GoodsForm frm) {
		List<GoodsForm> result = queryDao.executeForObjectList("Goods.selectGoodsListrelative", frm);
		return result;
	}

GoodsSqlMap.xml

<select id="selectGoodsListrelative"
		parameterClass="cn.agriculture.web.form.GoodsForm"
		resultClass="cn.agriculture.web.form.GoodsForm">
		SELECT commodity.commodity_id as commodityId,
			commodity.type as commodityTypeId,
			supplier.supplier_name as supplierName,
			brand.brand_name as brandName,
			commodity.commodity_name as commodityName,
			commodity.weight as weight,
			commodity.is_gift as isGift,
			commodity.specifications as specifications,
			commodity.unit as unit,
			commodity.benchmark_price as benchmarkPrice,
			commodity.guide_price as guidePrice,
			commodity.retail_price as retailPrice,
			commodity.competition_level as competitionLevel,
			commodity.note as note,
			commodity.update_time as updateTime,
			commodity.update_user as updateUser,
			commodity.picture_id as pictureId,
			stock.stock as stock
		FROM commodity, supplier, brand, stock
		WHERE commodity.commodity_id = stock.commodity_id
		AND commodity.supplier_id = supplier.supplier_id
		AND commodity.brand_id = brand.brand_id
		AND commodity.commodity_name LIKE '%$commodityName$%'
	</select>


你可能感兴趣的:(检索《商品》)