com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper Java Examples
The following examples show how to use
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SysAnnouncementSendController.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * @功能:更新用户系统消息阅读状态 * @param json * @return */ @PutMapping(value = "/editByAnntIdAndUserId") public Result<SysAnnouncementSend> editById(@RequestBody JSONObject json) { Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>(); String anntId = json.getString("anntId"); LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); String userId = sysUser.getId(); LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda(); updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG); updateWrapper.set(SysAnnouncementSend::getReadTime, new Date()); updateWrapper.last("where annt_id ='"+anntId+"' and user_id ='"+userId+"'"); SysAnnouncementSend announcementSend = new SysAnnouncementSend(); sysAnnouncementSendService.update(announcementSend, updateWrapper); result.setSuccess(true); return result; }
Example #2
Source File: SysAnnouncementSendController.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * @功能:一键已读 * @return */ @PutMapping(value = "/readAll") public Result<SysAnnouncementSend> readAll() { Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>(); LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); String userId = sysUser.getId(); LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda(); updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG); updateWrapper.set(SysAnnouncementSend::getReadTime, new Date()); updateWrapper.last("where user_id ='"+userId+"'"); SysAnnouncementSend announcementSend = new SysAnnouncementSend(); sysAnnouncementSendService.update(announcementSend, updateWrapper); result.setSuccess(true); result.setMessage("全部已读"); return result; }
Example #3
Source File: SysAnnouncementSendController.java From jeecg-boot with Apache License 2.0 | 6 votes |
/** * @功能:一键已读 * @return */ @PutMapping(value = "/readAll") public Result<SysAnnouncementSend> readAll() { Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>(); LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); String userId = sysUser.getId(); LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda(); updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG); updateWrapper.set(SysAnnouncementSend::getReadTime, new Date()); updateWrapper.last("where user_id ='"+userId+"'"); SysAnnouncementSend announcementSend = new SysAnnouncementSend(); sysAnnouncementSendService.update(announcementSend, updateWrapper); result.setSuccess(true); result.setMessage("全部已读"); return result; }
Example #4
Source File: SysAnnouncementSendController.java From jeecg-boot with Apache License 2.0 | 6 votes |
/** * @功能:更新用户系统消息阅读状态 * @param json * @return */ @PutMapping(value = "/editByAnntIdAndUserId") public Result<SysAnnouncementSend> editById(@RequestBody JSONObject json) { Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>(); String anntId = json.getString("anntId"); LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); String userId = sysUser.getId(); LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda(); updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG); updateWrapper.set(SysAnnouncementSend::getReadTime, new Date()); updateWrapper.last("where annt_id ='"+anntId+"' and user_id ='"+userId+"'"); SysAnnouncementSend announcementSend = new SysAnnouncementSend(); sysAnnouncementSendService.update(announcementSend, updateWrapper); result.setSuccess(true); return result; }
Example #5
Source File: SysAnnouncementSendController.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * @功能:更新用户系统消息阅读状态 * @param json * @return */ @PutMapping(value = "/editByAnntIdAndUserId") public Result<SysAnnouncementSend> editById(@RequestBody JSONObject json) { Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>(); String anntId = json.getString("anntId"); LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); String userId = sysUser.getId(); LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda(); updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG); updateWrapper.set(SysAnnouncementSend::getReadTime, new Date()); updateWrapper.last("where annt_id ='"+anntId+"' and user_id ='"+userId+"'"); SysAnnouncementSend announcementSend = new SysAnnouncementSend(); sysAnnouncementSendService.update(announcementSend, updateWrapper); result.setSuccess(true); return result; }
Example #6
Source File: SysAnnouncementSendController.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * @功能:一键已读 * @return */ @PutMapping(value = "/readAll") public Result<SysAnnouncementSend> readAll() { Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>(); LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); String userId = sysUser.getId(); LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda(); updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG); updateWrapper.set(SysAnnouncementSend::getReadTime, new Date()); updateWrapper.last("where user_id ='"+userId+"'"); SysAnnouncementSend announcementSend = new SysAnnouncementSend(); sysAnnouncementSendService.update(announcementSend, updateWrapper); result.setSuccess(true); result.setMessage("全部已读"); return result; }
Example #7
Source File: SysAnnouncementSendController.java From teaching with Apache License 2.0 | 6 votes |
/** * @功能:一键已读 * @return */ @PutMapping(value = "/readAll") public Result<SysAnnouncementSend> readAll() { Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>(); LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); String userId = sysUser.getId(); LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda(); updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG); updateWrapper.set(SysAnnouncementSend::getReadTime, new Date()); updateWrapper.last("where user_id ='"+userId+"'"); SysAnnouncementSend announcementSend = new SysAnnouncementSend(); sysAnnouncementSendService.update(announcementSend, updateWrapper); result.setSuccess(true); result.setMessage("全部已读"); return result; }
Example #8
Source File: PostsServiceImpl.java From plumemo with Apache License 2.0 | 6 votes |
@Override public Result publishByteBlogs(PostsVO postsVO) { UserSessionVO userSessionInfo = SessionUtil.getUserSessionInfo(); Posts posts = postsDao.selectById(postsVO.getId()); if (posts == null) { ExceptionUtil.rollback(ErrorEnum.DATA_NO_EXIST); } PostsAttribute postsAttribute = postsAttributeDao.selectOne(new LambdaQueryWrapper<PostsAttribute>().eq(PostsAttribute::getPostsId, posts.getId())); boolean syncStatus = syncByteblogs(new PostsVO().setTitle(posts.getTitle()).setIsPublishByteBlogs(Constants.YES).setContent(postsAttribute.getContent())); log.debug("保存到ByteBlogs草稿箱 {}", syncStatus); if (syncStatus) { postsDao.update(new Posts().setSyncStatus(Constants.YES), new LambdaUpdateWrapper<Posts>().eq(Posts::getId, postsVO.getId())); return Result.createWithSuccessMessage("同步到ByteBlogs成功,请点击" + Constants.BYTE_BLOGS_URL + "/editor/posts" + "进行编辑"); } return Result.createWithErrorMessage(ErrorEnum.SYNC_POSTS_ERROR); }
Example #9
Source File: SysAnnouncementSendController.java From teaching with Apache License 2.0 | 6 votes |
/** * @功能:更新用户系统消息阅读状态 * @param json * @return */ @PutMapping(value = "/editByAnntIdAndUserId") public Result<SysAnnouncementSend> editById(@RequestBody JSONObject json) { Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>(); String anntId = json.getString("anntId"); LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); String userId = sysUser.getId(); LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda(); updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG); updateWrapper.set(SysAnnouncementSend::getReadTime, new Date()); updateWrapper.last("where annt_id ='"+anntId+"' and user_id ='"+userId+"'"); SysAnnouncementSend announcementSend = new SysAnnouncementSend(); sysAnnouncementSendService.update(announcementSend, updateWrapper); result.setSuccess(true); return result; }
Example #10
Source File: PostsServiceImpl.java From plumemo with Apache License 2.0 | 5 votes |
@Override public Result deletePosts(Long id) { Posts posts = postsDao.selectById(id); if (posts == null) { ExceptionUtil.rollback(ErrorEnum.DATA_NO_EXIST); } postsDao.deleteById(id); postsAttributeDao.delete(new LambdaUpdateWrapper<PostsAttribute>().eq(PostsAttribute::getPostsId, id)); postsTagsDao.delete(new LambdaUpdateWrapper<PostsTags>().eq(PostsTags::getPostsId, id)); return Result.createWithSuccessMessage(); }
Example #11
Source File: SysBaseApiImpl.java From jeecg-boot with Apache License 2.0 | 5 votes |
@Override public void updateSysAnnounReadFlag(String busType, String busId) { SysAnnouncement announcement = sysAnnouncementMapper.selectOne(new QueryWrapper<SysAnnouncement>().eq("bus_type",busType).eq("bus_id",busId)); if(announcement != null){ LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); String userId = sysUser.getId(); LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda(); updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG); updateWrapper.set(SysAnnouncementSend::getReadTime, new Date()); updateWrapper.last("where annt_id ='"+announcement.getId()+"' and user_id ='"+userId+"'"); SysAnnouncementSend announcementSend = new SysAnnouncementSend(); sysAnnouncementSendMapper.update(announcementSend, updateWrapper); } }
Example #12
Source File: SysBaseApiImpl.java From teaching with Apache License 2.0 | 5 votes |
@Override public void updateSysAnnounReadFlag(String busType, String busId) { SysAnnouncement announcement = sysAnnouncementMapper.selectOne(new QueryWrapper<SysAnnouncement>().eq("bus_type",busType).eq("bus_id",busId)); if(announcement != null){ LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); String userId = sysUser.getId(); LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda(); updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG); updateWrapper.set(SysAnnouncementSend::getReadTime, new Date()); updateWrapper.last("where annt_id ='"+announcement.getId()+"' and user_id ='"+userId+"'"); SysAnnouncementSend announcementSend = new SysAnnouncementSend(); sysAnnouncementSendMapper.update(announcementSend, updateWrapper); } }
Example #13
Source File: CategoryServiceImpl.java From plumemo with Apache License 2.0 | 5 votes |
@Override public Result updateCategory(CategoryVO categoryVO) { Integer count = this.categoryDao.selectCount(new LambdaQueryWrapper<Category>().eq(Category::getId, categoryVO.getId())); if (count.equals(Constants.ZERO)) { ExceptionUtil.rollback(ErrorEnum.DATA_NO_EXIST); } Category category = new Category().setId(categoryVO.getId()).setName(categoryVO.getName()).setUpdateTime(LocalDateTime.now()); this.categoryDao.updateById(category); List<TagsVO> tagsList = categoryVO.getTagsList(); this.categoryTagsDao.delete(new LambdaUpdateWrapper<CategoryTags>().eq(CategoryTags::getCategoryId, category.getId())); if (!CollectionUtils.isEmpty(tagsList)) { tagsList.forEach(tagsVO -> { if (tagsVO.getId() == null) { // saveLogs Tags tags = new Tags().setName(tagsVO.getName()).setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now()); this.tagsDao.insert(tags); tagsVO.setId(tags.getId()); } categoryTagsDao.insert(new CategoryTags().setCategoryId(category.getId()).setTagsId(tagsVO.getId()).setCreateTime(LocalDateTime.now()).setUpdateTime(LocalDateTime.now())); }); } return Result.createWithSuccessMessage(); }
Example #14
Source File: BlogCategoryServiceImpl.java From My-Blog-layui with Apache License 2.0 | 5 votes |
@Transactional(rollbackFor = Exception.class) @Override public boolean clearCategory(BlogCategory blogCategory) { BlogInfo blogInfo = new BlogInfo() .setBlogCategoryId(Integer.valueOf(SysConfigConstants.DEFAULT_CATEGORY.getConfigField())) .setBlogCategoryName(SysConfigConstants.DEFAULT_CATEGORY.getConfigName()); LambdaUpdateWrapper<BlogInfo> updateWrapper = Wrappers.<BlogInfo>lambdaUpdate() .eq(BlogInfo::getBlogCategoryId, blogCategory.getCategoryId()); blogInfoMapper.update(blogInfo, updateWrapper); return retBool(baseMapper.deleteById(blogCategory.getCategoryId())); }
Example #15
Source File: PostsServiceImpl.java From plumemo with Apache License 2.0 | 5 votes |
/** * 同步数据到社区 * * @param postsVO * @return */ private boolean syncByteblogs(PostsVO postsVO) { if (postsVO.getIsPublishByteBlogs().equals(Constants.YES)) { ByteBlogsClient byteBlogsClient = BeanTool.getBean(ByteBlogsClient.class); HttpResult result = byteBlogsClient.syncPosts(new PostsDTO().setTitle(postsVO.getTitle()).setContent(postsVO.getContent())); log.warn("保存到ByteBlogs草稿箱 {}", result); if (result.getSuccess() == Constants.YES) { postsDao.update(new Posts().setSyncStatus(Constants.YES), new LambdaUpdateWrapper<Posts>().eq(Posts::getId, postsVO.getId())); return true; } } return false; }
Example #16
Source File: SysBaseApiImpl.java From jeecg-cloud with Apache License 2.0 | 5 votes |
@Override public void updateSysAnnounReadFlag(String busType, String busId) { SysAnnouncement announcement = sysAnnouncementMapper.selectOne(new QueryWrapper<SysAnnouncement>().eq("bus_type",busType).eq("bus_id",busId)); if(announcement != null){ LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); String userId = sysUser.getId(); LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda(); updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG); updateWrapper.set(SysAnnouncementSend::getReadTime, new Date()); updateWrapper.last("where annt_id ='"+announcement.getId()+"' and user_id ='"+userId+"'"); SysAnnouncementSend announcementSend = new SysAnnouncementSend(); sysAnnouncementSendMapper.update(announcementSend, updateWrapper); } }
Example #17
Source File: UserServiceImpl.java From kvf-admin with MIT License | 4 votes |
@Override public void updateUserPassword(Long id, String password) { super.update(new LambdaUpdateWrapper<User>() .set(User::getPassword, password) .eq(User::getId, id)); }
Example #18
Source File: SysRoleServiceImpl.java From spring-boot-plus with Apache License 2.0 | 4 votes |
@Override public boolean updateSysRolePermission(UpdateSysRolePermissionParam param) throws Exception { Long roleId = param.getRoleId(); List<Long> permissionIds = param.getPermissionIds(); // 校验角色是否存在 SysRole sysRole = getById(roleId); if (sysRole == null) { throw new BusinessException("该角色不存在"); } if (CollectionUtils.isNotEmpty(permissionIds)) { // 校验权限列表是否存在 if (!sysPermissionService.isExistsByPermissionIds(permissionIds)) { throw new BusinessException("权限列表id匹配失败"); } } // 获取之前的权限id集合 List<Long> beforeList = sysRolePermissionService.getPermissionIdsByRoleId(roleId); // 差集计算 // before:1,2,3,4,5,6 // after: 1,2,3,4,7,8 // 删除5,6 新增7,8 // 此处真实删除,去掉deleted字段的@TableLogic注解 Set<Long> beforeSet = new HashSet<>(beforeList); Set<Long> afterSet = new HashSet<>(permissionIds); SetView<Long> deleteSet = SetUtils.difference(beforeSet, afterSet); SetView<Long> addSet = SetUtils.difference(afterSet, beforeSet); log.debug("deleteSet = " + deleteSet); log.debug("addSet = " + addSet); if (CollectionUtils.isNotEmpty(deleteSet)) { // 删除权限关联 LambdaUpdateWrapper<SysRolePermission> updateWrapper = new LambdaUpdateWrapper<>(); updateWrapper.eq(SysRolePermission::getRoleId, roleId); updateWrapper.in(SysRolePermission::getPermissionId, deleteSet); boolean deleteResult = sysRolePermissionService.remove(updateWrapper); if (!deleteResult) { throw new DaoException("删除角色权限关系失败"); } } if (CollectionUtils.isNotEmpty(addSet)) { // 新增权限关联 boolean addResult = sysRolePermissionService.saveSysRolePermissionBatch(roleId, addSet); if (!addResult) { throw new DaoException("新增角色权限关系失败"); } } return true; }