mybatis使用,UpdateWrapper时间更新问题

2024-03-08 08:11:00 浏览数 (2)

//批量更订单删除状态:需要set时间

NeoCrmOrder updateNeoCrmCustomer = new NeoCrmOrder(); return neoCrmOrderMapper.update(updateNeoCrmCustomer, new UpdateWrapper<NeoCrmOrder>().eq("state_deleted", 0).eq("channel_contract_id", contract.getId()) .set("update_time", date) .set("state_deleted", 1));

//方法二:需要set时间 return neoCrmOrderMapper.update(null, new UpdateWrapper<NeoCrmOrder>().eq("state_deleted", 0).eq("channel_contract_id", contract.getId()) .set("state_deleted", 1) .set("update_time", new Date()));

//方法三:

NeoCrmOrder updateNeoCrmCustomer = new NeoCrmOrder(); UpdateWrapper<NeoCrmOrder> neoCrmCustomerUpdateWrapper = new UpdateWrapper<>(); neoCrmCustomerUpdateWrapper.eq("state_deleted", 0); neoCrmCustomerUpdateWrapper.eq("channel_contract_id", contract.getId()); neoCrmCustomerUpdateWrapper.set("state_deleted", 1); //会自动更新updateTime时间 this.update(updateNeoCrmCustomer, neoCrmCustomerUpdateWrapper);

0 人点赞