@RequestMapping("cartListVo")
public ResultEntity cartListVo(@RequestParam(name = "data", required = true) String data) {
GoodsCart goodsCart;
try {
goodsCart = decodeByBase64(data, GoodsCart.class);
System.out.println(goodsCart);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
return error(ResultCode.PARAM_DECODE_ERROR);
}
Wrapper<GoodsCart> wrapper = new EntityWrapper<GoodsCart>().eq("user_id", goodsCart.getUserId());
List<GoodsCart> selectList = goodsCartService.selectList(wrapper);
ArrayList<GoodsCartVo> goodsCartVoList = Lists.newArrayList();
if(selectList.size()!=0) {
for(GoodsCart onlyObj:selectList) {
GoodsCartVo goodsCartVoLin = new GoodsCartVo();
BeanUtils.copyProperties(onlyObj, goodsCartVoLin);
goodsCartVoList.add(goodsCartVoLin);
}
}
if(goodsCartVoList.size()!=0) {
for(GoodsCartVo goodsCartVo2:goodsCartVoList) {
Wrapper<GoodsBaseInfo> wrapper2 = new EntityWrapper<GoodsBaseInfo>().eq("id", goodsCartVo2.getGoodsId());
GoodsBaseInfo selectOne = goodsBaseInfoService.selectOne(wrapper2);
goodsCartVo2.setGoodsBaseInfo(selectOne);
}
}
return success(goodsCartVoList);
}
原文:https://www.cnblogs.com/dianzan/p/12455523.html