org.springframework.cache.annotation.CacheEvict Java Examples
The following examples show how to use
org.springframework.cache.annotation.CacheEvict.
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: SysDictItemController.java From teaching with Apache License 2.0 | 6 votes |
/** * @功能:删除字典数据 * @param id * @return */ @RequestMapping(value = "/delete", method = RequestMethod.DELETE) @CacheEvict(value=CacheConstant.SYS_DICT_CACHE, allEntries=true) public Result<SysDictItem> delete(@RequestParam(name="id",required=true) String id) { Result<SysDictItem> result = new Result<SysDictItem>(); SysDictItem joinSystem = sysDictItemService.getById(id); if(joinSystem==null) { result.error500("未找到对应实体"); }else { boolean ok = sysDictItemService.removeById(id); if(ok) { result.success("删除成功!"); } } return result; }
Example #2
Source File: PlaylistService.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
/** * DO NOT pass in the mutated cache value. This method relies on the existing * cached value to check the differences */ @CacheEvict(cacheNames = "playlistCache", key = "#playlist.id") public void updatePlaylist(Playlist playlist, boolean filesChangedBroadcastContext) { Playlist oldPlaylist = getPlaylist(playlist.getId()); playlistDao.updatePlaylist(playlist); runAsync(() -> { BroadcastedPlaylist bp = new BroadcastedPlaylist(playlist, filesChangedBroadcastContext); if (playlist.getShared()) { brokerTemplate.convertAndSend("/topic/playlists/updated", bp); } else { if (oldPlaylist.getShared()) { brokerTemplate.convertAndSend("/topic/playlists/deleted", playlist.getId()); } Stream.concat(Stream.of(playlist.getUsername()), getPlaylistUsers(playlist.getId()).stream()) .forEach(u -> brokerTemplate.convertAndSendToUser(u, "/queue/playlists/updated", bp)); } }); }
Example #3
Source File: UserService.java From spring-microservice-exam with MIT License | 6 votes |
/** * 批量删除用户 * * @param ids ids * @return int * @author tangyi * @date 2019/07/04 11:44:45 */ @Transactional @Override @CacheEvict(value = "user", allEntries = true) public int deleteAll(Long[] ids) { String currentUser = SysUtil.getUser(), applicationCode = SysUtil.getSysCode(), tenantCode = SysUtil.getTenantCode(); for (Long id : ids) { // 删除用户角色关系 userRoleMapper.deleteByUserId(id); // 删除用户授权信息 UserAuths userAuths = new UserAuths(); userAuths.setNewRecord(false); userAuths.setUserId(id); userAuths.setCommonValue(currentUser, applicationCode, tenantCode); userAuthsService.deleteByUserId(userAuths); } return super.deleteAll(ids); }
Example #4
Source File: SysDepartController.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * 添加新数据 添加用户新建的部门对象数据,并保存到数据库 * * @param sysDepart * @return */ @RequestMapping(value = "/add", method = RequestMethod.POST) @CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true) public Result<SysDepart> add(@RequestBody SysDepart sysDepart, HttpServletRequest request) { Result<SysDepart> result = new Result<SysDepart>(); String username = JwtUtil.getUserNameByToken(request); try { sysDepart.setCreateBy(username); sysDepartService.saveDepartData(sysDepart, username); //清除部门树内存 // FindsDepartsChildrenUtil.clearSysDepartTreeList(); // FindsDepartsChildrenUtil.clearDepartIdModel(); result.success("添加成功!"); } catch (Exception e) { log.error(e.getMessage(),e); result.error500("操作失败"); } return result; }
Example #5
Source File: SysPermissionServiceImpl.java From jeecg-cloud with Apache License 2.0 | 6 votes |
@Override @CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true) public void addPermission(SysPermission sysPermission) throws JeecgBootException { //---------------------------------------------------------------------- //判断是否是一级菜单,是的话清空父菜单 if(CommonConstant.MENU_TYPE_0.equals(sysPermission.getMenuType())) { sysPermission.setParentId(null); } //---------------------------------------------------------------------- String pid = sysPermission.getParentId(); if(oConvertUtils.isNotEmpty(pid)) { //设置父节点不为叶子节点 this.sysPermissionMapper.setMenuLeaf(pid, 0); } sysPermission.setCreateTime(new Date()); sysPermission.setDelFlag(0); sysPermission.setLeaf(true); this.save(sysPermission); }
Example #6
Source File: BaseAuthorityServiceImpl.java From open-cloud with MIT License | 6 votes |
/** * 应用授权-添加单个权限 * * @param appId * @param expireTime * @param authorityId */ @CacheEvict(value = {"apps"}, key = "'client:'+#appId") @Override public void addAuthorityApp(String appId, Date expireTime, String authorityId) { BaseAuthorityApp authority = new BaseAuthorityApp(); authority.setAppId(appId); authority.setAuthorityId(Long.parseLong(authorityId)); authority.setExpireTime(expireTime); authority.setCreateTime(new Date()); authority.setUpdateTime(authority.getCreateTime()); QueryWrapper<BaseAuthorityApp> appQueryWrapper = new QueryWrapper(); appQueryWrapper.lambda() .eq(BaseAuthorityApp::getAppId, appId) .eq(BaseAuthorityApp::getAuthorityId, authorityId); int count = baseAuthorityAppMapper.selectCount(appQueryWrapper); if (count > 0) { return; } authority.setCreateTime(new Date()); baseAuthorityAppMapper.insert(authority); }
Example #7
Source File: RoleMenuService.java From spring-microservice-exam with MIT License | 6 votes |
/** * @param role role * @param menus 菜单ID集合 * @return int * @author tangyi * @date 2018/10/28 14:29 */ @Transactional @CacheEvict(value = "menu", allEntries = true) public int saveRoleMenus(Long role, List<Long> menus) { int update = -1; if (CollectionUtils.isNotEmpty(menus)) { // 删除旧的管理数据 roleMenuMapper.deleteByRoleId(role); List<RoleMenu> roleMenus = new ArrayList<>(); for (Long menuId : menus) { RoleMenu roleMenu = new RoleMenu(); roleMenu.setId(IdGen.snowflakeId()); roleMenu.setRoleId(role); roleMenu.setMenuId(menuId); roleMenus.add(roleMenu); } update = roleMenuMapper.insertBatch(roleMenus); } return update; }
Example #8
Source File: UserServiceImpl.java From sk-admin with Apache License 2.0 | 6 votes |
@Override @CacheEvict(allEntries = true) @Transactional(rollbackFor = Exception.class) public void updateAvatar(MultipartFile multipartFile) { User user = userRepository.findByUsername(SecurityUtils.getCurrentUsername()); UserAvatar userAvatar = user.getUserAvatar(); String oldPath = ""; if (userAvatar != null) { oldPath = userAvatar.getPath(); } File file = FileUtils.upload(multipartFile, properties.getPath().getAvatar()); assert file != null; userAvatar = userAvatarRepository.save(new UserAvatar(userAvatar, file.getName(), file.getPath(), FileUtils.getSize(multipartFile.getSize()))); user.setUserAvatar(userAvatar); userRepository.save(user); if (StringUtils.isNotBlank(oldPath)) { FileUtil.del(oldPath); } }
Example #9
Source File: UserServiceImpl.java From syhthems-platform with MIT License | 6 votes |
@Override @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @CacheEvict(cacheNames = "UserDetails", key = "'CustomUserDetailsServiceImpl:loadUserByUsername:(' + #user.getUsername() + ')'", cacheManager = "JDKCacheManager", condition = "#user != null && #user.getUsername() != null ") public int updateLogin(User user) { Assert.notNull(user, "用户不能为空"); User u = new User(); u.setUserId(user.getUserId()); if (BaseConstants.YES.equals(user.getFirstLogin())) { u.setFirstLogin(BaseConstants.NO); } BeanUtils.copyObjectVersionValue(user, u); u.setLastLoginTime(new Date()); return super.updateByPrimaryKeySelectiveWithVersion(u); }
Example #10
Source File: SysDictItemController.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * @功能:编辑 * @param sysDictItem * @return */ @RequestMapping(value = "/edit", method = RequestMethod.PUT) @CacheEvict(value=CacheConstant.SYS_DICT_CACHE, allEntries=true) public Result<SysDictItem> edit(@RequestBody SysDictItem sysDictItem) { Result<SysDictItem> result = new Result<SysDictItem>(); SysDictItem sysdict = sysDictItemService.getById(sysDictItem.getId()); if(sysdict==null) { result.error500("未找到对应实体"); }else { sysDictItem.setUpdateTime(new Date()); boolean ok = sysDictItemService.updateById(sysDictItem); //TODO 返回false说明什么? if(ok) { result.success("编辑成功!"); } } return result; }
Example #11
Source File: BaseAppServiceImpl.java From open-cloud with MIT License | 6 votes |
/** * 修改应用 * * @param app 应用 * @return 应用信息 */ @Caching(evict = { @CacheEvict(value = {"apps"}, key = "#app.appId"), @CacheEvict(value = {"apps"}, key = "'client:'+#app.appId") }) @Override public BaseApp updateInfo(BaseApp app) { app.setUpdateTime(new Date()); baseAppMapper.updateById(app); // 修改客户端附加信息 BaseApp appInfo = getAppInfo(app.getAppId()); Map info = BeanConvertUtils.objectToMap(appInfo); BaseClientDetails client = (BaseClientDetails) jdbcClientDetailsService.loadClientByClientId(appInfo.getApiKey()); client.setAdditionalInformation(info); jdbcClientDetailsService.updateClientDetails(client); return app; }
Example #12
Source File: SysMenuServiceImpl.java From smaker with GNU Lesser General Public License v3.0 | 6 votes |
@Override @Transactional(rollbackFor = Exception.class) @CacheEvict(value = "menu_details", allEntries = true) public SmakerResult removeMenuById(Integer id) { // 查询父节点为当前节点的节点 List<SysMenu> menuList = this.list(Wrappers.<SysMenu>query() .lambda().eq(SysMenu::getParentId, id)); if (CollUtil.isNotEmpty(menuList)) { return SmakerResult.builder() .code(CommonConstants.FAIL) .msg("菜单含有下级不能删除").build(); } sysRoleMenuMapper .delete(Wrappers.<SysRoleMenu>query() .lambda().eq(SysRoleMenu::getMenuId, id)); //删除当前菜单及其子菜单 return new SmakerResult(this.removeById(id)); }
Example #13
Source File: SysDictItemController.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * @功能:删除字典数据 * @param id * @return */ @RequestMapping(value = "/delete", method = RequestMethod.DELETE) @CacheEvict(value=CacheConstant.SYS_DICT_CACHE, allEntries=true) public Result<SysDictItem> delete(@RequestParam(name="id",required=true) String id) { Result<SysDictItem> result = new Result<SysDictItem>(); SysDictItem joinSystem = sysDictItemService.getById(id); if(joinSystem==null) { result.error500("未找到对应实体"); }else { boolean ok = sysDictItemService.removeById(id); if(ok) { result.success("删除成功!"); } } return result; }
Example #14
Source File: SysDepartController.java From teaching with Apache License 2.0 | 6 votes |
/** * 编辑数据 编辑部门的部分数据,并保存到数据库 * * @param sysDepart * @return */ @RequestMapping(value = "/edit", method = RequestMethod.PUT) @CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true) public Result<SysDepart> edit(@RequestBody SysDepart sysDepart, HttpServletRequest request) { String username = JwtUtil.getUserNameByToken(request); sysDepart.setUpdateBy(username); Result<SysDepart> result = new Result<SysDepart>(); SysDepart sysDepartEntity = sysDepartService.getById(sysDepart.getId()); if (sysDepartEntity == null) { result.error500("未找到对应实体"); } else { boolean ok = sysDepartService.updateDepartDataById(sysDepart, username); // TODO 返回false说明什么? if (ok) { //清除部门树内存 //FindsDepartsChildrenUtil.clearSysDepartTreeList(); //FindsDepartsChildrenUtil.clearDepartIdModel(); result.success("修改成功!"); } } return result; }
Example #15
Source File: SysDepartController.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * 通过id删除 * @param id * @return */ //@RequiresRoles({"admin"}) @RequestMapping(value = "/delete", method = RequestMethod.DELETE) @CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true) public Result<SysDepart> delete(@RequestParam(name="id",required=true) String id) { Result<SysDepart> result = new Result<SysDepart>(); SysDepart sysDepart = sysDepartService.getById(id); if(sysDepart==null) { result.error500("未找到对应实体"); }else { boolean ok = sysDepartService.delete(id); if(ok) { //清除部门树内存 //FindsDepartsChildrenUtil.clearSysDepartTreeList(); // FindsDepartsChildrenUtil.clearDepartIdModel(); result.success("删除成功!"); } } return result; }
Example #16
Source File: UserServiceImpl.java From sk-admin with Apache License 2.0 | 5 votes |
@Override @CacheEvict(allEntries = true) @Transactional(rollbackFor = Exception.class) public void updateCenter(User resources) { User user = userRepository.findById(resources.getId()).orElseGet(User::new); user.setNickName(resources.getNickName()); user.setPhone(resources.getPhone()); user.setSex(resources.getSex()); userRepository.save(user); }
Example #17
Source File: MenuServiceImpl.java From yshopmall with Apache License 2.0 | 5 votes |
@Override @CacheEvict(allEntries = true) public MenuDto create(Menu resources) { isExitHttp(resources); if(this.getOne(new QueryWrapper<Menu>().eq("name",resources.getName())) != null){ throw new EntityExistException(Menu.class,"name",resources.getName()); } if(StringUtils.isNotBlank(resources.getComponentName())){ if(this.getOne(new QueryWrapper<Menu>().eq("component_name",resources.getComponentName())) != null){ throw new EntityExistException(Menu.class,"componentName",resources.getComponentName()); } } this.save(resources); return generator.convert(resources,MenuDto.class); }
Example #18
Source File: BaseAuthorityServiceImpl.java From open-cloud with MIT License | 5 votes |
/** * 应用授权 * * @param appId 应用ID * @param expireTime 过期时间,null表示长期,不限制 * @param authorityIds 权限集合 * @return */ @CacheEvict(value = {"apps"}, key = "'client:'+#appId") @Override public void addAuthorityApp(String appId, Date expireTime, String... authorityIds) { if (appId == null) { return; } BaseApp baseApp = baseAppService.getAppInfo(appId); if (baseApp == null) { return; } // 清空应用已有授权 QueryWrapper<BaseAuthorityApp> appQueryWrapper = new QueryWrapper(); appQueryWrapper.lambda().eq(BaseAuthorityApp::getAppId, appId); baseAuthorityAppMapper.delete(appQueryWrapper); BaseAuthorityApp authority = null; if (authorityIds != null && authorityIds.length > 0) { for (String id : authorityIds) { authority = new BaseAuthorityApp(); authority.setAuthorityId(Long.parseLong(id)); authority.setAppId(appId); authority.setExpireTime(expireTime); authority.setCreateTime(new Date()); authority.setUpdateTime(authority.getCreateTime()); baseAuthorityAppMapper.insert(authority); } } // 获取应用最新的权限列表 List<OpenAuthority> authorities = findAuthorityByApp(appId); // 动态更新tokenStore客户端 OpenHelper.updateOpenClientAuthorities(redisTokenStore,baseApp.getApiKey(),authorities); }
Example #19
Source File: MenuServiceImpl.java From yshopmall with Apache License 2.0 | 5 votes |
/** * 编辑 * * @param resources / */ @Override @CacheEvict(allEntries = true) public void update(Menu resources) { if(resources.getId().equals(resources.getPid())) { throw new BadRequestException("上级不能为自己"); } Menu menu = this.getById(resources.getId()); ValidationUtil.isNull(menu.getId(),"Permission","id",resources.getId()); isExitHttp(resources); Menu menu1 = this.getOne(new QueryWrapper<Menu>().eq("name",resources.getName())); if(menu1 != null && !menu1.getId().equals(menu.getId())){ throw new EntityExistException(Menu.class,"name",resources.getName()); } if(StringUtils.isNotBlank(resources.getComponentName())){ menu1 = this.getOne(new QueryWrapper<Menu>().eq("component_name",resources.getComponentName())); if(menu1 != null && !menu1.getId().equals(menu.getId())){ throw new EntityExistException(Menu.class,"componentName",resources.getComponentName()); } } menu.setId(resources.getId()); menu.setName(resources.getName()); menu.setComponent(resources.getComponent()); menu.setPath(resources.getPath()); menu.setIcon(resources.getIcon()); menu.setIFrame(resources.getIFrame()); menu.setPid(resources.getPid()); menu.setSort(resources.getSort()); menu.setCache(resources.getCache()); menu.setHidden(resources.getHidden()); menu.setComponentName(resources.getComponentName()); menu.setPermission(resources.getPermission()); menu.setType(resources.getType()); this.saveOrUpdate(menu); }
Example #20
Source File: UserService.java From spring-microservice-exam with MIT License | 5 votes |
/** * 导入用户 * * @param userInfoDtos userInfoDtos * @return boolean * @author tangyi * @date 2019/07/04 12:46:01 */ @Transactional @CacheEvict(value = "user", allEntries = true) public boolean importUsers(List<UserInfoDto> userInfoDtos) { String currentUser = SysUtil.getUser(), applicationCode = SysUtil.getSysCode(), tenantCode = SysUtil.getTenantCode(); Date currentDate = DateUtils.asDate(LocalDateTime.now()); for (UserInfoDto userInfoDto : userInfoDtos) { User user = new User(); BeanUtils.copyProperties(userInfoDto, user); user.setModifier(currentUser); user.setModifyDate(currentDate); if (this.update(user) < 1) { user.setCommonValue(currentUser, applicationCode, tenantCode); user.setStatus(CommonConstant.STATUS_NORMAL); this.insert(user); } // 先删除用户授权信息 UserAuths userAuths = new UserAuths(); userAuths.setIdentifier(userInfoDto.getIdentifier()); // 默认密码 if (StringUtils.isBlank(userInfoDto.getCredential())) { userInfoDto.setCredential(encodeCredential(CommonConstant.DEFAULT_PASSWORD)); } userAuths.setCredential(userInfoDto.getCredential()); userAuths.setModifier(currentUser); userAuths.setModifyDate(currentDate); userAuths.setTenantCode(tenantCode); userAuthsService.deleteByIdentifier(userAuths); // 重新insert userAuths.setCommonValue(currentUser, applicationCode, tenantCode); userAuths.setUserId(user.getId()); userAuths.setIdentityType(userInfoDto.getIdentityType()); userAuthsService.insert(userAuths); } return true; }
Example #21
Source File: UserServiceImpl.java From sk-admin with Apache License 2.0 | 5 votes |
@Override @CacheEvict(allEntries = true) @Transactional(rollbackFor = Exception.class) public void update(User resources) { User user = userRepository.findById(resources.getId()).orElseGet(User::new); ValidationUtil.isNull(user.getId(), "User", "id", resources.getId()); User user1 = userRepository.findByUsername(resources.getUsername()); User user2 = userRepository.findByEmail(resources.getEmail()); if (user1 != null && !user.getId().equals(user1.getId())) { throw new EntityExistException(User.class, "username", resources.getUsername()); } if (user2 != null && !user.getId().equals(user2.getId())) { throw new EntityExistException(User.class, "email", resources.getEmail()); } // 如果用户的角色改变了,需要手动清理下缓存 if (!resources.getRoles().equals(user.getRoles())) { String key = "role::loadPermissionByUser:" + user.getUsername(); redisUtils.del(key); key = "role::findByUsers_Id:" + user.getId(); redisUtils.del(key); } user.setUsername(resources.getUsername()); user.setEmail(resources.getEmail()); user.setEnabled(resources.getEnabled()); user.setRoles(resources.getRoles()); user.setDept(resources.getDept()); user.setJob(resources.getJob()); user.setPhone(resources.getPhone()); user.setNickName(resources.getNickName()); user.setSex(resources.getSex()); userRepository.save(user); }
Example #22
Source File: SysDictItemController.java From jeecg-boot-with-activiti with MIT License | 5 votes |
/** * @功能:新增 * @param sysDict * @return */ @RequestMapping(value = "/add", method = RequestMethod.POST) @CacheEvict(value= CacheConstant.SYS_DICT_CACHE, allEntries=true) public Result<SysDictItem> add(@RequestBody SysDictItem sysDictItem) { Result<SysDictItem> result = new Result<SysDictItem>(); try { sysDictItem.setCreateTime(new Date()); sysDictItemService.save(sysDictItem); result.success("保存成功!"); } catch (Exception e) { log.error(e.getMessage(),e); result.error500("操作失败"); } return result; }
Example #23
Source File: StoreProductController.java From yshopmall with Apache License 2.0 | 5 votes |
@Log("删除商品") @ApiOperation(value = "删除商品") @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true) @DeleteMapping(value = "/yxStoreProduct/{id}") @PreAuthorize("@el.check('admin','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_DELETE')") public ResponseEntity delete(@PathVariable Integer id){ yxStoreProductService.delete(id); return new ResponseEntity(HttpStatus.OK); }
Example #24
Source File: SysDictController.java From jeecg-cloud with Apache License 2.0 | 5 votes |
/** * @功能:批量删除 * @param ids * @return */ //@RequiresRoles({"admin"}) @RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE) @CacheEvict(value= CacheConstant.SYS_DICT_CACHE, allEntries=true) public Result<SysDict> deleteBatch(@RequestParam(name="ids",required=true) String ids) { Result<SysDict> result = new Result<SysDict>(); if(oConvertUtils.isEmpty(ids)) { result.error500("参数不识别!"); }else { sysDictService.removeByIds(Arrays.asList(ids.split(","))); result.success("删除成功!"); } return result; }
Example #25
Source File: UserService.java From spring-microservice-exam with MIT License | 5 votes |
/** * 注册,注意要清除缓存 * * @param userDto userDto * @return boolean * @author tangyi * @date 2019/07/03 13:30:03 */ @Transactional @CacheEvict(value = "user", key = "#userDto.identifier") public boolean register(UserDto userDto) { boolean success = false; if (userDto.getIdentityType() == null) userDto.setIdentityType(IdentityType.PASSWORD.getValue()); // 解密 String password = this.decryptCredential(userDto.getCredential(), userDto.getIdentityType()); User user = new User(); BeanUtils.copyProperties(userDto, user); // 初始化用户名,系统编号,租户编号 user.setCommonValue(userDto.getIdentifier(), SysUtil.getSysCode(), SysUtil.getTenantCode()); user.setStatus(CommonConstant.DEL_FLAG_NORMAL); // 初始化头像 if (StringUtils.isNotBlank(userDto.getAvatarUrl())) { Attachment attachment = new Attachment(); attachment.setCommonValue(userDto.getIdentifier(), SysUtil.getSysCode(), SysUtil.getTenantCode()); attachment.setBusiType(AttachmentConstant.BUSI_TYPE_USER_AVATAR); attachment.setPreviewUrl(userDto.getAvatarUrl()); if (attachmentService.insert(attachment) > 0) user.setAvatarId(attachment.getId()); } // 保存用户基本信息 if (this.insert(user) > 0) { // 保存账号信息 UserAuths userAuths = new UserAuths(); userAuths.setCommonValue(userDto.getIdentifier(), user.getApplicationCode(), user.getTenantCode()); userAuths.setUserId(user.getId()); userAuths.setIdentifier(userDto.getIdentifier()); if (userDto.getIdentityType() != null) userAuths.setIdentityType(userDto.getIdentityType()); // 设置密码 userAuths.setCredential(encoder.encode(password)); userAuthsService.insert(userAuths); // 分配默认角色 success = this.defaultRole(user, userDto.getTenantCode(), userDto.getIdentifier()); } return success; }
Example #26
Source File: AttachmentService.java From spring-microservice-exam with MIT License | 5 votes |
/** * 根据id更新 * * @param attachment attachment * @return int */ @Override @Transactional @CacheEvict(value = {"attachment", "attachment_preview"}, key = "#attachment.id") public int update(Attachment attachment) { return super.update(attachment); }
Example #27
Source File: SubjectChoicesService.java From spring-microservice-exam with MIT License | 5 votes |
/** * 删除 * * @param subjectDto subjectDto * @return int * @author tangyi * @date 2019/06/16 17:50 */ @Override @Transactional @CacheEvict(value = "subjectChoices", key = "#subjectDto.id") public int deleteSubject(SubjectDto subjectDto) { SubjectChoices subjectChoices = new SubjectChoices(); BeanUtils.copyProperties(subjectDto, subjectChoices); return this.delete(subjectChoices); }
Example #28
Source File: OptionsServiceImpl.java From stone with GNU General Public License v3.0 | 5 votes |
/** * 批量保存设置 * * @param options options */ @Override @CacheEvict(value = POSTS_CACHE_NAME, allEntries = true, beforeInvocation = true) public void saveOptions(Map<String, String> options) { if (null != options && !options.isEmpty()) { options.forEach((k, v) -> saveOption(k, v)); } }
Example #29
Source File: StoreProductController.java From yshopmall with Apache License 2.0 | 5 votes |
@ApiOperation(value = "恢复数据") @CacheEvict(cacheNames = ShopConstants.YSHOP_REDIS_INDEX_KEY,allEntries = true) @DeleteMapping(value = "/yxStoreProduct/recovery/{id}") @PreAuthorize("@el.check('admin','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_DELETE')") public ResponseEntity recovery(@PathVariable Integer id){ yxStoreProductService.recovery(id); return new ResponseEntity(HttpStatus.OK); }
Example #30
Source File: DictServiceImpl.java From SpringBlade with Apache License 2.0 | 5 votes |
@Override @CacheEvict(cacheNames = {DICT_LIST, DICT_VALUE}, allEntries = true) public boolean submit(Dict dict) { LambdaQueryWrapper<Dict> lqw = Wrappers.<Dict>query().lambda().eq(Dict::getCode, dict.getCode()).eq(Dict::getDictKey, dict.getDictKey()); Integer cnt = baseMapper.selectCount((Func.isEmpty(dict.getId())) ? lqw : lqw.notIn(Dict::getId, dict.getId())); if (cnt > 0) { throw new ApiException("当前字典键值已存在!"); } return saveOrUpdate(dict); }