From 4c8e9d806156fb1382e93ef3279982a42399530a Mon Sep 17 00:00:00 2001 From: wangchao Date: Mon, 22 Mar 2021 16:56:53 +0800 Subject: [PATCH] =?UTF-8?q?get=E7=BB=84=E5=91=98=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/redis/ResiGroupMemberRedis.java | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/redis/ResiGroupMemberRedis.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/redis/ResiGroupMemberRedis.java index c2c735c70b..fcb7cb7b4a 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/redis/ResiGroupMemberRedis.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/redis/ResiGroupMemberRedis.java @@ -18,6 +18,7 @@ package com.epmet.modules.member.redis; +import cn.hutool.core.bean.BeanUtil; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.redis.RedisKeys; @@ -25,6 +26,7 @@ import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.UserResiInfoFormDTO; +import com.epmet.dto.result.UserBaseInfoResultDTO; import com.epmet.dto.result.UserResiInfoResultDTO; import com.epmet.modules.constant.ResiGroupRedisKeys; import com.epmet.modules.feign.EpmetUserFeignClient; @@ -115,21 +117,34 @@ public class ResiGroupMemberRedis { memberRedis.setMemberStatus(memberMySql.getStatus()); - UserResiInfoFormDTO userParam = new UserResiInfoFormDTO(); - userParam.setUserId(memberMySql.getCustomerUserId()); - userParam.setCustomerId(groupService.get(groupId).getCustomerId()); - Result userInfo = epmetUserFeignClient.getUserResiInfoDTO(userParam); - if(userInfo.success()){ - if(null != userInfo.getData()){ - memberRedis.setUserShowName(userInfo.getData().getShowName()); - memberRedis.setUserHeadPhoto(userInfo.getData().getHeadPhoto()); - memberRedis.setMemberMobile(userInfo.getData().getRegMobile()); + + Map map = redisUtils.hGetAll(String.format("epmet:resi:user:%s",userId)); + if(null != map && !map.isEmpty()) { + //缓存中有数据,直接返回 + UserBaseInfoResultDTO userInfo = + BeanUtil.mapToBean(map, UserBaseInfoResultDTO.class, true); + if(null != userInfo){ + memberRedis.setUserShowName(userInfo.getShowName()); + memberRedis.setUserHeadPhoto(userInfo.getHeadImgUrl()); + memberRedis.setMemberMobile(userInfo.getMobile()); + set(memberRedis); + } + }else { + UserResiInfoFormDTO userParam = new UserResiInfoFormDTO(); + userParam.setUserId(memberMySql.getCustomerUserId()); + userParam.setCustomerId(groupService.get(groupId).getCustomerId()); + Result userInfo = epmetUserFeignClient.getUserResiInfoDTO(userParam); + if (userInfo.success()) { + if (null != userInfo.getData()) { + memberRedis.setUserShowName(userInfo.getData().getShowName()); + memberRedis.setUserHeadPhoto(userInfo.getData().getHeadPhoto()); + memberRedis.setMemberMobile(userInfo.getData().getRegMobile()); + set(memberRedis); + } + } else { + logger.warn(ModuleConstant.USER_INFO_LIST_NOT_FOUND); } - }else{ - logger.warn(ModuleConstant.USER_INFO_LIST_NOT_FOUND); } - - set(memberRedis); return memberRedis; }else{ //日志打印效果:找不到组员信息,组Id: ********,用户Id:********