批量更新的两种方法

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值