Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-07-21 11:04:29 +08:00
commit e5c683de8b
2 changed files with 50 additions and 26 deletions

View File

@ -21,6 +21,8 @@ import io.renren.modules.sys.service.SysUserService;
import io.renren.websocket.WebSocketServer;
import io.renren.websocket.data.MessageData;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -29,12 +31,16 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* 通知管理
*/
@Service
public class SysNoticeServiceImpl extends CrudServiceImpl<SysNoticeDao, SysNoticeEntity, SysNoticeDTO> implements SysNoticeService {
private static final ExecutorService executor = Executors.newWorkStealingPool();
private static final Logger logger = LoggerFactory.getLogger(SysNoticeServiceImpl.class);
@Autowired
private SysNoticeUserService sysNoticeUserService;
@Autowired
@ -85,22 +91,26 @@ public class SysNoticeServiceImpl extends CrudServiceImpl<SysNoticeDao, SysNotic
@Override
@Transactional(rollbackFor = Exception.class)
public void save(SysNoticeDTO dto) {
SysNoticeEntity entity = ConvertUtils.sourceToTarget(dto, SysNoticeEntity.class);
if (StringUtils.isEmpty(entity.getFrom())) {
entity.setFrom("其它"); // 站内信通知来源 (通知评论其它)
try {
SysNoticeEntity entity = ConvertUtils.sourceToTarget(dto, SysNoticeEntity.class);
if (StringUtils.isEmpty(entity.getFrom())) {
entity.setFrom("其它"); // 站内信通知来源 (通知评论其它)
}
//更新发送者信息
if (dto.getStatus() == NoticeStatusEnum.SEND.value() && StringUtils.isEmpty(dto.getSenderName())) {
entity.setSenderName(SecurityUser.getUser().getRealName());
entity.setSenderDate(new Date());
}
baseDao.insert(entity);
//发送通知
dto.setId(entity.getId());
sendNotice(dto);
} catch (Exception exception) {
logger.error("发送站内信异常", exception);
}
//更新发送者信息
if (dto.getStatus() == NoticeStatusEnum.SEND.value() && StringUtils.isEmpty(dto.getSenderName())) {
entity.setSenderName(SecurityUser.getUser().getRealName());
entity.setSenderDate(new Date());
}
baseDao.insert(entity);
//发送通知
dto.setId(entity.getId());
sendNotice(dto);
}
@Override
@ -131,12 +141,16 @@ public class SysNoticeServiceImpl extends CrudServiceImpl<SysNoticeDao, SysNotic
//全部用户
if (notice.getReceiverType() == ReceiverTypeEnum.ALL.value()) {
//发送给全部用户
sendAllUser(notice);
executor.execute(() -> {
//发送给全部用户
sendAllUser(notice);
});
//通过WebSocket提示全部用户有新通知
MessageData<String> message = new MessageData<String>().msg(notice.getTitle());
webSocketServer.sendMessageAll(message);
executor.execute(() -> {
//通过WebSocket提示全部用户有新通知
MessageData<String> message = new MessageData<String>().msg(notice.getTitle());
webSocketServer.sendMessageAll(message);
});
} else { //选中用户
List<Long> userIdList = new ArrayList<>();
@ -152,12 +166,17 @@ public class SysNoticeServiceImpl extends CrudServiceImpl<SysNoticeDao, SysNotic
return;
}
//发送给选中用户
sendUser(notice, userIdList);
List<Long> finalUserIdList = userIdList;
executor.execute(() -> {
//发送给选中用户
sendUser(notice, finalUserIdList);
});
//通过WebSocket提示选中用户有新通知
MessageData<String> message = new MessageData<String>().msg(notice.getTitle());
webSocketServer.sendMessage(userIdList, message);
executor.execute(() -> {
//通过WebSocket提示选中用户有新通知
MessageData<String> message = new MessageData<String>().msg(notice.getTitle());
webSocketServer.sendMessage(finalUserIdList, message);
});
}
}

View File

@ -63,7 +63,12 @@ spring:
baseline-on-migrate: true
baseline-version: 0
validate-on-migrate: true
jackson:
parser:
# 允许出现特殊字符和转义符
allow_unquoted_control_chars: true
#允许出现单引号
allow_single_quotes: true
fdfs:
so-timeout: 600000