eq or like
接收一个w (id= xx or spuu_name like xxx) 用括号括起来 后面 and status =xxx 属于内嵌条件
WHERE (( (id = ? OR spu_name LIKE ?) ) AND publish_status = ? AND brand_id = ? AND catalog_id = ?)
if (!StringUtils.isEmpty(key)){
wrapper.and((w)->{
w.eq("id",key).or().like("spu_name",key);
});
}
String status = (String) params.get("status");
if (!StringUtils.isEmpty(key)){
wrapper.eq("publish_status",status);
}
大于 小于
String min = (String) params.get("min");
if (!StringUtils.isEmpty(key)){
//ge大于
queryWrapper.ge("price",min);
}
String max = (String) params.get("max");
if (!StringUtils.isEmpty(key)){
//le小于
queryWrapper.le("price",max);
}
更新 updateWrapper
@Override
public void updateUmsAddr(UmsAddr umsAddr) {
Integer addrDefault = umsAddr.getAddrDefault();
//如果addr_default是默认地址 1.先修改其他为非默认,在更新
if (addrDefault== UmsAddrConstant.umsAddrDefault.ONDEFAULT.getCode()){
UpdateWrapper<UmsAddr> updateWrapper = new UpdateWrapper<>();
//定义updateWrapper 设置全部addr_default为0
updateWrapper.set("addr_default", 0);
this.baseMapper.update(null,updateWrapper);
}
this.baseMapper.updateById(umsAddr);
}
@Override
public void reduceCouponNumber(Long couponId){
UpdateWrapper<Coupon> updateWrapper=new UpdateWrapper<>();
updateWrapper.setSql("coupon_number=coupon_number-1");
updateWrapper.eq("coupon_id",couponId);
this.update(updateWrapper);
}
Update set coupon_number=coupon_number-1 where coupon_id=couponId
updateWrapper.in("status", new Integer[]{0, 1}) sql 拼接
UpdateWrapper<TenantTrialApply> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda()
.eq(TenantTrialApply::getId, connectStatus.getId());
boolean update = this.update(connectStatus, updateWrapper);
queryWrapper.in(isNotEmpty(query.getIds()), "id", query.getIds());//是否推荐 1:推荐 eq(boolean condition, R column, Object val) 第一个参数 为boolean类型 true就拼接上 flase就不拼接;
标签:status,lamda,coupon,UpdateWrapper,key,id,表达式,updateWrapper From: https://blog.51cto.com/u_15993308/6186314