码迷,mamicode.com
首页 > 其他好文 > 详细

批量更新的两种方法

时间:2017-01-09 16:39:12      阅读:389      评论:0      收藏:0      [点我收藏+]

标签:batch   turn   blog   cep   mpi   pre   ida   oid   方法   

/**
     * 批量删除
     *
     * @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 = "/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");
    }

 

批量更新的两种方法

标签:batch   turn   blog   cep   mpi   pre   ida   oid   方法   

原文地址:http://www.cnblogs.com/wangchuanfu/p/6265370.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!