Search in sources :

Example 1 with SysUserCacheInfo

use of org.jeecg.common.system.vo.SysUserCacheInfo in project jeecg-boot by jeecgboot.

the class JimuReportTokenService method getUserInfo.

@Override
public Map<String, Object> getUserInfo(String token) {
    Map<String, Object> map = new HashMap<String, Object>();
    String username = JwtUtil.getUsername(token);
    // 此处通过token只能拿到一个信息 用户账号  后面的就是根据账号获取其他信息 查询数据或是走redis 用户根据自身业务可自定义
    SysUserCacheInfo userInfo = null;
    try {
        userInfo = sysBaseAPI.getCacheUser(username);
    } catch (Exception e) {
        log.error("获取用户信息异常:" + e.getMessage());
        return map;
    }
    // 设置账号名
    map.put(SYS_USER_CODE, userInfo.getSysUserCode());
    // 设置部门编码
    map.put(SYS_ORG_CODE, userInfo.getSysOrgCode());
    // 将所有信息存放至map 解析sql/api会根据map的键值解析
    return map;
}
Also used : HashMap(java.util.HashMap) SysUserCacheInfo(org.jeecg.common.system.vo.SysUserCacheInfo)

Example 2 with SysUserCacheInfo

use of org.jeecg.common.system.vo.SysUserCacheInfo in project kms by mahonelau.

the class SysUserServiceImpl method getCacheUser.

@Override
public SysUserCacheInfo getCacheUser(String username) {
    SysUserCacheInfo info = new SysUserCacheInfo();
    info.setOneDepart(true);
    // SysUser user = userMapper.getUserByName(username);
    // info.setSysUserCode(user.getUsername());
    // info.setSysUserName(user.getRealname());
    LoginUser user = sysBaseAPI.getUserByName(username);
    if (user != null) {
        info.setSysUserCode(user.getUsername());
        info.setSysUserName(user.getRealname());
        info.setSysOrgCode(user.getOrgCode());
    }
    // 多部门支持in查询
    List<SysDepart> list = sysDepartMapper.queryUserDeparts(user.getId());
    List<String> sysMultiOrgCode = new ArrayList<String>();
    if (list == null || list.size() == 0) {
    // 当前用户无部门
    // sysMultiOrgCode.add("0");
    } else if (list.size() == 1) {
        sysMultiOrgCode.add(list.get(0).getOrgCode());
    } else {
        info.setOneDepart(false);
        for (SysDepart dpt : list) {
            sysMultiOrgCode.add(dpt.getOrgCode());
        }
    }
    info.setSysMultiOrgCode(sysMultiOrgCode);
    return info;
}
Also used : SysUserCacheInfo(org.jeecg.common.system.vo.SysUserCacheInfo) LoginUser(org.jeecg.common.system.vo.LoginUser)

Example 3 with SysUserCacheInfo

use of org.jeecg.common.system.vo.SysUserCacheInfo in project kms by mahonelau.

the class PermissionDataAspect method arround.

@Around("pointCut()")
public Object arround(ProceedingJoinPoint point) throws Throwable {
    HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
    MethodSignature signature = (MethodSignature) point.getSignature();
    Method method = signature.getMethod();
    PermissionData pd = method.getAnnotation(PermissionData.class);
    String component = pd.pageComponent();
    String requestMethod = request.getMethod();
    String requestPath = request.getRequestURI().substring(request.getContextPath().length());
    requestPath = filterUrl(requestPath);
    log.debug("拦截请求 >> " + requestPath + ";请求类型 >> " + requestMethod);
    String username = JwtUtil.getUserNameByToken(request);
    // 查询数据权限信息
    // TODO 微服务情况下也得支持缓存机制
    List<SysPermissionDataRuleModel> dataRules = commonAPI.queryPermissionDataRule(component, requestPath, username);
    if (dataRules != null && dataRules.size() > 0) {
        // 临时存储
        JeecgDataAutorUtils.installDataSearchConditon(request, dataRules);
        // TODO 微服务情况下也得支持缓存机制
        SysUserCacheInfo userinfo = commonAPI.getCacheUser(username);
        JeecgDataAutorUtils.installUserInfo(request, userinfo);
    }
    return point.proceed();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SysPermissionDataRuleModel(org.jeecg.common.system.vo.SysPermissionDataRuleModel) MethodSignature(org.aspectj.lang.reflect.MethodSignature) SysUserCacheInfo(org.jeecg.common.system.vo.SysUserCacheInfo) Method(java.lang.reflect.Method) PermissionData(org.jeecg.common.aspect.annotation.PermissionData) Around(org.aspectj.lang.annotation.Around)

Example 4 with SysUserCacheInfo

use of org.jeecg.common.system.vo.SysUserCacheInfo in project jeecg-boot by jeecgboot.

the class SysUserServiceImpl method getCacheUser.

@Override
public SysUserCacheInfo getCacheUser(String username) {
    SysUserCacheInfo info = new SysUserCacheInfo();
    info.setOneDepart(true);
    // SysUser user = userMapper.getUserByName(username);
    // info.setSysUserCode(user.getUsername());
    // info.setSysUserName(user.getRealname());
    LoginUser user = sysBaseAPI.getUserByName(username);
    if (user != null) {
        info.setSysUserCode(user.getUsername());
        info.setSysUserName(user.getRealname());
        info.setSysOrgCode(user.getOrgCode());
    }
    // 多部门支持in查询
    List<SysDepart> list = sysDepartMapper.queryUserDeparts(user.getId());
    List<String> sysMultiOrgCode = new ArrayList<String>();
    if (list == null || list.size() == 0) {
    // 当前用户无部门
    // sysMultiOrgCode.add("0");
    } else if (list.size() == 1) {
        sysMultiOrgCode.add(list.get(0).getOrgCode());
    } else {
        info.setOneDepart(false);
        for (SysDepart dpt : list) {
            sysMultiOrgCode.add(dpt.getOrgCode());
        }
    }
    info.setSysMultiOrgCode(sysMultiOrgCode);
    return info;
}
Also used : SysUserCacheInfo(org.jeecg.common.system.vo.SysUserCacheInfo) LoginUser(org.jeecg.common.system.vo.LoginUser)

Example 5 with SysUserCacheInfo

use of org.jeecg.common.system.vo.SysUserCacheInfo in project jeecg-boot by jeecgboot.

the class PermissionDataAspect method arround.

@Around("pointCut()")
public Object arround(ProceedingJoinPoint point) throws Throwable {
    HttpServletRequest request = SpringContextUtils.getHttpServletRequest();
    MethodSignature signature = (MethodSignature) point.getSignature();
    Method method = signature.getMethod();
    PermissionData pd = method.getAnnotation(PermissionData.class);
    String component = pd.pageComponent();
    String requestMethod = request.getMethod();
    String requestPath = request.getRequestURI().substring(request.getContextPath().length());
    requestPath = filterUrl(requestPath);
    // TODO 参数顺序调整有隐患
    if (requestPath.indexOf(UrlMatchEnum.CGREPORT_DATA.getMatch_url()) >= 0) {
        // 获取地址栏参数
        String urlParamString = request.getParameter(CommonConstant.ONL_REP_URL_PARAM_STR);
        if (oConvertUtils.isNotEmpty(urlParamString)) {
            requestPath += "?" + urlParamString;
        }
    }
    // update-end-author:taoyan date:20211027 for:JTC-132【online报表权限】online报表带参数的菜单配置数据权限无效
    log.info("拦截请求 >> {} ; 请求类型 >> {} . ", requestPath, requestMethod);
    String username = JwtUtil.getUserNameByToken(request);
    // 查询数据权限信息
    // TODO 微服务情况下也得支持缓存机制
    List<SysPermissionDataRuleModel> dataRules = commonAPI.queryPermissionDataRule(component, requestPath, username);
    if (dataRules != null && dataRules.size() > 0) {
        // 临时存储
        JeecgDataAutorUtils.installDataSearchConditon(request, dataRules);
        // TODO 微服务情况下也得支持缓存机制
        SysUserCacheInfo userinfo = commonAPI.getCacheUser(username);
        JeecgDataAutorUtils.installUserInfo(request, userinfo);
    }
    return point.proceed();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SysPermissionDataRuleModel(org.jeecg.common.system.vo.SysPermissionDataRuleModel) MethodSignature(org.aspectj.lang.reflect.MethodSignature) SysUserCacheInfo(org.jeecg.common.system.vo.SysUserCacheInfo) Method(java.lang.reflect.Method) PermissionData(org.jeecg.common.aspect.annotation.PermissionData) Around(org.aspectj.lang.annotation.Around)

Aggregations

SysUserCacheInfo (org.jeecg.common.system.vo.SysUserCacheInfo)7 Method (java.lang.reflect.Method)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 Around (org.aspectj.lang.annotation.Around)3 MethodSignature (org.aspectj.lang.reflect.MethodSignature)3 PermissionData (org.jeecg.common.aspect.annotation.PermissionData)3 LoginUser (org.jeecg.common.system.vo.LoginUser)3 SysPermissionDataRuleModel (org.jeecg.common.system.vo.SysPermissionDataRuleModel)3 HashMap (java.util.HashMap)1