コード例 #1
0
 /** 通知用 根据学生Id查询家庭成员 */
 @Override
 public List<FamilyRelationDTO> queryFamilyByStudent(String userId) {
   String key = MessageFormat.format(CacheConstants.KEY_PARENT_OF_KID, userId);
   List<FamilyRelationDTO> list = cacheService.get(key);
   if (list != null) {
     return list;
   }
   List<FamilyRelationDTO> familyRelationDTOs = new ArrayList<>();
   List<MFamilyRelation> mFamilyRelations =
       famillyRelationMapper.queryFamilyByStudent(userId, userService.getSchoolId(userId));
   for (MFamilyRelation fr : mFamilyRelations) {
     FamilyRelationDTO familyRelationDTO = new FamilyRelationDTO();
     BeanUtils.copyProperties(fr, familyRelationDTO);
     familyRelationDTOs.add(familyRelationDTO);
   }
   cacheService.set(key, familyRelationDTOs, CacheConstants.CACHE_SEVEN_DAY, TimeUnit.DAYS);
   return familyRelationDTOs;
 }
コード例 #2
0
 // 学生换班,管理员修改名称,删除该家长的缓存信息
 private void deleteRedis(List<MFamilyRelation> frList) {
   List<String> keyList = new ArrayList<>();
   for (MFamilyRelation fr : frList) {
     keyList.add(MessageFormat.format(CacheConstants.KEY_KID_OF_PARENT, fr.getUserId()));
     keyList.add(MessageFormat.format(CacheConstants.KEY_FAMILY_RELATION, fr.getUserId()));
     keyList.add(MessageFormat.format(CacheConstants.KEY_KID_NAME_OF_PARENT, fr.getUserId()));
   }
   if (CollectionUtils.isNotEmpty(keyList)) {
     cacheService.delete(keyList);
   }
 }
コード例 #3
0
 /** 修改学生信息 */
 @Override
 public StudentManagerDTO updateStudentInfo(String userId, String realName, String classId) {
   String schoolId = userService.getSchoolId(userId);
   // 更换用户名称
   usersMapper.updateUserName(userId, realName, schoolId);
   // 更换班级
   MClass mClass = classMapper.selectByPrimaryKey(classId, schoolId);
   studentMapper.updateStudentMessage(userId, mClass);
   // 修改家庭关系表中用户名称
   familyRelationService.updateName(userId, realName);
   MStudentManager studentManager = studentMapper.selectStudentByUserId(userId, schoolId);
   StudentManagerDTO studentManagerDTO = new StudentManagerDTO();
   BeanUtils.copyProperties(studentManager, studentManagerDTO);
   studentManagerDTO.setClassAliasName(
       getGrade(mClass.getYears()) + studentManagerDTO.getClassAliasName());
   // 修改孩子名称,班级信息,删除缓存数据
   deleteRedisOfParent(userId, schoolId);
   cacheService.delete(MessageFormat.format(CacheConstants.KEY_USER, userId));
   return studentManagerDTO;
 }