提交
This commit is contained in:
1 parent
e86cae8515
commit
8c0a2d904c
4 files changed
+15
-15
No files matched your search
+1
-1
@@ -168,7 +168,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
||||
* @param deptId 部门ID
|
||||
* @return 部门信息
|
||||
*/
|
||||
@Cacheable(cacheNames = CacheNames.SYS_DEPT, key = "#deptId")
|
||||
// @Cacheable(cacheNames = CacheNames.SYS_DEPT, key = "#deptId")
|
||||
@Override
|
||||
public SysDeptVo selectDeptById(Long deptId) {
|
||||
SysDeptVo dept = baseMapper.selectVoById(deptId);
|
||||
|
||||
+1
-1
@@ -123,7 +123,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
* @param dictType 字典类型
|
||||
* @return 字典类型
|
||||
*/
|
||||
@Cacheable(cacheNames = CacheNames.SYS_DICT_TYPE, key = "#dictType")
|
||||
// @Cacheable(cacheNames = CacheNames.SYS_DICT_TYPE, key = "#dictType")
|
||||
@Override
|
||||
public SysDictTypeVo selectDictTypeByType(String dictType) {
|
||||
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getDictType, dictType));
|
||||
|
||||
+2
-2
@@ -734,7 +734,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
* @param userId 用户ID
|
||||
* @return 用户账户
|
||||
*/
|
||||
@Cacheable(cacheNames = CacheNames.SYS_USER_NAME, key = "#userId")
|
||||
// @Cacheable(cacheNames = CacheNames.SYS_USER_NAME, key = "#userId")
|
||||
@Override
|
||||
public String selectUserNameById(Long userId) {
|
||||
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||
@@ -749,7 +749,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
* @return 用户账户
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(cacheNames = CacheNames.SYS_NICKNAME, key = "#userId")
|
||||
// @Cacheable(cacheNames = CacheNames.SYS_NICKNAME, key = "#userId")
|
||||
public String selectNicknameById(Long userId) {
|
||||
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getNickName).eq(SysUser::getUserId, userId));
|
||||
|
||||
+11
-11
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user