use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project jeecg-boot by jeecgboot.
the class SysPermissionServiceImpl method removeChildrenBy.
/**
* 根据父id删除其关联的子节点数据
*
* @return
*/
public void removeChildrenBy(String parentId) {
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<>();
// 封装查询条件parentId为主键,
query.eq(SysPermission::getParentId, parentId);
// 查出该主键下的所有子级
List<SysPermission> permissionList = this.list(query);
if (permissionList != null && permissionList.size() > 0) {
// id
String id = "";
// 查出的子级数量
int num = 0;
// 如果查出的集合不为空, 则先删除所有
this.remove(query);
// 再遍历刚才查出的集合, 根据每个对象,查找其是否仍有子级
for (int i = 0, len = permissionList.size(); i < len; i++) {
id = permissionList.get(i).getId();
Map map = new HashMap<>();
map.put("permission_id", id);
// 删除数据规则
this.deletePermRuleByPermId(id);
// 删除角色授权表
sysRolePermissionMapper.deleteByMap(map);
// 删除部门权限表
sysDepartPermissionMapper.deleteByMap(map);
// 删除部门角色授权
sysDepartRolePermissionMapper.deleteByMap(map);
num = this.count(new LambdaQueryWrapper<SysPermission>().eq(SysPermission::getParentId, id));
// 如果有, 则递归
if (num > 0) {
this.removeChildrenBy(id);
}
}
}
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project RuoYi-Flowable-Plus by KonBAI-Q.
the class SysConfigServiceImpl method checkConfigKeyUnique.
/**
* 校验参数键名是否唯一
*
* @param config 参数配置信息
* @return 结果
*/
@Override
public String checkConfigKeyUnique(SysConfig config) {
Long configId = ObjectUtil.isNull(config.getConfigId()) ? -1L : config.getConfigId();
SysConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getConfigKey, config.getConfigKey()));
if (ObjectUtil.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project RuoYi-Flowable-Plus by KonBAI-Q.
the class SysDeptServiceImpl method updateDeptChildren.
/**
* 修改子元素关系
*
* @param deptId 被修改的部门ID
* @param newAncestors 新的父ID集合
* @param oldAncestors 旧的父ID集合
*/
public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) {
List<SysDept> children = baseMapper.selectList(new LambdaQueryWrapper<SysDept>().apply(DataBaseHelper.findInSet(deptId, "ancestors")));
List<SysDept> list = new ArrayList<>();
for (SysDept child : children) {
SysDept dept = new SysDept();
dept.setDeptId(child.getDeptId());
dept.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
list.add(dept);
}
if (list.size() > 0) {
baseMapper.updateBatchById(list);
}
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project RuoYi-Flowable-Plus by KonBAI-Q.
the class SysDictTypeServiceImpl method deleteDictTypeByIds.
/**
* 批量删除字典类型信息
*
* @param dictIds 需要删除的字典ID
*/
@Override
public void deleteDictTypeByIds(Long[] dictIds) {
for (Long dictId : dictIds) {
SysDictType dictType = selectDictTypeById(dictId);
if (dictDataMapper.exists(new LambdaQueryWrapper<SysDictData>().eq(SysDictData::getDictType, dictType.getDictType()))) {
throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
}
RedisUtils.deleteObject(getCacheKey(dictType.getDictType()));
}
baseMapper.deleteBatchIds(Arrays.asList(dictIds));
}
use of com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper in project RuoYi-Flowable-Plus by KonBAI-Q.
the class SysUserServiceImpl method deleteUserByIds.
/**
* 批量删除用户信息
*
* @param userIds 需要删除的用户ID
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int deleteUserByIds(Long[] userIds) {
for (Long userId : userIds) {
checkUserAllowed(new SysUser(userId));
checkUserDataScope(userId);
}
List<Long> ids = Arrays.asList(userIds);
// 删除用户与角色关联
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getUserId, ids));
// 删除用户与岗位表
userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().in(SysUserPost::getUserId, ids));
return baseMapper.deleteBatchIds(ids);
}
Aggregations