mirror of https://gitee.com/stylefeng/roses
【8.3.3】【role】更新修改角色分类的接口
parent
1c5adea426
commit
d4fa4dd268
|
@ -18,6 +18,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -73,10 +74,25 @@ public class RoleCategoryServiceImpl extends ServiceImpl<RoleCategoryMapper, Rol
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void edit(RoleCategoryRequest roleCategoryRequest) {
|
public void edit(RoleCategoryRequest roleCategoryRequest) {
|
||||||
RoleCategory roleCategory = this.queryRoleCategory(roleCategoryRequest);
|
RoleCategory oldCategory = this.queryRoleCategory(roleCategoryRequest);
|
||||||
BeanUtil.copyProperties(roleCategoryRequest, roleCategory);
|
|
||||||
this.updateById(roleCategory);
|
RoleCategory newRoleCategory = new RoleCategory();
|
||||||
|
BeanUtil.copyProperties(oldCategory, newRoleCategory);
|
||||||
|
BeanUtil.copyProperties(roleCategoryRequest, newRoleCategory);
|
||||||
|
|
||||||
|
// 如果改了层级结构,则递归更新子结构
|
||||||
|
if (!oldCategory.getCategoryParentId().equals(newRoleCategory.getCategoryParentId())) {
|
||||||
|
|
||||||
|
// 设置文件夹的pids集合
|
||||||
|
CalcParentIdListUtil.fillParentIds(newRoleCategory, this);
|
||||||
|
|
||||||
|
// 更新文件夹的上下级结构
|
||||||
|
CalcParentIdListUtil.updateParentIdStringList("sys_role_category", "category_pids", oldCategory, newRoleCategory, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateById(oldCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue