This commit is contained in:
zlwu committed 2025-12-24 17:20:14 +08:00
1 parent e86cae8515
commit 8c0a2d904c
4 files changed
+15 -15

No files matched your search

@@ -168,7 +168,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
* @param deptId 部门ID * @param deptId 部门ID
* @return 部门信息 * @return 部门信息
*/ */
@Cacheable(cacheNames = CacheNames.SYS_DEPT, key = "#deptId") // @Cacheable(cacheNames = CacheNames.SYS_DEPT, key = "#deptId")
@Override @Override
public SysDeptVo selectDeptById(Long deptId) { public SysDeptVo selectDeptById(Long deptId) {
SysDeptVo dept = baseMapper.selectVoById(deptId); SysDeptVo dept = baseMapper.selectVoById(deptId);
@@ -123,7 +123,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
* @param dictType 字典类型 * @param dictType 字典类型
* @return 字典类型 * @return 字典类型
*/ */
@Cacheable(cacheNames = CacheNames.SYS_DICT_TYPE, key = "#dictType") // @Cacheable(cacheNames = CacheNames.SYS_DICT_TYPE, key = "#dictType")
@Override @Override
public SysDictTypeVo selectDictTypeByType(String dictType) { public SysDictTypeVo selectDictTypeByType(String dictType) {
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getDictType, dictType)); return baseMapper.selectVoOne(new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getDictType, dictType));
@@ -734,7 +734,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
* @param userId 用户ID * @param userId 用户ID
* @return 用户账户 * @return 用户账户
*/ */
@Cacheable(cacheNames = CacheNames.SYS_USER_NAME, key = "#userId") // @Cacheable(cacheNames = CacheNames.SYS_USER_NAME, key = "#userId")
@Override @Override
public String selectUserNameById(Long userId) { public String selectUserNameById(Long userId) {
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>() SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
@@ -749,7 +749,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
* @return 用户账户 * @return 用户账户
*/ */
@Override @Override
@Cacheable(cacheNames = CacheNames.SYS_NICKNAME, key = "#userId") // @Cacheable(cacheNames = CacheNames.SYS_NICKNAME, key = "#userId")
public String selectNicknameById(Long userId) { public String selectNicknameById(Long userId) {
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>() SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
.select(SysUser::getNickName).eq(SysUser::getUserId, userId)); .select(SysUser::getNickName).eq(SysUser::getUserId, userId));
@@ -77,16 +77,15 @@ public class XgStudentServiceImpl implements IXgStudentService {
* 优化版本:使用专门的SQL查询,避免全表查询,提升性能 * 优化版本:使用专门的SQL查询,避免全表查询,提升性能
*/ */
@Override @Override
@Cacheable(value = "student_tree", key = "'tree_data'", unless = "#result == null || #result.isEmpty()")
public List<XgStudentTreeVo> getTreeData() { public List<XgStudentTreeVo> getTreeData() {
// 使用专门的SQL查询获取树形结构所需的最少数据 // 使用专门的SQL查询获取树形结构所需的最少数据
List<Map<String, Object>> treeNodes = baseMapper.selectTreeNodes(); List<Map<String, Object>> treeNodes = baseMapper.selectTreeNodes();
// 构建树形结构 // 构建树形结构
Map<String, XgStudentTreeVo> collegeMap = new LinkedHashMap<>(); Map<String, XgStudentTreeVo> collegeMap = new LinkedHashMap<>();
Map<String, XgStudentTreeVo> majorMap = new LinkedHashMap<>(); Map<String, XgStudentTreeVo> majorMap = new LinkedHashMap<>();
Map<String, XgStudentTreeVo> classMap = new LinkedHashMap<>(); Map<String, XgStudentTreeVo> classMap = new LinkedHashMap<>();
for (Map<String, Object> node : treeNodes) { for (Map<String, Object> node : treeNodes) {
String collegeId = (String) node.get("college_id"); String collegeId = (String) node.get("college_id");
String collegeName = (String) node.get("college_name"); String collegeName = (String) node.get("college_name");
@@ -94,7 +93,7 @@ public class XgStudentServiceImpl implements IXgStudentService {
String majorName = (String) node.get("major_name"); String majorName = (String) node.get("major_name");
String classId = (String) node.get("class_id"); String classId = (String) node.get("class_id");
String className = (String) node.get("class_name"); String className = (String) node.get("class_name");
// 学院节点 // 学院节点
if (StringUtils.isNotBlank(collegeId) && !collegeMap.containsKey(collegeId)) { if (StringUtils.isNotBlank(collegeId) && !collegeMap.containsKey(collegeId)) {
XgStudentTreeVo college = new XgStudentTreeVo(); XgStudentTreeVo college = new XgStudentTreeVo();
@@ -104,7 +103,7 @@ public class XgStudentServiceImpl implements IXgStudentService {
college.setChildren(new ArrayList<>()); college.setChildren(new ArrayList<>());
collegeMap.put(collegeId, college); collegeMap.put(collegeId, college);
} }
// 专业节点 // 专业节点
String majorKey = collegeId + "_" + majorId; String majorKey = collegeId + "_" + majorId;
if (StringUtils.isNotBlank(majorId) && !majorMap.containsKey(majorKey)) { if (StringUtils.isNotBlank(majorId) && !majorMap.containsKey(majorKey)) {
@@ -114,13 +113,13 @@ public class XgStudentServiceImpl implements IXgStudentService {
major.setType("major"); major.setType("major");
major.setChildren(new ArrayList<>()); major.setChildren(new ArrayList<>());
majorMap.put(majorKey, major); majorMap.put(majorKey, major);
// 添加到学院下 // 添加到学院下
if (collegeMap.containsKey(collegeId)) { if (collegeMap.containsKey(collegeId)) {
collegeMap.get(collegeId).getChildren().add(major); collegeMap.get(collegeId).getChildren().add(major);
} }
} }
// 班级节点 // 班级节点
String classKey = majorKey + "_" + classId; String classKey = majorKey + "_" + classId;
if (StringUtils.isNotBlank(classId) && !classMap.containsKey(classKey)) { if (StringUtils.isNotBlank(classId) && !classMap.containsKey(classKey)) {
@@ -130,14 +129,14 @@ public class XgStudentServiceImpl implements IXgStudentService {
clazz.setType("class"); clazz.setType("class");
clazz.setChildren(new ArrayList<>()); clazz.setChildren(new ArrayList<>());
classMap.put(classKey, clazz); classMap.put(classKey, clazz);
// 添加到专业下 // 添加到专业下
if (majorMap.containsKey(majorKey)) { if (majorMap.containsKey(majorKey)) {
majorMap.get(majorKey).getChildren().add(clazz); majorMap.get(majorKey).getChildren().add(clazz);
} }
} }
} }
return new ArrayList<>(collegeMap.values()); return new ArrayList<>(collegeMap.values());
} }
@@ -145,7 +144,8 @@ public class XgStudentServiceImpl implements IXgStudentService {
* 根据班级ID获取学生列表 * 根据班级ID获取学生列表
*/ */
@Override @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) { public List<XgStudentVo> getStudentsByClassId(Long classId) {
LambdaQueryWrapper<XgStudentMsg> lqw = Wrappers.lambdaQuery(); LambdaQueryWrapper<XgStudentMsg> lqw = Wrappers.lambdaQuery();
lqw.eq(XgStudentMsg::getClassId, classId); lqw.eq(XgStudentMsg::getClassId, classId);
@@ -213,4 +213,4 @@ public class XgStudentServiceImpl implements IXgStudentService {
lqw.orderByDesc(XgStudentMsg::getStudentNo).orderByDesc(XgStudentMsg::getId); lqw.orderByDesc(XgStudentMsg::getStudentNo).orderByDesc(XgStudentMsg::getId);
return lqw; return lqw;
} }
} }