Java Code Examples for org.jeecg.common.constant.CommonConstant#USER_IDENTITY_1

The following examples show how to use org.jeecg.common.constant.CommonConstant#USER_IDENTITY_1 . 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: SysUserController.java    From jeecg-cloud with Apache License 2.0 4 votes vote down vote up
/**
 * 部门用户列表
 */
@RequestMapping(value = "/departUserList", method = RequestMethod.GET)
public Result<IPage<SysUser>> departUserList(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                             @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) {
    Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
    Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
    String depId = req.getParameter("depId");
    String username = req.getParameter("username");
    //根据部门ID查询,当前和下级所有的部门IDS
    List<String> subDepids = new ArrayList<>();
    //部门id为空时,查询我的部门下所有用户
    if(oConvertUtils.isEmpty(depId)){
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        int userIdentity = user.getUserIdentity() != null?user.getUserIdentity():CommonConstant.USER_IDENTITY_1;
        if(oConvertUtils.isNotEmpty(userIdentity) && userIdentity == CommonConstant.USER_IDENTITY_2 ){
            subDepids = sysDepartService.getMySubDepIdsByDepId(user.getDepartIds());
        }
    }else{
        subDepids = sysDepartService.getSubDepIdsByDepId(depId);
    }
    if(subDepids != null && subDepids.size()>0){
        IPage<SysUser> pageList = sysUserService.getUserByDepIds(page,subDepids,username);
        //批量查询用户的所属部门
        //step.1 先拿到全部的 useids
        //step.2 通过 useids,一次性查询用户的所属部门名字
        List<String> userIds = pageList.getRecords().stream().map(SysUser::getId).collect(Collectors.toList());
        if(userIds!=null && userIds.size()>0){
            Map<String, String> useDepNames = sysUserService.getDepNamesByUserIds(userIds);
            pageList.getRecords().forEach(item -> {
                //批量查询用户的所属部门
                item.setOrgCode(useDepNames.get(item.getId()));
            });
        }
        result.setSuccess(true);
        result.setResult(pageList);
    }else{
        result.setSuccess(true);
        result.setResult(null);
    }
    return result;
}
 
Example 2
Source File: SysUserController.java    From teaching with Apache License 2.0 4 votes vote down vote up
/**
 * 部门用户列表
 */
@RequestMapping(value = "/departUserList", method = RequestMethod.GET)
public Result<IPage<SysUser>> departUserList(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                             @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) {
    Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
    Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
    String depId = req.getParameter("depId");
    String username = req.getParameter("username");
    //根据部门ID查询,当前和下级所有的部门IDS
    List<String> subDepids = new ArrayList<>();
    //部门id为空时,查询我的部门下所有用户
    if(oConvertUtils.isEmpty(depId)){
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        int userIdentity = user.getIdentity() != null?user.getIdentity():CommonConstant.USER_IDENTITY_1;
        if(oConvertUtils.isNotEmpty(userIdentity) && userIdentity == CommonConstant.USER_IDENTITY_2 ){
            subDepids = sysDepartService.getMySubDepIdsByDepId(user.getDepartIds());
        }
    }else{
        subDepids = sysDepartService.getSubDepIdsByDepId(depId);
    }
    if(subDepids != null && subDepids.size()>0){
        IPage<SysUser> pageList = sysUserService.getUserByDepIds(page,subDepids,username);
        //批量查询用户的所属部门
        //step.1 先拿到全部的 useids
        //step.2 通过 useids,一次性查询用户的所属部门名字
        List<String> userIds = pageList.getRecords().stream().map(SysUser::getId).collect(Collectors.toList());
        if(userIds!=null && userIds.size()>0){
            Map<String, String> useDepNames = sysUserService.getDepNamesByUserIds(userIds);
            pageList.getRecords().forEach(item -> {
                //批量查询用户的所属部门
                item.setOrgCode(useDepNames.get(item.getId()));
            });
        }
        result.setSuccess(true);
        result.setResult(pageList);
    }else{
        result.setSuccess(true);
        result.setResult(null);
    }
    return result;
}
 
Example 3
Source File: SysUserController.java    From jeecg-boot with Apache License 2.0 4 votes vote down vote up
/**
 * 部门用户列表
 */
@RequestMapping(value = "/departUserList", method = RequestMethod.GET)
public Result<IPage<SysUser>> departUserList(@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                             @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, HttpServletRequest req) {
    Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
    Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
    String depId = req.getParameter("depId");
    String username = req.getParameter("username");
    //根据部门ID查询,当前和下级所有的部门IDS
    List<String> subDepids = new ArrayList<>();
    //部门id为空时,查询我的部门下所有用户
    if(oConvertUtils.isEmpty(depId)){
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        int userIdentity = user.getUserIdentity() != null?user.getUserIdentity():CommonConstant.USER_IDENTITY_1;
        if(oConvertUtils.isNotEmpty(userIdentity) && userIdentity == CommonConstant.USER_IDENTITY_2 ){
            subDepids = sysDepartService.getMySubDepIdsByDepId(user.getDepartIds());
        }
    }else{
        subDepids = sysDepartService.getSubDepIdsByDepId(depId);
    }
    if(subDepids != null && subDepids.size()>0){
        IPage<SysUser> pageList = sysUserService.getUserByDepIds(page,subDepids,username);
        //批量查询用户的所属部门
        //step.1 先拿到全部的 useids
        //step.2 通过 useids,一次性查询用户的所属部门名字
        List<String> userIds = pageList.getRecords().stream().map(SysUser::getId).collect(Collectors.toList());
        if(userIds!=null && userIds.size()>0){
            Map<String, String> useDepNames = sysUserService.getDepNamesByUserIds(userIds);
            pageList.getRecords().forEach(item -> {
                //批量查询用户的所属部门
                item.setOrgCode(useDepNames.get(item.getId()));
            });
        }
        result.setSuccess(true);
        result.setResult(pageList);
    }else{
        result.setSuccess(true);
        result.setResult(null);
    }
    return result;
}