/** * 增加一条GiftProd记录 * * @param response * @throws IOException */ @RequestMapping("/add") public void saveGiftProd(HttpServletResponse response, Integer[] sellProdIds, GiftProd giftProd) throws IOException { if (logger.isInfoEnabled()) { logger.info( "GiftProdService的saveGiftProd操作,参数giftProd,sellProdIds分别是:" + giftProd.toString() + "," + sellProdIds.toString()); } List<GiftProd> giftProdList = new ArrayList<GiftProd>(); int countAll = sellProdIds.length; for (int i = 0; i < countAll; i++) { GiftProd saveGiftProd = new GiftProd(); saveGiftProd.setSellProdId(sellProdIds[i]); saveGiftProd.setGiftProdId(giftProd.getGiftProdId()); saveGiftProd.setGiftProdCount(giftProd.getGiftProdCount()); saveGiftProd.setInUse(giftProd.getInUse()); giftProdList.add(saveGiftProd); } try { int count = giftProdService.saveGiftProdList(giftProdList); new JsonResult(JsonResult.SUCCESS) .setMsg("增加成功") .addData(JsonResult.RESULT_TYPE_TOTAL_COUNT, count) .toJson(response); } catch (ErpBusinessException e) { logger.info(e.getMessage()); new JsonResult(JsonResult.FAILURE).setMsg(e.getMessage()).toJson(response); } }
/** * 根据id 修改该记录的 其他字段值 * * @param response * @param giftProd * @throws IOException */ @RequestMapping("/update") public void updateGiftProdById(HttpServletResponse response, GiftProd giftProd) throws IOException { if (logger.isInfoEnabled()) { logger.info("GiftProdService的deleteGiftProdById操作,参数giftProd=" + giftProd.toString()); } int count = giftProdService.updateGiftProdById(giftProd); if (count != 0) { new JsonResult(JsonResult.SUCCESS) .setMsg("修改成功") .addData(JsonResult.RESULT_TYPE_TOTAL_COUNT, count) .toJson(response); } else { new JsonResult(JsonResult.FAILURE).setMsg("修改失败,此活动已经存在了").toJson(response); } }