首页 > 代码库 > 批量更新的两种方法
批量更新的两种方法
/** * 批量删除 * * @description */ @RequestMapping(value = "/deleteIdsLogicGoods") public void deleteIdsLogic(HttpServletRequest request, HttpServletResponse response) { String ids = null; if (request.getParameter("ids") != null) { ids = request.getParameter("ids").trim(); String[] idArr = ids.split(","); for (int i = 0; i < idArr.length; i++) { WeixinActivity bean = new WeixinActivity(); bean.setId(Long.parseLong(idArr[i])); bean.setIsDelete("Y"); weixinActivityService.updateWeixinActivityGoods(bean); } } }
//批量删除 @RequestMapping(value = "http://www.mamicode.com/batchDeleteLinks", method=RequestMethod.POST) @ResponseBody public String batchDeleteLinks(HttpServletRequest request) { Integer userId = (Integer)request.getSession().getAttribute("userId"); String str = "no"; String idStr = request.getParameter("idStr").toString(); String [] tempids =idStr.split(","); List<PageIndexLinks> list = new ArrayList <PageIndexLinks> (); for (int i =0; i<tempids.length ; i++){ PageIndexLinks pageIndexLinks = new PageIndexLinks (); pageIndexLinks.setId(Long.valueOf(tempids[i])); pageIndexLinks.setIsDelete("Y"); pageIndexLinks.setEditTime(StringUtil.returnDateFormat(new Date(),"yyyy-MM-dd HH:mm:ss")); pageIndexLinks.setEditUserId(userId); list.add(pageIndexLinks); } ServiceMessage<?> msg = pageIndexLinksService.batchUpdatePageIndexLinks(list); if(msg.getStatus().getCode().equals("0")){ str="ok"; } return str; } public ServiceMessage<?> batchUpdatePageIndexLinks(List<PageIndexLinks> list) { try{ if(list==null || list.size()==0){ return super.returnParamsError("batchUpdatePageIndexLinks(list=null)"); } for(PageIndexLinks pageIndexLinks:list){ pageIndexLinksMapper.update(pageIndexLinks); } }catch(Exception e){ logger.error(e.getMessage()); return super.returnException(); } return super. returnCorrectResult("ok"); }
批量更新的两种方法
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。