mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-07-23 17:49:34 +08:00
fixed: 部门和资源分类的上下级更改api
This commit is contained in:
parent
1867d5fa1a
commit
0d63b433ce
@ -1,5 +1,6 @@
|
|||||||
package xyz.playedu.api.request.backend;
|
package xyz.playedu.api.request.backend;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ -18,5 +19,6 @@ public class DepartmentParentRequest {
|
|||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
@NotNull(message = "参数为空")
|
@NotNull(message = "参数为空")
|
||||||
|
@JsonProperty("parent_id")
|
||||||
private Integer parentId;
|
private Integer parentId;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package xyz.playedu.api.request.backend;
|
package xyz.playedu.api.request.backend;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ -18,5 +19,6 @@ public class ResourceCategoryParentRequest {
|
|||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
@NotNull(message = "参数为空")
|
@NotNull(message = "参数为空")
|
||||||
|
@JsonProperty("parent_id")
|
||||||
private Integer parentId;
|
private Integer parentId;
|
||||||
}
|
}
|
||||||
|
@ -197,16 +197,8 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void changeParent(Integer id, Integer parentId, List<Integer> ids) throws NotFoundException {
|
public void changeParent(Integer id, Integer parentId, List<Integer> ids) throws NotFoundException {
|
||||||
Department department = new Department();
|
Department department = findOrFail(id);
|
||||||
department.setId(id);
|
update(department, department.getName(), parentId, department.getSort());
|
||||||
department.setParentId(parentId);
|
|
||||||
if (parentId.equals(0)) {
|
|
||||||
department.setParentChain("");
|
|
||||||
} else {
|
|
||||||
Department parentDep = findOrFail(parentId);
|
|
||||||
department.setParentChain(childrenParentChain(parentDep));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 重置排序
|
// 重置排序
|
||||||
resetSort(ids);
|
resetSort(ids);
|
||||||
}
|
}
|
||||||
|
@ -197,16 +197,8 @@ public class ResourceCategoryServiceImpl extends ServiceImpl<ResourceCategoryMap
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void changeParent(Integer id, Integer parentId, List<Integer> ids) throws NotFoundException {
|
public void changeParent(Integer id, Integer parentId, List<Integer> ids) throws NotFoundException {
|
||||||
ResourceCategory category = new ResourceCategory();
|
ResourceCategory category = findOrFail(id);
|
||||||
category.setId(id);
|
update(category, category.getName(), parentId, category.getSort());
|
||||||
category.setParentId(parentId);
|
|
||||||
if (parentId.equals(0)) {
|
|
||||||
category.setParentChain("");
|
|
||||||
} else {
|
|
||||||
ResourceCategory parentResourceCategory = findOrFail(parentId);
|
|
||||||
category.setParentChain(childrenParentChain(parentResourceCategory));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 重置排序
|
// 重置排序
|
||||||
resetSort(ids);
|
resetSort(ids);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user