org.jeecg.common.system.vo.LoginUser Java Examples
The following examples show how to use
org.jeecg.common.system.vo.LoginUser.
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: SysUserAgentController.java From jeecg-cloud with Apache License 2.0 | 8 votes |
/** * 导出excel * * @param sysUserAgent * @param request */ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(SysUserAgent sysUserAgent,HttpServletRequest request) { // Step.1 组装查询条件 QueryWrapper<SysUserAgent> queryWrapper = QueryGenerator.initQueryWrapper(sysUserAgent, request.getParameterMap()); //Step.2 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); List<SysUserAgent> pageList = sysUserAgentService.list(queryWrapper); //导出文件名称 mv.addObject(NormalExcelConstants.FILE_NAME, "用户代理人设置列表"); mv.addObject(NormalExcelConstants.CLASS, SysUserAgent.class); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); ExportParams exportParams = new ExportParams("用户代理人设置列表数据", "导出人:"+user.getRealname(), "导出信息"); exportParams.setImageBasePath(upLoadPath); mv.addObject(NormalExcelConstants.PARAMS, exportParams); mv.addObject(NormalExcelConstants.DATA_LIST, pageList); return mv; }
Example #2
Source File: SysUserController.java From jeecg-boot with Apache License 2.0 | 8 votes |
/** * 导出excel * * @param request * @param response */ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(SysUser sysUser,HttpServletRequest request) { // Step.1 组装查询条件 QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(sysUser, request.getParameterMap()); //Step.2 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); //update-begin--Author:kangxiaolin Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据-------------------- String selections = request.getParameter("selections"); if(!oConvertUtils.isEmpty(selections)){ queryWrapper.in("id",selections.split(",")); } //update-end--Author:kangxiaolin Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据---------------------- List<SysUser> pageList = sysUserService.list(queryWrapper); //导出文件名称 mv.addObject(NormalExcelConstants.FILE_NAME, "用户列表"); mv.addObject(NormalExcelConstants.CLASS, SysUser.class); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); ExportParams exportParams = new ExportParams("用户列表数据", "导出人:"+user.getRealname(), "导出信息"); exportParams.setImageBasePath(upLoadPath); mv.addObject(NormalExcelConstants.PARAMS, exportParams); mv.addObject(NormalExcelConstants.DATA_LIST, pageList); return mv; }
Example #3
Source File: SysUserAgentController.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * 导出excel * * @param request * @param response */ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(SysUserAgent sysUserAgent,HttpServletRequest request) { // Step.1 组装查询条件 QueryWrapper<SysUserAgent> queryWrapper = QueryGenerator.initQueryWrapper(sysUserAgent, request.getParameterMap()); //Step.2 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); List<SysUserAgent> pageList = sysUserAgentService.list(queryWrapper); //导出文件名称 mv.addObject(NormalExcelConstants.FILE_NAME, "用户代理人设置列表"); mv.addObject(NormalExcelConstants.CLASS, SysUserAgent.class); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("用户代理人设置列表数据", "导出人:"+user.getRealname(), "导出信息")); mv.addObject(NormalExcelConstants.DATA_LIST, pageList); return mv; }
Example #4
Source File: SysDepartController.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * 导出excel * * @param request */ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(SysDepart sysDepart,HttpServletRequest request) { // Step.1 组装查询条件 QueryWrapper<SysDepart> queryWrapper = QueryGenerator.initQueryWrapper(sysDepart, request.getParameterMap()); //Step.2 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); List<SysDepart> pageList = sysDepartService.list(queryWrapper); //按字典排序 Collections.sort(pageList, new Comparator<SysDepart>() { @Override public int compare(SysDepart arg0, SysDepart arg1) { return arg0.getOrgCode().compareTo(arg1.getOrgCode()); } }); //导出文件名称 mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表"); mv.addObject(NormalExcelConstants.CLASS, SysDepart.class); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:"+user.getRealname(), "导出信息")); mv.addObject(NormalExcelConstants.DATA_LIST, pageList); return mv; }
Example #5
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 #6
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 #7
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 #8
Source File: TokenUtils.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * 验证Token */ public static boolean verifyToken(HttpServletRequest request, ISysBaseAPI sysBaseAPI, RedisUtil redisUtil) { String token = request.getParameter("token"); // 解密获得username,用于和数据库进行对比 String username = JwtUtil.getUsername(token); if (username == null) { throw new AuthenticationException("token非法无效!"); } // 查询用户信息 LoginUser user = sysBaseAPI.getUserByName(username); if (user == null) { throw new AuthenticationException("用户不存在!"); } // 判断用户状态 if (user.getStatus() != 1) { throw new AuthenticationException("账号已被锁定,请联系管理员!"); } // 校验token是否超时失效 & 或者账号密码是否错误 if (!jwtTokenRefresh(token, username, user.getPassword(), redisUtil)) { throw new AuthenticationException("Token失效,请重新登录!"); } return true; }
Example #9
Source File: ShiroRealm.java From jeecg-boot with Apache License 2.0 | 6 votes |
/** * 校验token的有效性 * * @param token */ public LoginUser checkUserTokenIsEffect(String token) throws AuthenticationException { // 解密获得username,用于和数据库进行对比 String username = JwtUtil.getUsername(token); if (username == null) { throw new AuthenticationException("token非法无效!"); } // 查询用户信息 log.debug("———校验token是否有效————checkUserTokenIsEffect——————— "+ token); LoginUser loginUser = sysBaseAPI.getUserByName(username); if (loginUser == null) { throw new AuthenticationException("用户不存在!"); } // 判断用户状态 if (loginUser.getStatus() != 1) { throw new AuthenticationException("账号已被锁定,请联系管理员!"); } // 校验token是否超时失效 & 或者账号密码是否错误 if (!jwtTokenRefresh(token, username, loginUser.getPassword())) { throw new AuthenticationException("Token失效,请重新登录!"); } return loginUser; }
Example #10
Source File: SysAnnouncementSendController.java From teaching with Apache License 2.0 | 6 votes |
/** * @功能:获取我的消息 * @return */ @GetMapping(value = "/getMyAnnouncementSend") public Result<IPage<AnnouncementSendModel>> getMyAnnouncementSend(AnnouncementSendModel announcementSendModel, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) { Result<IPage<AnnouncementSendModel>> result = new Result<IPage<AnnouncementSendModel>>(); LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); String userId = sysUser.getId(); announcementSendModel.setUserId(userId); announcementSendModel.setPageNo((pageNo-1)*pageSize); announcementSendModel.setPageSize(pageSize); Page<AnnouncementSendModel> pageList = new Page<AnnouncementSendModel>(pageNo,pageSize); pageList = sysAnnouncementSendService.getMyAnnouncementSendPage(pageList, announcementSendModel); result.setResult(pageList); result.setSuccess(true); return result; }
Example #11
Source File: SysRoleController.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * 导出excel * @param request * @param response */ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(SysRole sysRole,HttpServletRequest request) { // Step.1 组装查询条件 QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(sysRole, request.getParameterMap()); //Step.2 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); List<SysRole> pageList = sysRoleService.list(queryWrapper); //导出文件名称 mv.addObject(NormalExcelConstants.FILE_NAME,"角色列表"); mv.addObject(NormalExcelConstants.CLASS,SysRole.class); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); mv.addObject(NormalExcelConstants.PARAMS,new ExportParams("角色列表数据","导出人:"+user.getRealname(),"导出信息")); mv.addObject(NormalExcelConstants.DATA_LIST,pageList); return mv; }
Example #12
Source File: NgAlainController.java From jeecg-boot with Apache License 2.0 | 6 votes |
@RequestMapping(value = "/getAppData") @ResponseBody public JSONObject getAppData(HttpServletRequest request) throws Exception { String token=request.getHeader("X-Access-Token"); JSONObject j = new JSONObject(); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); JSONObject userObjcet = new JSONObject(); userObjcet.put("name", user.getUsername()); userObjcet.put("avatar", user.getAvatar()); userObjcet.put("email", user.getEmail()); userObjcet.put("token", token); j.put("user", userObjcet); j.put("menu",ngAlainService.getMenu(user.getUsername())); JSONObject app = new JSONObject(); app.put("name", "jeecg-boot-angular"); app.put("description", "jeecg+ng-alain整合版本"); j.put("app", app); return j; }
Example #13
Source File: SysUserController.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * 导出excel * * @param request * @param response */ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(SysUser sysUser,HttpServletRequest request) { // Step.1 组装查询条件 QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(sysUser, request.getParameterMap()); //Step.2 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); //update-begin--Author:kangxiaolin Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据-------------------- String selections = request.getParameter("selections"); if(!oConvertUtils.isEmpty(selections)){ queryWrapper.in("id",selections.split(",")); } //update-end--Author:kangxiaolin Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据---------------------- List<SysUser> pageList = sysUserService.list(queryWrapper); //导出文件名称 mv.addObject(NormalExcelConstants.FILE_NAME, "用户列表"); mv.addObject(NormalExcelConstants.CLASS, SysUser.class); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("用户列表数据", "导出人:"+user.getRealname(), "导出信息")); mv.addObject(NormalExcelConstants.DATA_LIST, pageList); return mv; }
Example #14
Source File: SysCategoryController.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * 导出excel * * @param request * @param response */ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(HttpServletRequest request, SysCategory sysCategory) { // Step.1 组装查询条件查询数据 QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, request.getParameterMap()); List<SysCategory> pageList = sysCategoryService.list(queryWrapper); // Step.2 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); // 过滤选中数据 String selections = request.getParameter("selections"); if(oConvertUtils.isEmpty(selections)) { mv.addObject(NormalExcelConstants.DATA_LIST, pageList); }else { List<String> selectionList = Arrays.asList(selections.split(",")); List<SysCategory> exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList()); mv.addObject(NormalExcelConstants.DATA_LIST, exportList); } //导出文件名称 mv.addObject(NormalExcelConstants.FILE_NAME, "分类字典列表"); mv.addObject(NormalExcelConstants.CLASS, SysCategory.class); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("分类字典列表数据", "导出人:"+user.getRealname(), "导出信息")); return mv; }
Example #15
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 #16
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 #17
Source File: ShiroRealm.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * 校验token的有效性 * * @param token */ public LoginUser checkUserTokenIsEffect(String token) throws AuthenticationException { // 解密获得username,用于和数据库进行对比 String username = JwtUtil.getUsername(token); if (username == null) { throw new AuthenticationException("token非法无效!"); } // 查询用户信息 log.info("———校验token是否有效————checkUserTokenIsEffect——————— "+ token); LoginUser loginUser = sysBaseAPI.getUserByName(username); if (loginUser == null) { throw new AuthenticationException("用户不存在!"); } // 判断用户状态 if (loginUser.getStatus() != 1) { throw new AuthenticationException("账号已被锁定,请联系管理员!"); } // 校验token是否超时失效 & 或者账号密码是否错误 if (!jwtTokenRefresh(token, username, loginUser.getPassword())) { throw new AuthenticationException("Token失效,请重新登录!"); } return loginUser; }
Example #18
Source File: SysUserAgentController.java From teaching with Apache License 2.0 | 6 votes |
/** * 导出excel * * @param request * @param response */ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(SysUserAgent sysUserAgent,HttpServletRequest request) { // Step.1 组装查询条件 QueryWrapper<SysUserAgent> queryWrapper = QueryGenerator.initQueryWrapper(sysUserAgent, request.getParameterMap()); //Step.2 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); List<SysUserAgent> pageList = sysUserAgentService.list(queryWrapper); //导出文件名称 mv.addObject(NormalExcelConstants.FILE_NAME, "用户代理人设置列表"); mv.addObject(NormalExcelConstants.CLASS, SysUserAgent.class); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("用户代理人设置列表数据", "导出人:"+user.getRealname(), "导出信息")); mv.addObject(NormalExcelConstants.DATA_LIST, pageList); return mv; }
Example #19
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 #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: NgAlainController.java From teaching with Apache License 2.0 | 6 votes |
@RequestMapping(value = "/getAppData") @ResponseBody public JSONObject getAppData(HttpServletRequest request) throws Exception { String token=request.getHeader("X-Access-Token"); JSONObject j = new JSONObject(); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); JSONObject userObjcet = new JSONObject(); userObjcet.put("name", user.getUsername()); userObjcet.put("avatar", user.getAvatar()); userObjcet.put("email", user.getEmail()); userObjcet.put("token", token); j.put("user", userObjcet); j.put("menu",ngAlainService.getMenu(user.getUsername())); JSONObject app = new JSONObject(); app.put("name", "jeecg-boot-angular"); app.put("description", "jeecg+ng-alain整合版本"); j.put("app", app); return j; }
Example #22
Source File: SysAnnouncementController.java From jeecg-boot with Apache License 2.0 | 6 votes |
/** * 导出excel * * @param request */ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(SysAnnouncement sysAnnouncement,HttpServletRequest request) { // Step.1 组装查询条件 QueryWrapper<SysAnnouncement> queryWrapper = QueryGenerator.initQueryWrapper(sysAnnouncement, request.getParameterMap()); //Step.2 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); List<SysAnnouncement> pageList = sysAnnouncementService.list(queryWrapper); //导出文件名称 mv.addObject(NormalExcelConstants.FILE_NAME, "系统通告列表"); mv.addObject(NormalExcelConstants.CLASS, SysAnnouncement.class); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("系统通告列表数据", "导出人:"+user.getRealname(), "导出信息")); mv.addObject(NormalExcelConstants.DATA_LIST, pageList); return mv; }
Example #23
Source File: ShiroRealm.java From teaching with Apache License 2.0 | 6 votes |
/** * 校验token的有效性 * * @param token */ public LoginUser checkUserTokenIsEffect(String token) throws AuthenticationException { // 解密获得username,用于和数据库进行对比 String username = JwtUtil.getUsername(token); if (username == null) { throw new AuthenticationException("token非法无效!"); } // 查询用户信息 log.info("———校验token是否有效————checkUserTokenIsEffect——————— "+ token); LoginUser loginUser = sysBaseAPI.getUserByName(username); if (loginUser == null) { throw new AuthenticationException("用户不存在!"); } // 判断用户状态 if (loginUser.getStatus() != 1) { throw new AuthenticationException("账号已被锁定,请联系管理员!"); } // 校验token是否超时失效 & 或者账号密码是否错误 if (!jwtTokenRefresh(token, username, loginUser.getPassword())) { throw new AuthenticationException("Token失效,请重新登录!"); } return loginUser; }
Example #24
Source File: TeachingCourseUnitController.java From teaching with Apache License 2.0 | 6 votes |
@GetMapping("getUnitWorkInfo") public Result<CourseUnitWorkModel> getUnitWorkInfo(@RequestParam String unitId) { Result<CourseUnitWorkModel> result = new Result<CourseUnitWorkModel>(); LoginUser user = getCurrentUser(); if (user == null){ //未登录 } CourseUnitWorkModel teachingCourseUnit = teachingCourseUnitService.getCourseWorkUnit(unitId, user.getId()); if(teachingCourseUnit==null) { result.error500("未找到对应实体"); }else { result.setResult(teachingCourseUnit); result.setSuccess(true); } return result; }
Example #25
Source File: SysDepartController.java From teaching with Apache License 2.0 | 6 votes |
/** * 查询数据 查出我的部门,并以树结构数据格式响应给前端 * * @return */ @RequestMapping(value = "/queryMyDeptTreeList", method = RequestMethod.GET) public Result<List<SysDepartTreeModel>> queryMyDeptTreeList() { Result<List<SysDepartTreeModel>> result = new Result<>(); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); try { if(oConvertUtils.isNotEmpty(user.getIdentity()) && user.getIdentity() == CommonConstant.USER_IDENTITY_2 ){ List<SysDepartTreeModel> list = sysDepartService.queryMyDeptTreeList(user.getDepartIds()); result.setResult(list); result.setMessage(CommonConstant.USER_IDENTITY_2.toString()); result.setSuccess(true); }else{ result.setMessage(CommonConstant.USER_IDENTITY_1.toString()); result.setSuccess(true); } } catch (Exception e) { log.error(e.getMessage(),e); } return result; }
Example #26
Source File: SysRoleController.java From teaching with Apache License 2.0 | 6 votes |
/** * 导出excel * @param request */ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(SysRole sysRole,HttpServletRequest request) { // Step.1 组装查询条件 QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(sysRole, request.getParameterMap()); //Step.2 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); List<SysRole> pageList = sysRoleService.list(queryWrapper); //导出文件名称 mv.addObject(NormalExcelConstants.FILE_NAME,"角色列表"); mv.addObject(NormalExcelConstants.CLASS,SysRole.class); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); mv.addObject(NormalExcelConstants.PARAMS,new ExportParams("角色列表数据","导出人:"+user.getRealname(),"导出信息")); mv.addObject(NormalExcelConstants.DATA_LIST,pageList); return mv; }
Example #27
Source File: SysDepartController.java From jeecg-boot with Apache License 2.0 | 6 votes |
/** * 查询数据 查出我的部门,并以树结构数据格式响应给前端 * * @return */ @RequestMapping(value = "/queryMyDeptTreeList", method = RequestMethod.GET) public Result<List<SysDepartTreeModel>> queryMyDeptTreeList() { Result<List<SysDepartTreeModel>> result = new Result<>(); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); try { if(oConvertUtils.isNotEmpty(user.getUserIdentity()) && user.getUserIdentity().equals( CommonConstant.USER_IDENTITY_2 )){ List<SysDepartTreeModel> list = sysDepartService.queryMyDeptTreeList(user.getDepartIds()); result.setResult(list); result.setMessage(CommonConstant.USER_IDENTITY_2.toString()); result.setSuccess(true); }else{ result.setMessage(CommonConstant.USER_IDENTITY_1.toString()); result.setSuccess(true); } } catch (Exception e) { log.error(e.getMessage(),e); } return result; }
Example #28
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 #29
Source File: SysUserController.java From teaching with Apache License 2.0 | 6 votes |
/** * 导出excel * * @param request * @param response */ @RequestMapping(value = "/exportXls") public ModelAndView exportXls(SysUser sysUser,HttpServletRequest request) { // Step.1 组装查询条件 QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(sysUser, request.getParameterMap()); //Step.2 AutoPoi 导出Excel ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); //update-begin--Author:kangxiaolin Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据-------------------- String selections = request.getParameter("selections"); if(!oConvertUtils.isEmpty(selections)){ queryWrapper.in("id",selections.split(",")); } //update-end--Author:kangxiaolin Date:20180825 for:[03]用户导出,如果选择数据则只导出相关数据---------------------- List<SysUser> pageList = sysUserService.list(queryWrapper); //导出文件名称 mv.addObject(NormalExcelConstants.FILE_NAME, "用户列表"); mv.addObject(NormalExcelConstants.CLASS, SysUser.class); LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("用户列表数据", "导出人:"+user.getRealname(), "导出信息")); mv.addObject(NormalExcelConstants.DATA_LIST, pageList); return mv; }
Example #30
Source File: SysUserController.java From teaching with Apache License 2.0 | 6 votes |
/** * 查询当前用户的所有部门/当前部门编码 * @return */ @RequestMapping(value = "/getCurrentUserDeparts", method = RequestMethod.GET) public Result<Map<String,Object>> getCurrentUserDeparts() { Result<Map<String,Object>> result = new Result<Map<String,Object>>(); try { LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); List<SysDepart> list = this.sysDepartService.queryUserDeparts(sysUser.getId()); Map<String,Object> map = new HashMap<String,Object>(); map.put("list", list); map.put("orgCode", sysUser.getOrgCode()); result.setSuccess(true); result.setResult(map); }catch(Exception e) { log.error(e.getMessage(), e); result.error500("查询失败!"); } return result; }