org.jeecg.common.constant.CacheConstant Java Examples
The following examples show how to use
org.jeecg.common.constant.CacheConstant.
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: SysDictServiceImpl.java From teaching with Apache License 2.0 | 6 votes |
/** * 通过查询指定table的 text code 获取字典,包含text和value * dictTableCache采用redis缓存有效期10分钟 * @param table * @param text * @param code * @param keyArray * @return */ @Override @Cacheable(value = CacheConstant.SYS_DICT_TABLE_CACHE) public List<String> queryTableDictByKeys(String table, String text, String code, String[] keyArray) { List<DictModel> dicts = sysDictMapper.queryTableDictByKeys(table, text, code, keyArray); List<String> texts = new ArrayList<>(dicts.size()); // 查询出来的顺序可能是乱的,需要排个序 for (String key : keyArray) { for (DictModel dict : dicts) { if (key.equals(dict.getValue())) { texts.add(dict.getText()); break; } } } return texts; }
Example #2
Source File: SysDictItemController.java From jeecg-cloud with Apache License 2.0 | 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 #3
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 #4
Source File: JwtUtil.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * 根据request中的token获取用户信息 * * @return * @throws JeecgBootException */ public static LoginUser getLoginUser() throws JeecgBootException { HttpServletRequest request = SpringContextUtils.getHttpServletRequest(); if(request==null){ log.warn(" 非request方式访问!! "); return null; } String accessToken = request.getHeader("X-Access-Token"); if(oConvertUtils.isEmpty(accessToken)){ return null; } String username = getUsername(accessToken); if (oConvertUtils.isEmpty(username)) { throw new JeecgBootException("未获取到用户"); } RedisUtil redisUtil = SpringContextUtils.getApplicationContext().getBean(RedisUtil.class); LoginUser sysUser = (LoginUser) redisUtil.get(CacheConstant.SYS_USERS_CACHE_JWT +":" +username); return sysUser; }
Example #5
Source File: SysDepartController.java From teaching with Apache License 2.0 | 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 #6
Source File: LoginController.java From jeecg-boot with Apache License 2.0 | 6 votes |
/** * 退出登录 * @param request * @param response * @return */ @RequestMapping(value = "/logout") public Result<Object> logout(HttpServletRequest request,HttpServletResponse response) { //用户退出逻辑 String token = request.getHeader(DefContants.X_ACCESS_TOKEN); if(oConvertUtils.isEmpty(token)) { return Result.error("退出登录失败!"); } String username = JwtUtil.getUsername(token); LoginUser sysUser = sysBaseAPI.getUserByName(username); if(sysUser!=null) { sysBaseAPI.addLog("用户名: "+sysUser.getRealname()+",退出成功!", CommonConstant.LOG_TYPE_1, null); log.info(" 用户名: "+sysUser.getRealname()+",退出成功! "); //清空用户登录Token缓存 redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + token); //清空用户登录Shiro权限缓存 redisUtil.del(CommonConstant.PREFIX_USER_SHIRO_CACHE + sysUser.getId()); //清空用户的缓存信息(包括部门信息),例如sys:cache:user::<username> redisUtil.del(String.format("%s::%s", CacheConstant.SYS_USERS_CACHE, sysUser.getUsername())); //调用shiro的logout SecurityUtils.getSubject().logout(); return Result.ok("退出登录成功!"); }else { return Result.error("Token无效!"); } }
Example #7
Source File: LoginController.java From teaching with Apache License 2.0 | 6 votes |
/** * 退出登录 * @param request * @param response * @return */ @RequestMapping(value = "/logout") public Result<Object> logout(HttpServletRequest request,HttpServletResponse response) { //用户退出逻辑 String token = request.getHeader(DefContants.X_ACCESS_TOKEN); if(oConvertUtils.isEmpty(token)) { return Result.error("退出登录失败!"); } String username = JwtUtil.getUsername(token); LoginUser sysUser = sysBaseAPI.getUserByName(username); if(sysUser!=null) { sysBaseAPI.addLog("用户名: "+sysUser.getRealname()+",退出成功!", CommonConstant.LOG_TYPE_1, null); log.info(" 用户名: "+sysUser.getRealname()+",退出成功! "); //清空用户登录Token缓存 redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + token); //清空用户登录Shiro权限缓存 redisUtil.del(CommonConstant.PREFIX_USER_SHIRO_CACHE + sysUser.getId()); //清空用户的缓存信息(包括部门信息),例如sys:cache:user::<username> redisUtil.del(String.format("%s::%s", CacheConstant.SYS_USERS_CACHE, sysUser.getUsername())); //调用shiro的logout SecurityUtils.getSubject().logout(); return Result.ok("退出登录成功!"); }else { return Result.error("Token无效!"); } }
Example #8
Source File: SysDepartController.java From jeecg-boot-with-activiti with MIT License | 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 #9
Source File: SysPermissionServiceImpl.java From teaching with Apache License 2.0 | 6 votes |
/** * 逻辑删除 */ @Override @CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true) //@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true,condition="#sysPermission.menuType==2") public void deletePermissionLogical(String id) throws JeecgBootException { SysPermission sysPermission = this.getById(id); if(sysPermission==null) { throw new JeecgBootException("未找到菜单信息"); } String pid = sysPermission.getParentId(); int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid)); if(count==1) { //若父节点无其他子节点,则该父节点是叶子节点 this.sysPermissionMapper.setMenuLeaf(pid, 1); } sysPermission.setDelFlag(1); this.updateById(sysPermission); }
Example #10
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 #11
Source File: SysPermissionServiceImpl.java From teaching with Apache License 2.0 | 6 votes |
/** * 真实删除 */ @Override @Transactional @CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true) public void deletePermission(String id) throws JeecgBootException { SysPermission sysPermission = this.getById(id); if(sysPermission==null) { throw new JeecgBootException("未找到菜单信息"); } String pid = sysPermission.getParentId(); if(oConvertUtils.isNotEmpty(pid)) { int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid)); if(count==1) { //若父节点无其他子节点,则该父节点是叶子节点 this.sysPermissionMapper.setMenuLeaf(pid, 1); } } sysPermissionMapper.deleteById(id); // 该节点可能是子节点但也可能是其它节点的父节点,所以需要级联删除 this.removeChildrenBy(sysPermission.getId()); }
Example #12
Source File: SysDepartController.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * 编辑数据 编辑部门的部分数据,并保存到数据库 * * @param sysDepart * @return */ //@RequiresRoles({"admin"}) @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 #13
Source File: SysDepartController.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * 添加新数据 添加用户新建的部门对象数据,并保存到数据库 * * @param sysDepart * @return */ //@RequiresRoles({"admin"}) @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 #14
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 #15
Source File: SysDictItemController.java From jeecg-boot with Apache License 2.0 | 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 #16
Source File: SysDepartController.java From jeecg-boot with Apache License 2.0 | 6 votes |
/** * 添加新数据 添加用户新建的部门对象数据,并保存到数据库 * * @param sysDepart * @return */ //@RequiresRoles({"admin"}) @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 #17
Source File: SysDepartController.java From jeecg-boot 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 #18
Source File: SysPermissionServiceImpl.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * 逻辑删除 */ @Override @CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true) //@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true,condition="#sysPermission.menuType==2") public void deletePermissionLogical(String id) throws JeecgBootException { SysPermission sysPermission = this.getById(id); if(sysPermission==null) { throw new JeecgBootException("未找到菜单信息"); } String pid = sysPermission.getParentId(); int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid)); if(count==1) { //若父节点无其他子节点,则该父节点是叶子节点 this.sysPermissionMapper.setMenuLeaf(pid, 1); } sysPermission.setDelFlag(1); this.updateById(sysPermission); }
Example #19
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 #20
Source File: SysDictItemController.java From jeecg-boot 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 #21
Source File: SysDepartController.java From jeecg-boot with Apache License 2.0 | 6 votes |
/** * 编辑数据 编辑部门的部分数据,并保存到数据库 * * @param sysDepart * @return */ //@RequiresRoles({"admin"}) @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 #22
Source File: SysDictServiceImpl.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * 通过查询指定table的 text code 获取字典,包含text和value * dictTableCache采用redis缓存有效期10分钟 * @param table * @param text * @param code * @param keyArray * @return */ @Override @Cacheable(value = CacheConstant.SYS_DICT_TABLE_CACHE) public List<String> queryTableDictByKeys(String table, String text, String code, String[] keyArray) { List<DictModel> dicts = sysDictMapper.queryTableDictByKeys(table, text, code, keyArray); List<String> texts = new ArrayList<>(dicts.size()); // 查询出来的顺序可能是乱的,需要排个序 for (String key : keyArray) { for (DictModel dict : dicts) { if (key.equals(dict.getValue())) { texts.add(dict.getText()); break; } } } return texts; }
Example #23
Source File: SysDictServiceImpl.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * 通过查询指定table的 text code 获取字典,包含text和value * dictTableCache采用redis缓存有效期10分钟 * @param table * @param text * @param code * @param keyArray * @return */ @Override @Cacheable(value = CacheConstant.SYS_DICT_TABLE_CACHE) public List<String> queryTableDictByKeys(String table, String text, String code, String[] keyArray) { List<DictModel> dicts = sysDictMapper.queryTableDictByKeys(table, text, code, keyArray); List<String> texts = new ArrayList<>(dicts.size()); // 查询出来的顺序可能是乱的,需要排个序 for (String key : keyArray) { for (DictModel dict : dicts) { if (key.equals(dict.getValue())) { texts.add(dict.getText()); break; } } } return texts; }
Example #24
Source File: SysPermissionServiceImpl.java From teaching 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 #25
Source File: SysUserServiceImpl.java From jeecg-boot-with-activiti with MIT License | 6 votes |
@Override @CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true) @Transactional(rollbackFor = Exception.class) public boolean deleteBatchUsers(String userIds) { //1.删除用户 this.removeByIds(Arrays.asList(userIds.split(","))); //2.删除用户部门关系 LambdaQueryWrapper<SysUserDepart> query = new LambdaQueryWrapper<SysUserDepart>(); for(String id : userIds.split(",")) { query.eq(SysUserDepart::getUserId, id); this.sysUserDepartMapper.delete(query); } //3.删除用户角色关系 //TODO return false; }
Example #26
Source File: SysGatewayRouteServiceImpl.java From jeecg-cloud with Apache License 2.0 | 6 votes |
@Override public void updateAll(JSONArray array) { this.remove(new LambdaQueryWrapper<SysGatewayRoute>().eq(SysGatewayRoute::getStatus,1)); List<SysGatewayRoute> ls = new ArrayList<>(); for(int i =0;i<array.size();i++){ JSONObject json = array.getJSONObject(i); SysGatewayRoute route = new SysGatewayRoute(); route.setId(json.getString("id")); route.setName(json.getString("name")); route.setPredicates(json.getString("predicates")); route.setFilters(json.getString("filters")); route.setUri(json.getString("uri")); if(json.get("status")==null){ route.setStatus(1); }else{ route.setStatus(json.getInteger("status")); } ls.add(route); } this.saveBatch(ls); redisTemplate.opsForValue().set(CacheConstant.GATEWAY_ROUTES, JSON.toJSONString(ls)); }
Example #27
Source File: SysDictServiceImpl.java From jeecg-boot with Apache License 2.0 | 6 votes |
/** * 通过查询指定table的 text code 获取字典,包含text和value * dictTableCache采用redis缓存有效期10分钟 * @param table * @param text * @param code * @param keyArray * @return */ @Override @Cacheable(value = CacheConstant.SYS_DICT_TABLE_CACHE) public List<String> queryTableDictByKeys(String table, String text, String code, String[] keyArray) { List<DictModel> dicts = sysDictMapper.queryTableDictByKeys(table, text, code, keyArray); List<String> texts = new ArrayList<>(dicts.size()); // 查询出来的顺序可能是乱的,需要排个序 for (String key : keyArray) { for (DictModel dict : dicts) { if (key.equals(dict.getValue())) { texts.add(dict.getText()); break; } } } return texts; }
Example #28
Source File: SysUserServiceImpl.java From jeecg-cloud with Apache License 2.0 | 6 votes |
@Override @CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true) public Result<?> resetPassword(String username, String oldpassword, String newpassword, String confirmpassword) { SysUser user = userMapper.getUserByName(username); String passwordEncode = PasswordUtil.encrypt(username, oldpassword, user.getSalt()); if (!user.getPassword().equals(passwordEncode)) { return Result.error("旧密码输入错误!"); } if (oConvertUtils.isEmpty(newpassword)) { return Result.error("新密码不允许为空!"); } if (!newpassword.equals(confirmpassword)) { return Result.error("两次输入密码不一致!"); } String password = PasswordUtil.encrypt(username, newpassword, user.getSalt()); this.userMapper.update(new SysUser().setPassword(password), new LambdaQueryWrapper<SysUser>().eq(SysUser::getId, user.getId())); return Result.ok("密码重置成功!"); }
Example #29
Source File: SysDictController.java From teaching with Apache License 2.0 | 5 votes |
/** * @功能:批量删除 * @param ids * @return */ @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 #30
Source File: SysDictController.java From jeecg-boot-with-activiti with MIT License | 5 votes |
/** * @功能:删除 * @param id * @return */ @RequestMapping(value = "/delete", method = RequestMethod.DELETE) @CacheEvict(value=CacheConstant.SYS_DICT_CACHE, allEntries=true) public Result<SysDict> delete(@RequestParam(name="id",required=true) String id) { Result<SysDict> result = new Result<SysDict>(); boolean ok = sysDictService.removeById(id); if(ok) { result.success("删除成功!"); }else{ result.error500("删除失败!"); } return result; }