...
|
...
|
@@ -2,16 +2,15 @@ package com.sunyo.wlpt.message.bus.service.service.impl; |
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
import com.sunyo.wlpt.message.bus.service.domain.UserMessageBinding;
|
|
|
import com.sunyo.wlpt.message.bus.service.domain.*;
|
|
|
import com.sunyo.wlpt.message.bus.service.mapper.UserMessageBindingMapper;
|
|
|
import com.sunyo.wlpt.message.bus.service.service.UserMessageBindingService;
|
|
|
import com.sunyo.wlpt.message.bus.service.service.*;
|
|
|
import com.sunyo.wlpt.message.bus.service.utils.IdUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -23,11 +22,27 @@ import java.util.List; |
|
|
public class UserMessageBindingServiceImpl implements UserMessageBindingService {
|
|
|
|
|
|
@Resource
|
|
|
private BusServerService busServerService;
|
|
|
|
|
|
@Resource
|
|
|
private VirtualHostService virtualHostService;
|
|
|
|
|
|
@Resource
|
|
|
private BusExchangeService busExchangeService;
|
|
|
|
|
|
@Resource
|
|
|
private BusQueueService busQueueService;
|
|
|
|
|
|
@Resource
|
|
|
private RoutingKeyService routingKeyService;
|
|
|
|
|
|
@Resource
|
|
|
private UserMessageBindingMapper userMessageBindingMapper;
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
|
|
|
public int deleteByPrimaryKey(String id) {
|
|
|
public int deleteByPrimaryKey(String id)
|
|
|
{
|
|
|
// 判断删除的个数,需被删除的个数是否一致
|
|
|
int index = 0;
|
|
|
String splitItem = ",";
|
...
|
...
|
@@ -56,38 +71,94 @@ public class UserMessageBindingServiceImpl implements UserMessageBindingService |
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int insert(UserMessageBinding record) {
|
|
|
public int insert(UserMessageBinding record)
|
|
|
{
|
|
|
return userMessageBindingMapper.insert(record);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int insertSelective(UserMessageBinding record) {
|
|
|
return userMessageBindingMapper.insertSelective(record);
|
|
|
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
|
|
|
public int insertSelective(UserMessageBinding userMessageBinding)
|
|
|
{
|
|
|
int index = 0;
|
|
|
String queueId = userMessageBinding.getQueueId();
|
|
|
String splitItem = ",";
|
|
|
if (queueId.contains(splitItem)) {
|
|
|
String[] split = queueId.split(splitItem);
|
|
|
for (int i = 0; i < split.length; i++) {
|
|
|
// 设置id
|
|
|
userMessageBinding.setId(IdUtils.generateId());
|
|
|
userMessageBinding.setQueueId(split[i]);
|
|
|
int num = userMessageBindingMapper.insertSelective(umb_fillName(userMessageBinding));
|
|
|
if (num > 0) {
|
|
|
index = index + num;
|
|
|
}
|
|
|
}
|
|
|
if (index == split.length) {
|
|
|
return 1;
|
|
|
} else {
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
return userMessageBindingMapper.insertSelective(umb_fillName(userMessageBinding));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public UserMessageBinding selectByPrimaryKey(String id) {
|
|
|
public UserMessageBinding selectByPrimaryKey(String id)
|
|
|
{
|
|
|
return userMessageBindingMapper.selectByPrimaryKey(id);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int updateByPrimaryKeySelective(UserMessageBinding record) {
|
|
|
return userMessageBindingMapper.updateByPrimaryKeySelective(record);
|
|
|
public int updateByPrimaryKeySelective(UserMessageBinding userMessageBinding)
|
|
|
{
|
|
|
return userMessageBindingMapper.updateByPrimaryKeySelective(umb_fillName(userMessageBinding));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int updateByPrimaryKey(UserMessageBinding record) {
|
|
|
public int updateByPrimaryKey(UserMessageBinding record)
|
|
|
{
|
|
|
return userMessageBindingMapper.updateByPrimaryKey(record);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public PageInfo selectUserMessageBindingList(UserMessageBinding userMessageBinding, Integer pageNum, Integer pageSize) {
|
|
|
public PageInfo selectUserMessageBindingList(UserMessageBinding userMessageBinding, Integer pageNum, Integer pageSize)
|
|
|
{
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
List<UserMessageBinding> userMessageBindingList = userMessageBindingMapper.selectUserMessageBindingList(userMessageBinding);
|
|
|
PageInfo<UserMessageBinding> pageInfo = new PageInfo<>(userMessageBindingList);
|
|
|
return pageInfo;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 编辑 or 新增方法,根绝前端传递来的id值,来填充对应的name
|
|
|
* 服务器id,虚拟主机id,交换机id,队列id,路由键id
|
|
|
*/
|
|
|
public UserMessageBinding umb_fillName(UserMessageBinding userMessageBinding)
|
|
|
{
|
|
|
// 填充,服务器名称
|
|
|
BusServer busServer = busServerService.selectByPrimaryKey(userMessageBinding.getServerId());
|
|
|
userMessageBinding.setServerName(busServer.getServerName());
|
|
|
|
|
|
// 填充,虚拟主机名称
|
|
|
VirtualHost virtualHost = virtualHostService.selectByPrimaryKey(userMessageBinding.getVirtualHostId());
|
|
|
userMessageBinding.setVirtualHostName(virtualHost.getVirtualHostName());
|
|
|
|
|
|
// 填充,交换机名称
|
|
|
BusExchange busExchange = busExchangeService.selectByPrimaryKey(userMessageBinding.getExchangeId());
|
|
|
userMessageBinding.setExchangeName(busExchange.getExchangeName());
|
|
|
|
|
|
// 填充,队列名称
|
|
|
BusQueue busQueue = busQueueService.selectByPrimaryKey(userMessageBinding.getQueueId());
|
|
|
userMessageBinding.setQueueName(busQueue.getQueueName());
|
|
|
|
|
|
// 填充,路由键名称
|
|
|
RoutingKey routingKey = routingKeyService.selectByPrimaryKey(userMessageBinding.getRoutingKeyId());
|
|
|
userMessageBinding.setRoutingKeyName(routingKey.getRoutingKeyName());
|
|
|
|
|
|
return userMessageBinding;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|