org.jeecg.common.constant.CommonConstant Java Examples
The following examples show how to use
org.jeecg.common.constant.CommonConstant.
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: SysPermissionDataRuleImpl.java From jeecg-boot-with-activiti with MIT License | 6 votes |
@Override @Transactional public void deletePermissionDataRule(String dataRuleId) { SysPermissionDataRule dataRule = this.baseMapper.selectById(dataRuleId); if(dataRule!=null) { this.removeById(dataRuleId); Integer count = this.baseMapper.selectCount(new LambdaQueryWrapper<SysPermissionDataRule>().eq(SysPermissionDataRule::getPermissionId, dataRule.getPermissionId())); //注:同一个事务中删除后再查询是会认为数据已被删除的 若事务回滚上述删除无效 if(count==null || count==0) { SysPermission permission = sysPermissionMapper.selectById(dataRule.getPermissionId()); if(permission!=null && permission.getRuleFlag().equals(CommonConstant.RULE_FLAG_1)) { permission.setRuleFlag(CommonConstant.RULE_FLAG_0); sysPermissionMapper.updateById(permission); } } } }
Example #2
Source File: SysPermissionDataRuleImpl.java From jeecg-boot-with-activiti with MIT License | 6 votes |
@Override public List<SysPermissionDataRule> queryPermissionDataRules(String username,String permissionId) { List<String> idsList = this.baseMapper.queryDataRuleIds(username, permissionId); if(idsList==null || idsList.size()==0 || idsList.get(0)==null ) { return null; } Set<String> set = new HashSet<String>(); for (String ids : idsList) { if(ids==null) { continue; } String[] arr = ids.split(","); for (String id : arr) { if(oConvertUtils.isNotEmpty(id)) { set.add(id); } } } if(set.size()==0) { return null; } return this.baseMapper.selectList(new QueryWrapper<SysPermissionDataRule>().in("id", set).eq("status",CommonConstant.STATUS_1)); }
Example #3
Source File: SysRoleController.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * 用户角色授权功能,查询菜单权限树 * @param request * @return */ @RequestMapping(value = "/queryTreeList", method = RequestMethod.GET) public Result<Map<String,Object>> queryTreeList(HttpServletRequest request) { Result<Map<String,Object>> result = new Result<>(); //全部权限ids List<String> ids = new ArrayList<>(); try { LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>(); query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0); query.orderByAsc(SysPermission::getSortNo); List<SysPermission> list = sysPermissionService.list(query); for(SysPermission sysPer : list) { ids.add(sysPer.getId()); } List<TreeModel> treeList = new ArrayList<>(); getTreeModelList(treeList, list, null); Map<String,Object> resMap = new HashMap<String,Object>(); resMap.put("treeList", treeList); //全部树节点数据 resMap.put("ids", ids);//全部树ids result.setResult(resMap); result.setSuccess(true); } catch (Exception e) { log.error(e.getMessage(), e); } return result; }
Example #4
Source File: QueryGenerator.java From jeecg-boot with Apache License 2.0 | 6 votes |
public static void doMultiFieldsOrder(QueryWrapper<?> queryWrapper,Map<String, String[]> parameterMap) { String column=null,order=null; if(parameterMap!=null&& parameterMap.containsKey(ORDER_COLUMN)) { column = parameterMap.get(ORDER_COLUMN)[0]; } if(parameterMap!=null&& parameterMap.containsKey(ORDER_TYPE)) { order = parameterMap.get(ORDER_TYPE)[0]; } log.debug("排序规则>>列:"+column+",排序方式:"+order); if (oConvertUtils.isNotEmpty(column) && oConvertUtils.isNotEmpty(order)) { //字典字段,去掉字典翻译文本后缀 if(column.endsWith(CommonConstant.DICT_TEXT_SUFFIX)) { column = column.substring(0, column.lastIndexOf(CommonConstant.DICT_TEXT_SUFFIX)); } //SQL注入check SqlInjectionUtil.filterContent(column); if (order.toUpperCase().indexOf(ORDER_TYPE_ASC)>=0) { queryWrapper.orderByAsc(oConvertUtils.camelToUnderline(column)); } else { queryWrapper.orderByDesc(oConvertUtils.camelToUnderline(column)); } } }
Example #5
Source File: SysPermissionController.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * 查询子菜单 * @param parentId * @return */ @RequestMapping(value = "/getSystemSubmenu", method = RequestMethod.GET) public Result<List<SysPermissionTree>> getSystemSubmenu(@RequestParam("parentId") String parentId){ Result<List<SysPermissionTree>> result = new Result<>(); try{ LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>(); query.eq(SysPermission::getParentId,parentId); query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0); query.orderByAsc(SysPermission::getSortNo); List<SysPermission> list = sysPermissionService.list(query); List<SysPermissionTree> sysPermissionTreeList = new ArrayList<SysPermissionTree>(); for(SysPermission sysPermission : list){ SysPermissionTree sysPermissionTree = new SysPermissionTree(sysPermission); sysPermissionTreeList.add(sysPermissionTree); } result.setResult(sysPermissionTreeList); result.setSuccess(true); }catch (Exception e){ log.error(e.getMessage(), e); } return result; }
Example #6
Source File: SysDepartController.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * <p> * 部门搜索功能方法,根据关键字模糊搜索相关部门 * </p> * * @param keyWord * @return */ @RequestMapping(value = "/searchBy", method = RequestMethod.GET) public Result<List<SysDepartTreeModel>> searchBy(@RequestParam(name = "keyWord", required = true) String keyWord,@RequestParam(name = "myDeptSearch", required = false) String myDeptSearch) { Result<List<SysDepartTreeModel>> result = new Result<List<SysDepartTreeModel>>(); //部门查询,myDeptSearch为1时为我的部门查询,登录用户为上级时查只查负责部门下数据 LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String departIds = null; if(oConvertUtils.isNotEmpty(user.getUserIdentity()) && user.getUserIdentity().equals( CommonConstant.USER_IDENTITY_2 )){ departIds = user.getDepartIds(); } List<SysDepartTreeModel> treeList = this.sysDepartService.searhBy(keyWord,myDeptSearch,departIds); if (treeList == null || treeList.size() == 0) { result.setSuccess(false); result.setMessage("未查询匹配数据!"); return result; } result.setResult(treeList); return result; }
Example #7
Source File: SysDepartServiceImpl.java From jeecg-cloud with Apache License 2.0 | 6 votes |
@Override public List<SysDepartTreeModel> queryMyDeptTreeList(String departIds) { //根据部门id获取所负责部门 LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>(); String[] codeArr = this.getMyDeptParentOrgCode(departIds); for(int i=0;i<codeArr.length;i++){ query.or().likeRight(SysDepart::getOrgCode,codeArr[i]); } query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); query.orderByAsc(SysDepart::getDepartOrder); //将父节点ParentId设为null List<SysDepart> listDepts = this.list(query); for(int i=0;i<codeArr.length;i++){ for(SysDepart dept : listDepts){ if(dept.getOrgCode().equals(codeArr[i])){ dept.setParentId(null); } } } // 调用wrapTreeDataToTreeList方法生成树状数据 List<SysDepartTreeModel> listResult = FindsDepartsChildrenUtil.wrapTreeDataToTreeList(listDepts); return listResult; }
Example #8
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 #9
Source File: SysPermissionServiceImpl.java From jeecg-boot 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 #10
Source File: TeachingUserController.java From teaching with Apache License 2.0 | 6 votes |
@RequestMapping(value = "/edit", method = RequestMethod.PUT) public Result<SysUser> edit(@RequestBody JSONObject jsonObject) { Result<SysUser> result = new Result<SysUser>(); try { SysUser sysUser = sysUserService.getById(jsonObject.getString("id")); sysBaseAPI.addLog("修改用户资料,id: " +jsonObject.getString("id") , CommonConstant.LOG_TYPE_2, 2); if(sysUser==null) { result.error500("未找到对应实体"); }else { SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class); user.setUpdateTime(new Date()); //String passwordEncode = PasswordUtil.encrypt(user.getUsername(), user.getPassword(), sysUser.getSalt()); user.setPassword(sysUser.getPassword()); sysUserService.updateById(user); result.success("修改成功!"); } } catch (Exception e) { log.error(e.getMessage(), e); result.error500("操作失败"); } return result; }
Example #11
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 #12
Source File: ThirdLoginController.java From jeecg-boot with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @RequestMapping(value = "/getLoginUser/{token}", method = RequestMethod.GET) @ResponseBody public Result<JSONObject> getLoginUser(@PathVariable("token") String token) throws Exception { Result<JSONObject> result = new Result<JSONObject>(); String username = JwtUtil.getUsername(token); //1. 校验用户是否有效 SysUser sysUser = sysUserService.getUserByName(username); result = sysUserService.checkUserIsEffective(sysUser); if(!result.isSuccess()) { return result; } JSONObject obj = new JSONObject(); //用户登录信息 obj.put("userInfo", sysUser); //token 信息 obj.put("token", token); result.setResult(obj); result.setSuccess(true); result.setCode(200); sysBaseAPI.addLog("用户名: " + username + ",登录成功[第三方用户]!", CommonConstant.LOG_TYPE_1, null); return result; }
Example #13
Source File: SysAnnouncementController.java From teaching with Apache License 2.0 | 6 votes |
/** * 批量删除 * @param ids * @return */ @RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE) public Result<SysAnnouncement> deleteBatch(@RequestParam(name="ids",required=true) String ids) { Result<SysAnnouncement> result = new Result<SysAnnouncement>(); if(ids==null || "".equals(ids.trim())) { result.error500("参数不识别!"); }else { String[] id = ids.split(","); for(int i=0;i<id.length;i++) { SysAnnouncement announcement = sysAnnouncementService.getById(id[i]); announcement.setDelFlag(CommonConstant.DEL_FLAG_1.toString()); sysAnnouncementService.updateById(announcement); } result.success("删除成功!"); } return result; }
Example #14
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 #15
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 #16
Source File: AutoLogAspect.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * 获取操作类型 */ private int getOperateType(String methodName,int operateType) { if (operateType > 0) { return operateType; } if (methodName.startsWith("list")) { return CommonConstant.OPERATE_TYPE_1; } if (methodName.startsWith("add")) { return CommonConstant.OPERATE_TYPE_2; } if (methodName.startsWith("edit")) { return CommonConstant.OPERATE_TYPE_3; } if (methodName.startsWith("delete")) { return CommonConstant.OPERATE_TYPE_4; } if (methodName.startsWith("import")) { return CommonConstant.OPERATE_TYPE_5; } if (methodName.startsWith("export")) { return CommonConstant.OPERATE_TYPE_6; } return CommonConstant.OPERATE_TYPE_1; }
Example #17
Source File: ShiroRealm.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * JWTToken刷新生命周期 (实现: 用户在线操作不掉线功能) * 1、登录成功后将用户的JWT生成的Token作为k、v存储到cache缓存里面(这时候k、v值一样),缓存有效期设置为Jwt有效时间的2倍 * 2、当该用户再次请求时,通过JWTFilter层层校验之后会进入到doGetAuthenticationInfo进行身份验证 * 3、当该用户这次请求jwt生成的token值已经超时,但该token对应cache中的k还是存在,则表示该用户一直在操作只是JWT的token失效了,程序会给token对应的k映射的v值重新生成JWTToken并覆盖v值,该缓存生命周期重新计算 * 4、当该用户这次请求jwt在生成的token值已经超时,并在cache中不存在对应的k,则表示该用户账户空闲超时,返回用户信息已失效,请重新登录。 * 注意: 前端请求Header中设置Authorization保持不变,校验有效性以缓存中的token为准。 * 用户过期时间 = Jwt有效时间 * 2。 * * @param userName * @param passWord * @return */ public boolean jwtTokenRefresh(String token, String userName, String passWord) { String cacheToken = String.valueOf(redisUtil.get(CommonConstant.PREFIX_USER_TOKEN + token)); if (oConvertUtils.isNotEmpty(cacheToken)) { // 校验token有效性 if (!JwtUtil.verify(cacheToken, userName, passWord)) { String newAuthorization = JwtUtil.sign(userName, passWord); // 设置超时时间 redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, newAuthorization); redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME *2 / 1000); log.info("——————————用户在线操作,更新token保证不掉线—————————jwtTokenRefresh——————— "+ token); } //update-begin--Author:scott Date:20191005 for:解决每次请求,都重写redis中 token缓存问题 // else { // // 设置超时时间 // redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, cacheToken); // redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000); // } //update-end--Author:scott Date:20191005 for:解决每次请求,都重写redis中 token缓存问题 return true; } return false; }
Example #18
Source File: SysUserServiceImpl.java From jeecg-boot with Apache License 2.0 | 6 votes |
/** * 校验用户是否有效 * @param sysUser * @return */ @Override public Result<?> checkUserIsEffective(SysUser sysUser) { Result<?> result = new Result<Object>(); //情况1:根据用户信息查询,该用户不存在 if (sysUser == null) { result.error500("该用户不存在,请注册"); sysBaseAPI.addLog("用户登录失败,用户不存在!", CommonConstant.LOG_TYPE_1, null); return result; } //情况2:根据用户信息查询,该用户已注销 if (CommonConstant.DEL_FLAG_1.toString().equals(sysUser.getDelFlag())) { sysBaseAPI.addLog("用户登录失败,用户名:" + sysUser.getUsername() + "已注销!", CommonConstant.LOG_TYPE_1, null); result.error500("该用户已注销"); return result; } //情况3:根据用户信息查询,该用户已冻结 if (CommonConstant.USER_FREEZE.equals(sysUser.getStatus())) { sysBaseAPI.addLog("用户登录失败,用户名:" + sysUser.getUsername() + "已冻结!", CommonConstant.LOG_TYPE_1, null); result.error500("该用户已冻结"); return result; } return result; }
Example #19
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 #20
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 #21
Source File: QueryGenerator.java From jeecg-boot-with-activiti with MIT License | 6 votes |
public static void doMultiFieldsOrder(QueryWrapper<?> queryWrapper,Map<String, String[]> parameterMap) { String column=null,order=null; if(parameterMap!=null&& parameterMap.containsKey(ORDER_COLUMN)) { column = parameterMap.get(ORDER_COLUMN)[0]; } if(parameterMap!=null&& parameterMap.containsKey(ORDER_TYPE)) { order = parameterMap.get(ORDER_TYPE)[0]; } log.debug("排序规则>>列:"+column+",排序方式:"+order); if (oConvertUtils.isNotEmpty(column) && oConvertUtils.isNotEmpty(order)) { //字典字段,去掉字典翻译文本后缀 if(column.endsWith(CommonConstant.DICT_TEXT_SUFFIX)) { column = column.substring(0, column.lastIndexOf(CommonConstant.DICT_TEXT_SUFFIX)); } //SQL注入check SqlInjectionUtil.filterContent(column); if (order.toUpperCase().indexOf(ORDER_TYPE_ASC)>=0) { queryWrapper.orderByAsc(oConvertUtils.camelToUnderline(column)); } else { queryWrapper.orderByDesc(oConvertUtils.camelToUnderline(column)); } } }
Example #22
Source File: TokenUtils.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * 刷新token(保证用户在线操作不掉线) * @param token * @param userName * @param passWord * @param redisUtil * @return */ private static boolean jwtTokenRefresh(String token, String userName, String passWord, RedisUtil redisUtil) { String cacheToken = String.valueOf(redisUtil.get(CommonConstant.PREFIX_USER_TOKEN + token)); if (oConvertUtils.isNotEmpty(cacheToken)) { // 校验token有效性 if (!JwtUtil.verify(cacheToken, userName, passWord)) { String newAuthorization = JwtUtil.sign(userName, passWord); // 设置Toekn缓存有效时间 redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, newAuthorization); redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000); } //update-begin--Author:scott Date:20191005 for:解决每次请求,都重写redis中 token缓存问题 // else { // redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, cacheToken); // // 设置超时时间 // redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000); // } //update-end--Author:scott Date:20191005 for:解决每次请求,都重写redis中 token缓存问题 return true; } return false; }
Example #23
Source File: TokenUtils.java From teaching with Apache License 2.0 | 6 votes |
/** * 刷新token(保证用户在线操作不掉线) * @param token * @param userName * @param passWord * @param redisUtil * @return */ private static boolean jwtTokenRefresh(String token, String userName, String passWord, RedisUtil redisUtil) { String cacheToken = String.valueOf(redisUtil.get(CommonConstant.PREFIX_USER_TOKEN + token)); if (oConvertUtils.isNotEmpty(cacheToken)) { // 校验token有效性 if (!JwtUtil.verify(cacheToken, userName, passWord)) { String newAuthorization = JwtUtil.sign(userName, passWord); // 设置Toekn缓存有效时间 redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, newAuthorization); redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000); } //update-begin--Author:scott Date:20191005 for:解决每次请求,都重写redis中 token缓存问题 // else { // redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, cacheToken); // // 设置超时时间 // redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000); // } //update-end--Author:scott Date:20191005 for:解决每次请求,都重写redis中 token缓存问题 return true; } return false; }
Example #24
Source File: SysAnnouncementServiceImpl.java From jeecg-boot with Apache License 2.0 | 6 votes |
@Transactional @Override public void saveAnnouncement(SysAnnouncement sysAnnouncement) { if(sysAnnouncement.getMsgType().equals(CommonConstant.MSG_TYPE_ALL)) { sysAnnouncementMapper.insert(sysAnnouncement); }else { // 1.插入通告表记录 sysAnnouncementMapper.insert(sysAnnouncement); // 2.插入用户通告阅读标记表记录 String userId = sysAnnouncement.getUserIds(); String[] userIds = userId.substring(0, (userId.length()-1)).split(","); String anntId = sysAnnouncement.getId(); Date refDate = new Date(); for(int i=0;i<userIds.length;i++) { SysAnnouncementSend announcementSend = new SysAnnouncementSend(); announcementSend.setAnntId(anntId); announcementSend.setUserId(userIds[i]); announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG); announcementSend.setReadTime(refDate); sysAnnouncementSendMapper.insert(announcementSend); } } }
Example #25
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 #26
Source File: SysRoleController.java From jeecg-boot with Apache License 2.0 | 6 votes |
/** * 用户角色授权功能,查询菜单权限树 * @param request * @return */ @RequestMapping(value = "/queryTreeList", method = RequestMethod.GET) public Result<Map<String,Object>> queryTreeList(HttpServletRequest request) { Result<Map<String,Object>> result = new Result<>(); //全部权限ids List<String> ids = new ArrayList<>(); try { LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>(); query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0); query.orderByAsc(SysPermission::getSortNo); List<SysPermission> list = sysPermissionService.list(query); for(SysPermission sysPer : list) { ids.add(sysPer.getId()); } List<TreeModel> treeList = new ArrayList<>(); getTreeModelList(treeList, list, null); Map<String,Object> resMap = new HashMap<String,Object>(); resMap.put("treeList", treeList); //全部树节点数据 resMap.put("ids", ids);//全部树ids result.setResult(resMap); result.setSuccess(true); } catch (Exception e) { log.error(e.getMessage(), e); } return result; }
Example #27
Source File: SysPermissionController.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * 查询子菜单 * @param parentId * @return */ @RequestMapping(value = "/getSystemSubmenu", method = RequestMethod.GET) public Result<List<SysPermissionTree>> getSystemSubmenu(@RequestParam("parentId") String parentId){ Result<List<SysPermissionTree>> result = new Result<>(); try{ LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>(); query.eq(SysPermission::getParentId,parentId); query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0); query.orderByAsc(SysPermission::getSortNo); List<SysPermission> list = sysPermissionService.list(query); List<SysPermissionTree> sysPermissionTreeList = new ArrayList<SysPermissionTree>(); for(SysPermission sysPermission : list){ SysPermissionTree sysPermissionTree = new SysPermissionTree(sysPermission); sysPermissionTreeList.add(sysPermissionTree); } result.setResult(sysPermissionTreeList); result.setSuccess(true); }catch (Exception e){ log.error(e.getMessage(), e); } return result; }
Example #28
Source File: ImportExcelUtil.java From jeecg-boot with Apache License 2.0 | 6 votes |
public static List<String> importDateSaveOne(Object obj, Class serviceClass,List<String> errorMessage,int i,String errorFlag) { IService bean =(IService) SpringContextUtils.getBean(serviceClass); try { boolean save = bean.save(obj); if(!save){ throw new Exception(errorFlag); } } catch (Exception e) { String message = e.getMessage(); int lineNumber = i + 1; // 通过索引名判断出错信息 if (message.contains(CommonConstant.SQL_INDEX_UNIQ_SYS_ROLE_CODE)) { errorMessage.add("第 " + lineNumber + " 行:角色编码已经存在,忽略导入。"); } else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_JOB_CLASS_NAME)) { errorMessage.add("第 " + lineNumber + " 行:任务类名已经存在,忽略导入。"); }else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_CODE)) { errorMessage.add("第 " + lineNumber + " 行:职务编码已经存在,忽略导入。"); }else if (message.contains(CommonConstant.SQL_INDEX_UNIQ_DEPART_ORG_CODE)) { errorMessage.add("第 " + lineNumber + " 行:部门编码已经存在,忽略导入。"); }else { errorMessage.add("第 " + lineNumber + " 行:未知错误,忽略导入"); log.error(e.getMessage(), e); } } return errorMessage; }
Example #29
Source File: SysUserController.java From teaching with Apache License 2.0 | 5 votes |
/** * 删除用户 */ @RequestMapping(value = "/delete", method = RequestMethod.DELETE) public Result<?> delete(@RequestParam(name="id",required=true) String id) { sysBaseAPI.addLog("删除用户,id: " +id ,CommonConstant.LOG_TYPE_2, 3); this.sysUserService.deleteUser(id); return Result.ok("删除用户成功"); }
Example #30
Source File: SysDepartServiceImpl.java From jeecg-cloud with Apache License 2.0 | 5 votes |
@Cacheable(value = CacheConstant.SYS_DEPART_IDS_CACHE) @Override public List<DepartIdModel> queryDepartIdTreeList() { LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>(); query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString()); query.orderByAsc(SysDepart::getDepartOrder); List<SysDepart> list = this.list(query); // 调用wrapTreeDataToTreeList方法生成树状数据 List<DepartIdModel> listResult = FindsDepartsChildrenUtil.wrapTreeDataToDepartIdTreeList(list); return listResult; }