@Test public void testSelectByAccount() throws Exception { List<Map<String, Object>> mapList = service.selectByAccount(2l); for (Map<String, Object> map: mapList){ System.out.println(map.get("commodityName")); } }
@Override public List<Map<String, Object>> selectByAccount(Long accountId) { List<Map<String, Object>> mapList = new ArrayList<>(); ShoppingCart shopping = new ShoppingCart(); shopping.setUserAccountId(accountId); List<ShoppingCart> list = mapper.select(shopping); for (ShoppingCart sc : list) { Map<String, Object> map = new HashMap<>(); Commoditys key = commodMapper.selectByPrimaryKey(sc.getCommodityId()); map.put("commodityName", key.getName()); map.put("buyCurrentNumber", key.getBuyCurrentNumber()); map.put("buyTotalNumber", key.getBuyTotalNumber()); map.put("commodityId", key.getId()); map.put("coverImgUrl", key.getCoverImgUrl()); map.put("payNumber", sc.getNumber()); mapList.add(map); } return mapList; }
ShoppingCartServiceImpl implements IShoppingCartService { @Override public List<Map<String, Object>> selectByAccount(Long accountId) { List<Map<String, Object>> mapList = new ArrayList<>(); ShoppingCart shopping = new ShoppingCart(); shopping.setUserAccountId(accountId); List<ShoppingCart> list = mapper.select(shopping); for (ShoppingCart sc : list) { Map<String, Object> map = new HashMap<>(); Commoditys key = commodMapper.selectByPrimaryKey(sc.getCommodityId()); map.put("commodityName", key.getName()); map.put("buyCurrentNumber", key.getBuyCurrentNumber()); map.put("buyTotalNumber", key.getBuyTotalNumber()); map.put("commodityId", key.getId()); map.put("coverImgUrl", key.getCoverImgUrl()); map.put("payNumber", sc.getNumber()); mapList.add(map); } return mapList; } }
ShoppingCartServiceImpl implements IShoppingCartService { @Override public List<Map<String, Object>> selectByAccount(Long accountId) { List<Map<String, Object>> mapList = new ArrayList<>(); ShoppingCart shopping = new ShoppingCart(); shopping.setUserAccountId(accountId); List<ShoppingCart> list = mapper.select(shopping); for (ShoppingCart sc : list) { Map<String, Object> map = new HashMap<>(); Commoditys key = commodMapper.selectByPrimaryKey(sc.getCommodityId()); map.put("commodityName", key.getName()); map.put("buyCurrentNumber", key.getBuyCurrentNumber()); map.put("buyTotalNumber", key.getBuyTotalNumber()); map.put("commodityId", key.getId()); map.put("coverImgUrl", key.getCoverImgUrl()); map.put("payNumber", sc.getNumber()); mapList.add(map); } return mapList; }  }
ShoppingCartServiceImpl implements IShoppingCartService { @Override public List<Map<String, Object>> selectByAccount(Long accountId) { List<Map<String, Object>> mapList = new ArrayList<>(); ShoppingCart shopping = new ShoppingCart(); shopping.setUserAccountId(accountId); List<ShoppingCart> list = mapper.select(shopping); for (ShoppingCart sc : list) { Map<String, Object> map = new HashMap<>(); Commoditys key = commodMapper.selectByPrimaryKey(sc.getCommodityId()); map.put("commodityName", key.getName()); map.put("buyCurrentNumber", key.getBuyCurrentNumber()); map.put("buyTotalNumber", key.getBuyTotalNumber()); map.put("commodityId", key.getId()); map.put("coverImgUrl", key.getCoverImgUrl()); map.put("payNumber", sc.getNumber()); mapList.add(map); } return mapList; }  @Override boolean addCommodityToCart(Long accountId, Long commId, Integer count); @Override boolean deleteCommodity(Long accountId, Long commId); @Override boolean updateCommodity(Long accountId, Long commId, Integer count); @Override List<Map<String, Object>> selectByAccount(Long accountId); }
ShoppingCartServiceImpl implements IShoppingCartService { @Override public List<Map<String, Object>> selectByAccount(Long accountId) { List<Map<String, Object>> mapList = new ArrayList<>(); ShoppingCart shopping = new ShoppingCart(); shopping.setUserAccountId(accountId); List<ShoppingCart> list = mapper.select(shopping); for (ShoppingCart sc : list) { Map<String, Object> map = new HashMap<>(); Commoditys key = commodMapper.selectByPrimaryKey(sc.getCommodityId()); map.put("commodityName", key.getName()); map.put("buyCurrentNumber", key.getBuyCurrentNumber()); map.put("buyTotalNumber", key.getBuyTotalNumber()); map.put("commodityId", key.getId()); map.put("coverImgUrl", key.getCoverImgUrl()); map.put("payNumber", sc.getNumber()); mapList.add(map); } return mapList; }  @Override boolean addCommodityToCart(Long accountId, Long commId, Integer count); @Override boolean deleteCommodity(Long accountId, Long commId); @Override boolean updateCommodity(Long accountId, Long commId, Integer count); @Override List<Map<String, Object>> selectByAccount(Long accountId);  }