Merge remote-tracking branch 'origin/master'

This commit is contained in:
liang.chao 2024-12-20 15:26:57 +08:00
commit 9b2342d295
3 changed files with 14 additions and 13 deletions

View File

@ -71,6 +71,7 @@ public class MaterialConstants {
/** 文件类型:合同照片 */
public static final Integer APPENDICES_OF_CONTRACT = 20; //move to TmTaskTypeEnum
public static final String CACHE_MATERIAL_MALL_MESSAGE_CODE = "material-mall-message-code:";
public static final String CACHE_MATERIAL_MALL_MESSAGE = "material-mall-message:";
public static final Long CACHE_MATERIAL_MALL_MESSAGE_HOURS = 24L;
}

View File

@ -3,12 +3,12 @@ package com.bonus.material.basic.service.impl;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.alibaba.fastjson2.JSONObject;
import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.redis.service.RedisService;
import com.bonus.common.security.config.VerificationCodeConfig;
import com.bonus.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -22,9 +22,6 @@ public class BmMessageServiceImpl implements IBmMessageService {
@Autowired
private BmMessageMapper bmMessageMapper;
@Resource
private VerificationCodeConfig verificationCodeConfig;
@Resource
private RedisService redisService;
@ -47,13 +44,18 @@ public class BmMessageServiceImpl implements IBmMessageService {
*/
@Override
public List<BmMessage> selectBmMessageList(BmMessage bmMessage) {
Long companyId = SecurityUtils.getLoginUser().getSysUser().getCompanyId();
bmMessage.setFromCompany(companyId);
bmMessage.setToCompany(companyId);
return bmMessageMapper.selectBmMessageList(bmMessage);
}
@Override
public List<BmMessage> selectBmMessageListFromCache(BmMessage bmMessage) {
List<BmMessage> bmMessages = redisService.getCacheList(MaterialConstants.CACHE_MATERIAL_MALL_MESSAGE_CODE);
return bmMessages;
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());
return result;
}
/**
@ -69,9 +71,9 @@ public class BmMessageServiceImpl implements IBmMessageService {
bmMessage.setFromCompany(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
bmMessage.setFromUser(SecurityUtils.getLoginUser().getSysUser().getUserId());
bmMessage.setUuid(String.valueOf(UUID.randomUUID()));
String msgKey = MaterialConstants.CACHE_MATERIAL_MALL_MESSAGE_CODE;
String msgKey = MaterialConstants.CACHE_MATERIAL_MALL_MESSAGE;
String msgContent = JSONObject.toJSONString(bmMessage);
redisService.setCacheObject(msgKey, msgContent, verificationCodeConfig.getTime(), TimeUnit.MINUTES);
redisService.setCacheObject(msgKey, msgContent, MaterialConstants.CACHE_MATERIAL_MALL_MESSAGE_HOURS, TimeUnit.HOURS);
return bmMessageMapper.insertBmMessage(bmMessage);
} catch (Exception e) {
throw new ServiceException("错误信息描述");

View File

@ -25,10 +25,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectBmMessageVo"/>
<where>
<if test="uuid != null and uuid != ''"> and uuid = #{uuid}</if>
<if test="fromUser != null and fromUser != ''"> and from_user = #{fromUser}</if>
<if test="toUser != null and toUser != ''"> and to_user = #{toUser}</if>
<if test="fromCompany != null and fromCompany != ''"> and from_company = #{fromCompany}</if>
<if test="toCompany != null and toCompany != ''"> and to_company = #{toCompany}</if>
<if test="fromUser != null and toUser != null"> and (from_user = #{fromUser} or to_user = #{toUser})</if>
<if test="fromCompany != null and toCompany != null"> and (from_company = #{fromCompany} or to_company = #{toCompany})</if>
<if test="messageContent != null and messageContent != ''"> and message_content = #{messageContent}</if>
<if test="messageTopic != null and messageTopic != ''"> and message_topic = #{messageTopic}</if>
<if test="messageType != null and messageType != ''"> and message_type = #{messageType}</if>