...
|
...
|
@@ -2,12 +2,10 @@ package com.sunyo.wlpt.message.bus.service.controller; |
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.sunyo.wlpt.message.bus.service.domain.BusQueue;
|
|
|
import com.sunyo.wlpt.message.bus.service.domain.UserInfo;
|
|
|
import com.sunyo.wlpt.message.bus.service.response.ResultJson;
|
|
|
import com.sunyo.wlpt.message.bus.service.service.BusQueueService;
|
|
|
import com.sunyo.wlpt.message.bus.service.service.UserInfoService;
|
|
|
import com.sunyo.wlpt.message.bus.service.utils.IdUtils;
|
|
|
import io.netty.util.internal.StringUtil;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
...
|
...
|
@@ -29,6 +27,7 @@ public class BusQueueController { |
|
|
|
|
|
@Resource
|
|
|
private UserInfoService userInfoService;
|
|
|
|
|
|
@Resource
|
|
|
private BusQueueService busQueueService;
|
|
|
|
...
|
...
|
@@ -117,31 +116,28 @@ public class BusQueueController { |
|
|
@PostMapping("/insert")
|
|
|
public ResultJson insertBusQueue(@RequestBody BusQueue busQueue) throws IOException, TimeoutException
|
|
|
{
|
|
|
//先验证,增加的虚拟主机的核心信息(交换机名称)是否已存在
|
|
|
String message = validateBusQueue(busQueue);
|
|
|
// 设置id
|
|
|
busQueue.setId(IdUtils.generateId());
|
|
|
//验证通过
|
|
|
return message == null
|
|
|
? busQueueService.insertSelective(busQueue) > 0
|
|
|
? new ResultJson<>("200", "添加消息队列,成功")
|
|
|
: new ResultJson<>("500", "添加消息队列,失败")
|
|
|
? busQueueService.insertSelective(busQueue)
|
|
|
: new ResultJson<>("400", message);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 校验-消息队列,添加和修改之前,是否已存在
|
|
|
* 校验-消息队列的队列名称的唯一性
|
|
|
*
|
|
|
* @param busQueue {@link BusQueue}
|
|
|
* @return 通过校验,无返回消息
|
|
|
*/
|
|
|
private String validateBusQueue(BusQueue busQueue)
|
|
|
{
|
|
|
if (!StringUtil.isNullOrEmpty(busQueue.getUserId())) {
|
|
|
// 根据用户id,填充用户名称;违背了单一职责原则,有时间再改
|
|
|
UserInfo userInfo = userInfoService.selectByPrimaryKey(busQueue.getUserId());
|
|
|
busQueue.setUsername(userInfo.getUsername());
|
|
|
}
|
|
|
// if (!StringUtil.isNullOrEmpty(busQueue.getUserId())) {
|
|
|
// // 根据用户id,填充用户名称;违背了单一职责原则,有时间再改
|
|
|
// UserInfo userInfo = userInfoService.selectByPrimaryKey(busQueue.getUserId());
|
|
|
// busQueue.setUsername(userInfo.getUsername());
|
|
|
// }
|
|
|
|
|
|
// 判断队列名称,是否为空
|
|
|
if ("".equals(busQueue.getQueueName()) || busQueue.getQueueName() == null) {
|
...
|
...
|
|