...
|
...
|
@@ -5,6 +5,7 @@ import com.github.pagehelper.PageInfo; |
|
|
import com.sunyo.wlpt.message.bus.service.domain.*;
|
|
|
import com.sunyo.wlpt.message.bus.service.mapper.MessageNoteMapper;
|
|
|
import com.sunyo.wlpt.message.bus.service.mapper.UserMessageBindingMapper;
|
|
|
import com.sunyo.wlpt.message.bus.service.rabbit.utils.DirectUtils;
|
|
|
import com.sunyo.wlpt.message.bus.service.service.*;
|
|
|
import com.sunyo.wlpt.message.bus.service.utils.IdUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
...
|
...
|
@@ -47,6 +48,9 @@ public class MessageNoteServiceImpl implements MessageNoteService { |
|
|
@Resource
|
|
|
private MessageNoteMapper messageNoteMapper;
|
|
|
|
|
|
@Resource
|
|
|
private DirectUtils directUtils;
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
|
|
|
public int deleteByPrimaryKey(String id)
|
...
|
...
|
@@ -80,7 +84,7 @@ public class MessageNoteServiceImpl implements MessageNoteService { |
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int insertSelective(MessageNote record)
|
|
|
public int insertSelective(MessageNote record) throws Exception
|
|
|
{
|
|
|
return validateNoteAndFill(record);
|
|
|
}
|
...
|
...
|
@@ -164,15 +168,15 @@ public class MessageNoteServiceImpl implements MessageNoteService { |
|
|
messageNote.setId(IdUtils.generateId());
|
|
|
|
|
|
// 填充,用户名称
|
|
|
UserInfo userInfo = userInfoService.selectByPrimaryKey(messageNote.getUserId());
|
|
|
messageNote.setUsername(userInfo.getUsername());
|
|
|
// UserInfo userInfo = userInfoService.selectByPrimaryKey(messageNote.getUserId());
|
|
|
// messageNote.setUsername(userInfo.getUsername());
|
|
|
|
|
|
// 填充,发送内容(编辑 or 新增)
|
|
|
messageNote.setSendContent(messageNote.getAlias_sendContent().getBytes());
|
|
|
|
|
|
// 填充,服务器名称
|
|
|
BusServer busServer = busServerService.selectByPrimaryKey(messageNote.getServerId());
|
|
|
messageNote.setServerName(busServer.getServerName());
|
|
|
// BusServer busServer = busServerService.selectByPrimaryKey(messageNote.getServerId());
|
|
|
// messageNote.setServerName(busServer.getServerName());
|
|
|
|
|
|
// 填充,虚拟主机名称
|
|
|
VirtualHost virtualHost = virtualHostService.selectByPrimaryKey(messageNote.getVirtualHostId());
|
...
|
...
|
@@ -205,9 +209,35 @@ public class MessageNoteServiceImpl implements MessageNoteService { |
|
|
* @param messageNote {@link MessageNote}
|
|
|
* @return 发送信息记录的条数
|
|
|
*/
|
|
|
public int validateNoteAndFill(MessageNote messageNote)
|
|
|
public int validateNoteAndFill(MessageNote messageNote) throws Exception
|
|
|
{
|
|
|
return validateNote(messageNote) ? messageNoteMapper.insertSelective(note_fillName(messageNote)) : 0;
|
|
|
if (validateNote(messageNote)) {
|
|
|
// 填充,用户名称
|
|
|
UserInfo userInfo = userInfoService.selectByPrimaryKey(messageNote.getUserId());
|
|
|
messageNote.setUsername(userInfo.getUsername());
|
|
|
// 填充,服务器名称
|
|
|
BusServer busServer = busServerService.selectByPrimaryKey(messageNote.getServerId());
|
|
|
messageNote.setServerName(busServer.getServerName());
|
|
|
|
|
|
MessageNote note = note_fillName(messageNote);
|
|
|
// 发送到MQ服务器
|
|
|
XmlData xmlData = XmlData.builder()
|
|
|
.sender(note.getUsername())
|
|
|
.password(userInfo.getPassword())
|
|
|
.sendContent(note.getAlias_sendContent())
|
|
|
.sendDateTime(note.getSendTime())
|
|
|
.exchangeName(note.getExchangeName())
|
|
|
.routingKeyName(note.getRoutingKeyName())
|
|
|
.virtualHostName(note.getVirtualHostName())
|
|
|
.serverName(note.getServerName())
|
|
|
.serverIp(busServer.getServerIp())
|
|
|
.serverPort(busServer.getServerPort())
|
|
|
.build();
|
|
|
directUtils.sendMessage(xmlData);
|
|
|
return messageNoteMapper.insertSelective(note);
|
|
|
} else {
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|