|
|
@@ -77,16 +77,15 @@ public class XgStudentServiceImpl implements IXgStudentService {
|
|
|
* 优化版本:使用专门的SQL查询,避免全表查询,提升性能
|
|
|
*/
|
|
|
@Override
|
|
|
- @Cacheable(value = "student_tree", key = "'tree_data'", unless = "#result == null || #result.isEmpty()")
|
|
|
public List<XgStudentTreeVo> getTreeData() {
|
|
|
// 使用专门的SQL查询获取树形结构所需的最少数据
|
|
|
List<Map<String, Object>> treeNodes = baseMapper.selectTreeNodes();
|
|
|
-
|
|
|
+
|
|
|
// 构建树形结构
|
|
|
Map<String, XgStudentTreeVo> collegeMap = new LinkedHashMap<>();
|
|
|
Map<String, XgStudentTreeVo> majorMap = new LinkedHashMap<>();
|
|
|
Map<String, XgStudentTreeVo> classMap = new LinkedHashMap<>();
|
|
|
-
|
|
|
+
|
|
|
for (Map<String, Object> node : treeNodes) {
|
|
|
String collegeId = (String) node.get("college_id");
|
|
|
String collegeName = (String) node.get("college_name");
|
|
|
@@ -94,7 +93,7 @@ public class XgStudentServiceImpl implements IXgStudentService {
|
|
|
String majorName = (String) node.get("major_name");
|
|
|
String classId = (String) node.get("class_id");
|
|
|
String className = (String) node.get("class_name");
|
|
|
-
|
|
|
+
|
|
|
// 学院节点
|
|
|
if (StringUtils.isNotBlank(collegeId) && !collegeMap.containsKey(collegeId)) {
|
|
|
XgStudentTreeVo college = new XgStudentTreeVo();
|
|
|
@@ -104,7 +103,7 @@ public class XgStudentServiceImpl implements IXgStudentService {
|
|
|
college.setChildren(new ArrayList<>());
|
|
|
collegeMap.put(collegeId, college);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 专业节点
|
|
|
String majorKey = collegeId + "_" + majorId;
|
|
|
if (StringUtils.isNotBlank(majorId) && !majorMap.containsKey(majorKey)) {
|
|
|
@@ -114,13 +113,13 @@ public class XgStudentServiceImpl implements IXgStudentService {
|
|
|
major.setType("major");
|
|
|
major.setChildren(new ArrayList<>());
|
|
|
majorMap.put(majorKey, major);
|
|
|
-
|
|
|
+
|
|
|
// 添加到学院下
|
|
|
if (collegeMap.containsKey(collegeId)) {
|
|
|
collegeMap.get(collegeId).getChildren().add(major);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 班级节点
|
|
|
String classKey = majorKey + "_" + classId;
|
|
|
if (StringUtils.isNotBlank(classId) && !classMap.containsKey(classKey)) {
|
|
|
@@ -130,14 +129,14 @@ public class XgStudentServiceImpl implements IXgStudentService {
|
|
|
clazz.setType("class");
|
|
|
clazz.setChildren(new ArrayList<>());
|
|
|
classMap.put(classKey, clazz);
|
|
|
-
|
|
|
+
|
|
|
// 添加到专业下
|
|
|
if (majorMap.containsKey(majorKey)) {
|
|
|
majorMap.get(majorKey).getChildren().add(clazz);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return new ArrayList<>(collegeMap.values());
|
|
|
}
|
|
|
|
|
|
@@ -145,7 +144,8 @@ public class XgStudentServiceImpl implements IXgStudentService {
|
|
|
* 根据班级ID获取学生列表
|
|
|
*/
|
|
|
@Override
|
|
|
- @Cacheable(value = "student_list", key = "'class_' + #classId", unless = "#result == null || #result.isEmpty()")
|
|
|
+ // @Cacheable(value = "student_list", key = "'class_' + #classId", unless =
|
|
|
+ // "#result == null || #result.isEmpty()")
|
|
|
public List<XgStudentVo> getStudentsByClassId(Long classId) {
|
|
|
LambdaQueryWrapper<XgStudentMsg> lqw = Wrappers.lambdaQuery();
|
|
|
lqw.eq(XgStudentMsg::getClassId, classId);
|
|
|
@@ -213,4 +213,4 @@ public class XgStudentServiceImpl implements IXgStudentService {
|
|
|
lqw.orderByDesc(XgStudentMsg::getStudentNo).orderByDesc(XgStudentMsg::getId);
|
|
|
return lqw;
|
|
|
}
|
|
|
-}
|
|
|
+}
|