|
|
|
@ -87,8 +87,17 @@ public class UserBaseInfoRedis { |
|
|
|
redisUtils.hMSet(key, map,RedisUtils.DEFAULT_EXPIRE * NumConstant.SEVEN); |
|
|
|
} |
|
|
|
|
|
|
|
public String get(String id){ |
|
|
|
return null; |
|
|
|
public UserBaseInfoResultDTO get(String userId){ |
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(userId)) { |
|
|
|
Map<String, Object> map = redisUtils.hGetAll(UserRedisKeys.getResiUserKey(userId)); |
|
|
|
if (null != map && !map.isEmpty()) { |
|
|
|
//缓存中有数据,直接返回
|
|
|
|
return BeanUtil.mapToBean(map, UserBaseInfoResultDTO.class, true); |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -193,6 +202,14 @@ public class UserBaseInfoRedis { |
|
|
|
|
|
|
|
UserBaseInfoResultDTO currentCache = ConvertUtils.sourceToTarget(entity,UserBaseInfoResultDTO.class); |
|
|
|
|
|
|
|
UserBaseInfoResultDTO orientCache = get(entity.getUserId()); |
|
|
|
if(null != orientCache && StringUtils.isNotBlank(orientCache.getUserId())){ |
|
|
|
//将要更改的信息赋值到原缓存中
|
|
|
|
mergeObject(currentCache,orientCache); |
|
|
|
//将原来的缓存对象赋值给要更新的缓存对象
|
|
|
|
//此时orientCache中包概括要更新的属性以及之前有切不更新的属性
|
|
|
|
currentCache = orientCache; |
|
|
|
} |
|
|
|
RegisterRelationEntity relation = registerRelationDao.selectRegisteredGridIdByUserId(entity.getUserId()); |
|
|
|
//如果没有首次注册网格,则没有网格名称(xx机关-xx网格)、显示昵称(xx网格-x先生/女士)
|
|
|
|
if(null != relation && StringUtils.isNotBlank(relation.getGridId())){ |
|
|
|
@ -203,22 +220,24 @@ public class UserBaseInfoRedis { |
|
|
|
Result<BelongGridNameResultDTO> gridResult = |
|
|
|
govOrgOpenFeignClient.getGridNameByGridId(gridParam); |
|
|
|
if(gridResult.success() && null != gridResult.getData() |
|
|
|
&& StringUtils.isNotBlank(gridResult.getData().getBelongsGridName())){ |
|
|
|
&& StringUtils.isNotBlank(gridResult.getData().getBelongsGridName())) { |
|
|
|
String gridFullName = gridResult.getData().getBelongsGridName(); |
|
|
|
currentCache.setRegisteredGridName(gridFullName); |
|
|
|
if(StringUtils.isBlank(currentCache.getGender()))currentCache.setGender(NumConstant.ZERO_STR); |
|
|
|
StringBuffer buffer = new StringBuffer(gridFullName.split(ModuleConstant.DASH)[NumConstant.ONE]).append(ModuleConstant.DASH).append(currentCache.getSurname()); |
|
|
|
switch (currentCache.getGender()) { |
|
|
|
case NumConstant.ONE_STR: |
|
|
|
buffer.append(ModuleConstant.RESI_USER_NICKNAME_SUFFIX_MALE); |
|
|
|
break; |
|
|
|
case NumConstant.TWO_STR: |
|
|
|
buffer.append(ModuleConstant.RESI_USER_NICKNAME_SUFFIX_FEMALE); |
|
|
|
break; |
|
|
|
default: |
|
|
|
buffer.append(ModuleConstant.RESI_USER_NICKNAME_SUFFIX_GENDER_UNKNOWN); |
|
|
|
if (StringUtils.isBlank(currentCache.getGender())) currentCache.setGender(NumConstant.ZERO_STR); |
|
|
|
if (StringUtils.isNotBlank(currentCache.getNickname())) { |
|
|
|
StringBuffer buffer = new StringBuffer(gridFullName.split(ModuleConstant.DASH)[NumConstant.ONE]).append(ModuleConstant.DASH).append(currentCache.getSurname()); |
|
|
|
switch (currentCache.getGender()) { |
|
|
|
case NumConstant.ONE_STR: |
|
|
|
buffer.append(ModuleConstant.RESI_USER_NICKNAME_SUFFIX_MALE); |
|
|
|
break; |
|
|
|
case NumConstant.TWO_STR: |
|
|
|
buffer.append(ModuleConstant.RESI_USER_NICKNAME_SUFFIX_FEMALE); |
|
|
|
break; |
|
|
|
default: |
|
|
|
buffer.append(ModuleConstant.RESI_USER_NICKNAME_SUFFIX_GENDER_UNKNOWN); |
|
|
|
} |
|
|
|
currentCache.setShowName(buffer.toString()); |
|
|
|
} |
|
|
|
currentCache.setShowName(buffer.toString()); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
//如果没有居民注册记录,说明当前用户是陌生人,需要从陌生人网格访问列表中查询所属的客户Id
|
|
|
|
@ -240,18 +259,7 @@ public class UserBaseInfoRedis { |
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
Map<String,Object> map = redisUtils.hGetAll(UserRedisKeys.getResiUserKey(entity.getUserId())); |
|
|
|
if(null != map && !map.isEmpty()) { |
|
|
|
//缓存中有数据,直接返回
|
|
|
|
UserBaseInfoResultDTO orientCache = BeanUtil.mapToBean(map, UserBaseInfoResultDTO.class, true); |
|
|
|
mergeObject(currentCache , orientCache); |
|
|
|
set(orientCache); |
|
|
|
}else{ |
|
|
|
//缓存中没有该数据
|
|
|
|
set(currentCache); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
set(currentCache); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|