判断ID不为空,怎么做?if (Request.Params ["id"] !=null)

int id;
try{
id=int.Parse(Request.QueryString["id"];
}
catch{
id=1;
}
解释一下这段代码:public R autoSort2(@RequestParam Map<String, Object> params,CaipinxinxiEntity caipinxinxi, HttpServletRequest request){ String userId = request.getSession().getAttribute("userId").toString(); String goodtypeColumn = "caipinfenlei"; List<OrdersEntity> orders = ordersService.selectList(new EntityWrapper<OrdersEntity>().eq("userid", userId).eq("tablename", "caipinxinxi").orderBy("addtime", false)); List<String> goodtypes = new ArrayList<String>(); Integer limit = params.get("limit")==null?10:Integer.parseInt(params.get("limit").toString()); List<CaipinxinxiEntity> caipinxinxiList = new ArrayList<CaipinxinxiEntity>();//去重 List<OrdersEntity> ordersDist = new ArrayList<OrdersEntity>(); for(OrdersEntity o1 : orders) { boolean addFlag = true; for(OrdersEntity o2 : ordersDist) { if(o1.getGoodid()==o2.getGoodid() || o1.getGoodtype().equals(o2.getGoodtype())) { addFlag = false; break; } } if(addFlag) ordersDist.add(o1); } if(ordersDist!=null && ordersDist.size()>0) { for(OrdersEntity o : ordersDist) { caipinxinxiList.addAll(caipinxinxiService.selectList(new EntityWrapper<CaipinxinxiEntity>().eq(goodtypeColumn, o.getGoodtype()))); } } EntityWrapper<CaipinxinxiEntity> ew = new EntityWrapper<CaipinxinxiEntity>(); params.put("sort", "id"); params.put("order", "desc"); //调用caipinxinxi对象的queryPage方法 PageUtils page = caipinxinxiService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.likeOrEq(ew, caipinxinxi), params), params)); List<CaipinxinxiEntity> pageList = (List<CaipinxinxiEntity>)page.getList(); if(caipinxinxiList.size()<limit) { int toAddNum = (limit-caipinxinxiList.size())<=pageList.size()?(limit-caipinxinxiList.size()):pageList.size(); for(CaipinxinxiEntity o1 : pageList) { boolean addFlag = true; for(CaipinxinxiEntity o2 : caipinxinxiList) { if(o1.getId().intValue()==o2.getId().intValue()) { addFlag = false; break; } } if(addFlag) { caipinxinxiList.add(o1); if(--toAddNum==0) break; } } } page.setList(caipinxinxiList); return R.ok().put("data", page); }
04-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值