This commit is contained in:
sxu 2024-12-23 12:24:05 +08:00
parent 73e4f593fe
commit 6e23827f40
1 changed files with 9 additions and 4 deletions

View File

@ -1,5 +1,6 @@
package com.bonus.material.basic.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@ -52,9 +53,12 @@ public class BmMessageServiceImpl implements IBmMessageService {
@Override
public List<BmMessage> selectBmMessageListFromCache(BmMessage bmMessage) {
List<BmMessage> bmMessages = redisService.getCacheList(MaterialConstants.CACHE_MATERIAL_MALL_MESSAGE);
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
List<BmMessage> result = bmMessages.stream().filter(o -> companyId.equals(o.getFromCompany()) || companyId.equals(o.getToCompany())).collect(Collectors.toList());
List<BmMessage> fromMessages = redisService.getCacheList(MaterialConstants.CACHE_MATERIAL_MALL_MESSAGE + companyId);
List<BmMessage> toMessages = redisService.getCacheList(MaterialConstants.CACHE_MATERIAL_MALL_MESSAGE + bmMessage.getToCompany());
List<BmMessage> result = new ArrayList<>();
result.addAll(fromMessages);
result.addAll(toMessages);
return result;
}
@ -68,10 +72,11 @@ public class BmMessageServiceImpl implements IBmMessageService {
public int insertBmMessage(BmMessage bmMessage) {
bmMessage.setCreateTime(DateUtils.getNowDate());
try {
bmMessage.setFromCompany(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
bmMessage.setFromCompany(companyId);
bmMessage.setFromUser(SecurityUtils.getLoginUser().getSysUser().getUserId());
bmMessage.setUuid(String.valueOf(UUID.randomUUID()));
String msgKey = MaterialConstants.CACHE_MATERIAL_MALL_MESSAGE;
String msgKey = MaterialConstants.CACHE_MATERIAL_MALL_MESSAGE + companyId;
String msgContent = JSONObject.toJSONString(bmMessage);
redisService.setCacheObject(msgKey, msgContent, MaterialConstants.CACHE_MATERIAL_MALL_MESSAGE_HOURS, TimeUnit.HOURS);
return bmMessageMapper.insertBmMessage(bmMessage);