fix:bug
This commit is contained in:
@@ -10,6 +10,6 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
@FeignClient(name = "system",contextId = "systemMessageClient")
|
||||
public interface IMessageFeignClient {
|
||||
|
||||
@PostMapping("/systemMsg//sendMessage")
|
||||
@PostMapping("/systemMsg/sendMessage")
|
||||
SdmResponse sendMessage(@RequestBody SendMsgReq req);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.sdm.common.entity.req.system.UserQueryReq;
|
||||
import com.sdm.common.entity.resp.system.CIDUserResp;
|
||||
import com.sdm.common.feign.inter.system.ISysUserFeignClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -25,17 +26,18 @@ public class UserNameCacheService {
|
||||
@Cacheable(value = "userNames", key = "#userIds.toString()")
|
||||
public Map<Long, String> batchGetUserNames(Set<Long> userIds) {
|
||||
log.info("【缓存未命中】批量查询用户名,用户数量: {}", userIds.size());
|
||||
|
||||
Map<Long, String> userMap = new HashMap<>();
|
||||
// 批量调用用户服务
|
||||
SdmResponse<List<CIDUserResp>> response = sysUserFeignClient.listUserByIds(
|
||||
UserQueryReq.builder().userIds(new ArrayList<>(userIds)).build()
|
||||
);
|
||||
|
||||
Map<Long, String> userMap = response.getData().stream()
|
||||
.collect(Collectors.toMap(
|
||||
CIDUserResp::getUserId,
|
||||
CIDUserResp::getNickname
|
||||
));
|
||||
if (CollectionUtils.isNotEmpty(response.getData())) {
|
||||
userMap = response.getData().stream()
|
||||
.collect(Collectors.toMap(
|
||||
CIDUserResp::getUserId,
|
||||
CIDUserResp::getNickname
|
||||
));
|
||||
}
|
||||
|
||||
return userMap;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user