mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-22 18:29:51 +08:00
优化代码
This commit is contained in:
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import xyz.playedu.api.exception.NotFoundException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author tengteng
|
||||
@@ -40,4 +41,6 @@ public interface DepartmentService extends IService<Department> {
|
||||
void changeParent(Integer id, Integer parentId, List<Integer> ids) throws NotFoundException;
|
||||
|
||||
void resetSort(List<Integer> ids);
|
||||
|
||||
Map<Integer, List<Department>> groupByParent();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import xyz.playedu.api.exception.NotFoundException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author tengteng
|
||||
@@ -37,4 +38,6 @@ public interface ResourceCategoryService extends IService<ResourceCategory> {
|
||||
|
||||
void changeParent(Integer id, Integer parentId, List<Integer> ids) throws NotFoundException;
|
||||
|
||||
Map<Integer, List<ResourceCategory>> groupByParent();
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ import xyz.playedu.api.service.internal.UserDepartmentService;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author tengteng
|
||||
@@ -225,6 +227,11 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
||||
}
|
||||
updateBatchById(departments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, List<Department>> groupByParent() {
|
||||
return list(query().getWrapper().orderByAsc("sort")).stream().collect(Collectors.groupingBy(Department::getParentId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ import xyz.playedu.api.service.internal.ResourceCourseCategoryService;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author tengteng
|
||||
@@ -208,6 +210,11 @@ public class ResourceCategoryServiceImpl extends ServiceImpl<ResourceCategoryMap
|
||||
// 重置排序
|
||||
resetSort(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, List<ResourceCategory>> groupByParent() {
|
||||
return list(query().getWrapper().orderByAsc("sort")).stream().collect(Collectors.groupingBy(ResourceCategory::getParentId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user