Search in sources :

Example 1 with SysPermissionDataRule

use of org.jeecg.modules.system.entity.SysPermissionDataRule in project jeecg-boot by jeecgboot.

the class SysDepartPermissionController method loadDatarule.

/**
 * 部门管理授权查询数据规则数据
 */
@GetMapping(value = "/datarule/{permissionId}/{departId}")
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId, @PathVariable("departId") String departId) {
    List<SysPermissionDataRule> list = sysPermissionDataRuleService.getPermRuleListByPermId(permissionId);
    if (list == null || list.size() == 0) {
        return Result.error("未找到权限配置信息");
    } else {
        Map<String, Object> map = new HashMap<>();
        map.put("datarule", list);
        LambdaQueryWrapper<SysDepartPermission> query = new LambdaQueryWrapper<SysDepartPermission>().eq(SysDepartPermission::getPermissionId, permissionId).eq(SysDepartPermission::getDepartId, departId);
        SysDepartPermission sysDepartPermission = sysDepartPermissionService.getOne(query);
        if (sysDepartPermission == null) {
        // return Result.error("未找到角色菜单配置信息");
        } else {
            String drChecked = sysDepartPermission.getDataRuleIds();
            if (oConvertUtils.isNotEmpty(drChecked)) {
                map.put("drChecked", drChecked.endsWith(",") ? drChecked.substring(0, drChecked.length() - 1) : drChecked);
            }
        }
        return Result.ok(map);
    // TODO 以后按钮权限的查询也走这个请求 无非在map中多加两个key
    }
}
Also used : SysDepartPermission(org.jeecg.modules.system.entity.SysDepartPermission) SysPermissionDataRule(org.jeecg.modules.system.entity.SysPermissionDataRule) JSONObject(com.alibaba.fastjson.JSONObject) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 2 with SysPermissionDataRule

use of org.jeecg.modules.system.entity.SysPermissionDataRule in project jeecg-boot by jeecgboot.

the class SysDepartPermissionServiceImpl method getPermRuleListByDeptIdAndPermId.

@Override
public List<SysPermissionDataRule> getPermRuleListByDeptIdAndPermId(String departId, String permissionId) {
    SysDepartPermission departPermission = this.getOne(new QueryWrapper<SysDepartPermission>().lambda().eq(SysDepartPermission::getDepartId, departId).eq(SysDepartPermission::getPermissionId, permissionId));
    if (departPermission != null && oConvertUtils.isNotEmpty(departPermission.getDataRuleIds())) {
        LambdaQueryWrapper<SysPermissionDataRule> query = new LambdaQueryWrapper<SysPermissionDataRule>();
        query.in(SysPermissionDataRule::getId, Arrays.asList(departPermission.getDataRuleIds().split(",")));
        query.orderByDesc(SysPermissionDataRule::getCreateTime);
        List<SysPermissionDataRule> permRuleList = this.ruleMapper.selectList(query);
        return permRuleList;
    } else {
        return null;
    }
}
Also used : SysDepartPermission(org.jeecg.modules.system.entity.SysDepartPermission) SysPermissionDataRule(org.jeecg.modules.system.entity.SysPermissionDataRule) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 3 with SysPermissionDataRule

use of org.jeecg.modules.system.entity.SysPermissionDataRule in project kykms by mahonelau.

the class SysDepartPermissionServiceImpl method getPermRuleListByDeptIdAndPermId.

@Override
public List<SysPermissionDataRule> getPermRuleListByDeptIdAndPermId(String departId, String permissionId) {
    SysDepartPermission departPermission = this.getOne(new QueryWrapper<SysDepartPermission>().lambda().eq(SysDepartPermission::getDepartId, departId).eq(SysDepartPermission::getPermissionId, permissionId));
    if (departPermission != null) {
        LambdaQueryWrapper<SysPermissionDataRule> query = new LambdaQueryWrapper<SysPermissionDataRule>();
        query.in(SysPermissionDataRule::getId, Arrays.asList(departPermission.getDataRuleIds().split(",")));
        query.orderByDesc(SysPermissionDataRule::getCreateTime);
        List<SysPermissionDataRule> permRuleList = this.ruleMapper.selectList(query);
        return permRuleList;
    } else {
        return null;
    }
}
Also used : SysDepartPermission(org.jeecg.modules.system.entity.SysDepartPermission) SysPermissionDataRule(org.jeecg.modules.system.entity.SysPermissionDataRule) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 4 with SysPermissionDataRule

use of org.jeecg.modules.system.entity.SysPermissionDataRule in project kykms by mahonelau.

the class SysPermissionDataRuleImpl method deletePermissionDataRule.

@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);
            }
        }
    }
}
Also used : SysPermissionDataRule(org.jeecg.modules.system.entity.SysPermissionDataRule) SysPermission(org.jeecg.modules.system.entity.SysPermission) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with SysPermissionDataRule

use of org.jeecg.modules.system.entity.SysPermissionDataRule in project kykms by mahonelau.

the class SysDepartPermissionController method loadDatarule.

/**
 * 部门管理授权查询数据规则数据
 */
@GetMapping(value = "/datarule/{permissionId}/{departId}")
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId, @PathVariable("departId") String departId) {
    List<SysPermissionDataRule> list = sysPermissionDataRuleService.getPermRuleListByPermId(permissionId);
    if (list == null || list.size() == 0) {
        return Result.error("未找到权限配置信息");
    } else {
        Map<String, Object> map = new HashMap<>();
        map.put("datarule", list);
        LambdaQueryWrapper<SysDepartPermission> query = new LambdaQueryWrapper<SysDepartPermission>().eq(SysDepartPermission::getPermissionId, permissionId).eq(SysDepartPermission::getDepartId, departId);
        SysDepartPermission sysDepartPermission = sysDepartPermissionService.getOne(query);
        if (sysDepartPermission == null) {
        // return Result.error("未找到角色菜单配置信息");
        } else {
            String drChecked = sysDepartPermission.getDataRuleIds();
            if (oConvertUtils.isNotEmpty(drChecked)) {
                map.put("drChecked", drChecked.endsWith(",") ? drChecked.substring(0, drChecked.length() - 1) : drChecked);
            }
        }
        return Result.ok(map);
    // TODO 以后按钮权限的查询也走这个请求 无非在map中多加两个key
    }
}
Also used : SysDepartPermission(org.jeecg.modules.system.entity.SysDepartPermission) SysPermissionDataRule(org.jeecg.modules.system.entity.SysPermissionDataRule) JSONObject(com.alibaba.fastjson.JSONObject) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Aggregations

SysPermissionDataRule (org.jeecg.modules.system.entity.SysPermissionDataRule)12 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)9 JSONObject (com.alibaba.fastjson.JSONObject)6 SysDepartPermission (org.jeecg.modules.system.entity.SysDepartPermission)6 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)3 HashMap (java.util.HashMap)3 SysPermission (org.jeecg.modules.system.entity.SysPermission)3 SysRolePermission (org.jeecg.modules.system.entity.SysRolePermission)3 Transactional (org.springframework.transaction.annotation.Transactional)3 GetMapping (org.springframework.web.bind.annotation.GetMapping)3