使用hutool工具判断数组是否存在
ArrayUtil.isNotEmpty(数组)
使用mybatis-plus批量添加
xxxMapper.insertBatch(Arrays.stream(xxxDto.getUserId()).map(objectId->new xxx表(id,objectId)).collect(Collectors.toSet()));
Mybatis-plus批量删除(逻辑删除)
@ApiOperation(value = "批量删除公告")
@OptLog(optType = REMOVE_BATCH)
public Result deleteBatch(@RequestBody List<Integer> ids){
if (ids!=null){
noticeService.update(new Notice(), Wrappers.<Notice>update().lambda().in(Notice::getId,ids).set(Notice::getIsDelete,1));
return Result.ok("批量删除成功");
}
throw new ServiceException("批量删除失败");
}
文章展示了如何利用Hutool库的ArrayUtil工具类检查数组是否非空,以及如何运用Mybatis-Plus进行批量添加和逻辑删除操作。在批量删除中,通过传入ID列表,更新对应记录的逻辑删除状态。
1174

被折叠的 条评论
为什么被折叠?



