/** 通知用 根据学生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; }
/* * 学生换班,管理员修改名称,根据单个孩子id删除家长在缓存中的数据 * @param userId 孩子id * @param schoolId 孩子的学校id */ private void deleteRedisOfParent(String userId, String schoolId) { // 获取孩子的家长信息 List<MFamilyRelation> frList = famillyRelationMapper.queryFamilyByStudent(userId, schoolId); deleteRedis(frList); }
/* * 学生换班,根据多个孩子id删除家长在缓存中的数据 * @param userIdList 孩子id列表 * @param schoolId 孩子的学校id */ private void deleteRedisOfParent(List<String> userIdList, String schoolId) { // 获取孩子的家长信息 List<MFamilyRelation> frList = famillyRelationMapper.queryParentOfKidList(userIdList, schoolId); deleteRedis(frList); }