Java Code Examples for org.jeecg.common.system.vo.LoginUser

The following examples show how to use org.jeecg.common.system.vo.LoginUser. These examples are extracted from open source projects. 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 Project: jeecg-cloud   Source File: SysDepartController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 查询数据 查出我的部门,并以树结构数据格式响应给前端
 *
 * @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 2
Source Project: jeecg-cloud   Source File: SysDepartController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * <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 3
Source Project: jeecg-cloud   Source File: SysDepartController.java    License: Apache License 2.0 6 votes vote down vote up
/**
  * 导出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 4
Source Project: jeecg-cloud   Source File: SysRoleController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 导出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 5
Source Project: jeecg-cloud   Source File: SysAnnouncementController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 导出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 6
Source Project: jeecg-boot   Source File: SysAnnouncementSendController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @功能:获取我的消息
 * @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 7
Source Project: jeecg-cloud   Source File: SysUserController.java    License: Apache License 2.0 6 votes vote down vote up
/**
     *  查询当前用户的所有部门/当前部门编码
 * @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;
}
 
Example 8
Source Project: jeecg-cloud   Source File: SysCategoryController.java    License: Apache License 2.0 6 votes vote down vote up
/**
    * 导出excel
 *
 * @param request
 */
@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 9
Source Project: jeecg-cloud   Source File: SysAnnouncementSendController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @功能:更新用户系统消息阅读状态
 * @param json
 * @return
 */
@PutMapping(value = "/editByAnntIdAndUserId")
public Result<SysAnnouncementSend> editById(@RequestBody JSONObject json) {
	Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>();
	String anntId = json.getString("anntId");
	LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
	String userId = sysUser.getId();
	LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda();
	updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG);
	updateWrapper.set(SysAnnouncementSend::getReadTime, new Date());
	updateWrapper.last("where annt_id ='"+anntId+"' and user_id ='"+userId+"'");
	SysAnnouncementSend announcementSend = new SysAnnouncementSend();
	sysAnnouncementSendService.update(announcementSend, updateWrapper);
	result.setSuccess(true);
	return result;
}
 
Example 10
Source Project: jeecg-cloud   Source File: SysAnnouncementSendController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @功能:获取我的消息
 * @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 Project: jeecg-cloud   Source File: SysAnnouncementSendController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @功能:一键已读
 * @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 Project: jeecg-cloud   Source File: SysUserAgentController.java    License: Apache License 2.0 6 votes vote down vote up
/**
    * 导出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 13
Source Project: jeecg-cloud   Source File: JwtUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 根据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 14
Source Project: jeecg-boot-with-activiti   Source File: TokenUtils.java    License: MIT License 6 votes vote down vote up
/**
 * 验证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 15
Source Project: jeecg-boot   Source File: ShiroRealm.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 校验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 16
Source Project: teaching   Source File: SysAnnouncementSendController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @功能:获取我的消息
 * @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 17
Source Project: jeecg-boot-with-activiti   Source File: ShiroRealm.java    License: MIT License 6 votes vote down vote up
/**
 * 校验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 Project: jeecg-boot-with-activiti   Source File: SysRoleController.java    License: MIT License 6 votes vote down vote up
/**
 * 导出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 19
Source Project: jeecg-boot   Source File: NgAlainController.java    License: Apache License 2.0 6 votes vote down vote up
@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 20
Source Project: jeecg-boot-with-activiti   Source File: SysUserController.java    License: MIT License 6 votes vote down vote up
/**
   * 导出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 21
Source Project: jeecg-boot-with-activiti   Source File: SysCategoryController.java    License: MIT License 6 votes vote down vote up
/**
    * 导出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 22
/**
 * @功能:更新用户系统消息阅读状态
 * @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 23
/**
 * @功能:一键已读
 * @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 24
Source Project: jeecg-boot-with-activiti   Source File: SysUserAgentController.java    License: MIT License 6 votes vote down vote up
/**
    * 导出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 25
Source Project: teaching   Source File: SysUserAgentController.java    License: Apache License 2.0 6 votes vote down vote up
/**
    * 导出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 26
Source Project: jeecg-boot   Source File: SysAnnouncementSendController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @功能:更新用户系统消息阅读状态
 * @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 27
Source Project: teaching   Source File: SysAnnouncementSendController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @功能:更新用户系统消息阅读状态
 * @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 28
Source Project: teaching   Source File: NgAlainController.java    License: Apache License 2.0 6 votes vote down vote up
@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 29
Source Project: jeecg-boot   Source File: SysAnnouncementController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 导出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 30
Source Project: teaching   Source File: ShiroRealm.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 校验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;
}