mirror of https://gitee.com/stylefeng/roses
【8.3.3】【role】更新删除角色分类的接口
parent
d77a6752d0
commit
1c5adea426
|
@ -2,6 +2,7 @@ package cn.stylefeng.roses.kernel.sys.modular.role.service.impl;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.db.api.DbOperatorApi;
|
||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||
import cn.stylefeng.roses.kernel.rule.pidset.CalcParentIdListUtil;
|
||||
import cn.stylefeng.roses.kernel.rule.pidset.callback.PidGetterService;
|
||||
|
@ -13,11 +14,14 @@ import cn.stylefeng.roses.kernel.sys.modular.role.mapper.RoleCategoryMapper;
|
|||
import cn.stylefeng.roses.kernel.sys.modular.role.pojo.request.RoleCategoryRequest;
|
||||
import cn.stylefeng.roses.kernel.sys.modular.role.service.RoleCategoryService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 角色分类业务实现层
|
||||
|
@ -28,6 +32,9 @@ import java.util.List;
|
|||
@Service
|
||||
public class RoleCategoryServiceImpl extends ServiceImpl<RoleCategoryMapper, RoleCategory> implements RoleCategoryService, PidGetterService {
|
||||
|
||||
@Resource
|
||||
private DbOperatorApi dbOperatorApi;
|
||||
|
||||
@Override
|
||||
public List<RoleCategory> treeList(RoleCategoryRequest roleCategoryRequest) {
|
||||
LambdaQueryWrapper<RoleCategory> wrapper = this.createWrapper(roleCategoryRequest);
|
||||
|
@ -53,8 +60,16 @@ public class RoleCategoryServiceImpl extends ServiceImpl<RoleCategoryMapper, Rol
|
|||
|
||||
@Override
|
||||
public void del(RoleCategoryRequest roleCategoryRequest) {
|
||||
RoleCategory roleCategory = this.queryRoleCategory(roleCategoryRequest);
|
||||
this.removeById(roleCategory.getId());
|
||||
Long treeId = roleCategoryRequest.getId();
|
||||
|
||||
// 获取所有的子级节点id
|
||||
Set<Long> childIdList = this.dbOperatorApi.findSubListByParentId("sys_role_category", "category_pids", "id", treeId);
|
||||
childIdList.add(treeId);
|
||||
|
||||
// 删除本节点 + 子节点
|
||||
LambdaUpdateWrapper<RoleCategory> wrapper = new LambdaUpdateWrapper<>();
|
||||
wrapper.in(RoleCategory::getId, childIdList);
|
||||
this.remove(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue