作者 王勇

对配置的各个关联的名称,进行了填充

正在显示 20 个修改的文件 包含 252 行增加24 行删除
package com.sunyo.wlpt.message.bus.service.controller;
import com.sunyo.wlpt.message.bus.service.domain.BusExchange;
import com.sunyo.wlpt.message.bus.service.domain.BusServer;
import com.sunyo.wlpt.message.bus.service.domain.VirtualHost;
import com.sunyo.wlpt.message.bus.service.domain.*;
import com.sunyo.wlpt.message.bus.service.response.ResultJson;
import com.sunyo.wlpt.message.bus.service.service.BusExchangeService;
import com.sunyo.wlpt.message.bus.service.service.BusServerService;
import com.sunyo.wlpt.message.bus.service.service.VirtualHostService;
import com.sunyo.wlpt.message.bus.service.service.*;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
... ... @@ -31,6 +27,12 @@ public class CascadeController {
@Resource
private BusExchangeService busExchangeService;
@Resource
private BusQueueService busQueueService;
@Resource
private RoutingKeyService routingKeyService;
/**
* 仅,查询服务器列表
*
... ... @@ -53,15 +55,20 @@ public class CascadeController {
return result;
}
/**
* 仅,查询虚拟主机列表
*
* @param serverId 所属服务器ID
* @return {@link ResultJson}
*/
@GetMapping("/host")
public ResultJson getVirtualHostList() {
public ResultJson getVirtualHostList(@RequestParam(value = "serverId", required = false) String serverId) {
ResultJson result = new ResultJson();
List<VirtualHost> virtualHosts = virtualHostService.getVirtualHostList();
VirtualHost virtualHost = new VirtualHost();
// 获取参数,所属服务器ID
virtualHost.setServerId(serverId);
List<VirtualHost> virtualHosts = virtualHostService.getVirtualHostList(virtualHost);
int num = virtualHosts.size();
if (num > 0) {
result.setCode("200");
... ... @@ -74,9 +81,18 @@ public class CascadeController {
return result;
}
/**
* 仅查询交换机的列表
*
* @param virtualHostId 所属虚拟主机的ID
* @return
*/
@GetMapping("/exchange")
public ResultJson getExchangeList() {
List<BusExchange> busExchanges = busExchangeService.getExchangeList();
public ResultJson getExchangeList(@RequestParam(value = "virtualHostId", required = false) String virtualHostId) {
BusExchange busExchange = new BusExchange();
// 获取参数,所属虚拟主机ID
busExchange.setVirtualHostId(virtualHostId);
List<BusExchange> busExchanges = busExchangeService.getExchangeList(busExchange);
int num = busExchanges.size();
if (num > 0) {
return new ResultJson("200", "查询交换机列表,成功", busExchanges);
... ... @@ -86,6 +102,48 @@ public class CascadeController {
}
/**
* 仅,查询队列列表
*
* @param virtualHostId 所属虚拟主机ID
* @return {@link ResultJson}
*/
@GetMapping("/queue")
public ResultJson getQueueList(@RequestParam(value = "virtualHostId", required = false) String virtualHostId) {
BusQueue busQueue = new BusQueue();
// 获取参数,所属虚拟主机ID
busQueue.setVirtualHostId(virtualHostId);
List<BusQueue> busQueues = busQueueService.getQueueList(busQueue);
int num = busQueues.size();
if (num > 0) {
return new ResultJson("200", "查询队列列表,成功", busQueues);
} else {
return new ResultJson("500", "查询队列列表,失败");
}
}
/**
* 仅,查询路由键列表
*
* @param exchangeId 所属交换机ID
* @return {@link ResultJson}
*/
@GetMapping("/routing")
public ResultJson getRoutingKeyList(@RequestParam(value = "exchangeId", required = false) String exchangeId) {
RoutingKey routingKey = new RoutingKey();
// 获取参数,交换机ID
routingKey.setExchangeId(exchangeId);
List<RoutingKey> routingKeys = routingKeyService.getRoutingKeyList(routingKey);
int num = routingKeys.size();
if (num > 0) {
return new ResultJson("200", "查询路由键列表,成功", routingKeys);
} else {
return new ResultJson("500", "查询路由键列表,失败");
}
}
/**
* 服务器与虚拟主机是1:n的关系
* 查询,服务器列表(包含虚拟机)
*
... ...
... ... @@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.github.pagehelper.PageInfo;
import com.sunyo.wlpt.message.bus.service.domain.MessageNote;
import com.sunyo.wlpt.message.bus.service.domain.SchedulingDelete;
import com.sunyo.wlpt.message.bus.service.domain.UserMessageBinding;
import com.sunyo.wlpt.message.bus.service.response.ResultJson;
import com.sunyo.wlpt.message.bus.service.service.MessageNoteService;
import com.sunyo.wlpt.message.bus.service.service.SchedulingDeleteService;
... ...
... ... @@ -2,10 +2,9 @@ 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.UserMessageBinding;
import com.sunyo.wlpt.message.bus.service.domain.*;
import com.sunyo.wlpt.message.bus.service.response.ResultJson;
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.web.bind.annotation.*;
... ... @@ -23,6 +22,20 @@ import javax.annotation.Resource;
public class UserMessageBindingController {
@Resource
private BusServerService busServerService;
@Resource
private VirtualHostService virtualHostService;
@Resource
private BusExchangeService busExchangeService;
@Resource
private BusQueueService busQueueService;
@Resource
private RoutingKeyService routingKeyService;
@Resource
private UserMessageBindingService userMessageBindingService;
/**
... ... @@ -130,7 +143,7 @@ public class UserMessageBindingController {
@PutMapping("/update")
public ResultJson updateUserMessageBinding(@RequestBody UserMessageBinding userMessageBinding) {
ResultJson result = new ResultJson<>();
int num = userMessageBindingService.updateByPrimaryKeySelective(userMessageBinding);
int num = userMessageBindingService.updateByPrimaryKeySelective(fillName(userMessageBinding));
if (num > 0) {
result.setCode("200");
result.setMsg("编辑-账户消息配置-信息,成功");
... ... @@ -152,7 +165,7 @@ public class UserMessageBindingController {
ResultJson result = new ResultJson<>();
// 设置id
userMessageBinding.setId(IdUtils.generateId());
int num = userMessageBindingService.insertSelective(userMessageBinding);
int num = userMessageBindingService.insertSelective(fillName(userMessageBinding));
if (num > 0) {
result.setCode("200");
result.setMsg("添加-账户消息配置-信息,成功");
... ... @@ -163,4 +176,31 @@ public class UserMessageBindingController {
return result;
}
/**
* 编辑 or 新增方法,根绝前端传递来的id值,来填充对应的name
* 服务器id,虚拟主机id,交换机id,队列id,路由键id
*/
public UserMessageBinding 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;
}
}
... ...
... ... @@ -80,7 +80,8 @@ public interface BusExchangeMapper {
/**
* 仅,查询交换机列表
*
* @param busExchange {@link BusExchange}
* @return List<BusExchange>
*/
List<BusExchange> getExchangeList();
List<BusExchange> getExchangeList(BusExchange busExchange);
}
... ...
... ... @@ -76,4 +76,12 @@ public interface BusQueueMapper {
* @return List<BusQueue>
*/
List<BusQueue> validateBusQueue(BusQueue busQueue);
/**
* 仅,查询队列列表
*
* @param busQueue {@link BusQueue}
* @return
*/
List<BusQueue> getQueueList(BusQueue busQueue);
}
... ...
... ... @@ -76,4 +76,12 @@ public interface RoutingKeyMapper {
* @return List<RoutingKey>
*/
List<RoutingKey> validateRoutingKey(RoutingKey routingKey);
/**
* 仅,查询路由键列表
*
* @param routingKey 路由键 {@link RoutingKey}
* @return List<RoutingKey>
*/
List<RoutingKey> getRoutingKeyList(RoutingKey routingKey);
}
... ...
... ... @@ -80,7 +80,8 @@ public interface VirtualHostMapper {
/**
* 查询虚拟主机列表
*
* @param virtualHost {@link VirtualHost}
* @return 虚拟主机列表
*/
List<VirtualHost> getVirtualHostList();
List<VirtualHost> getVirtualHostList(VirtualHost virtualHost);
}
... ...
... ... @@ -83,7 +83,8 @@ public interface BusExchangeService {
/**
* 仅,查询交换机列表
*
* @param busExchange {@link BusExchange}
* @return List<BusExchange>
*/
List<BusExchange> getExchangeList();
List<BusExchange> getExchangeList(BusExchange busExchange);
}
... ...
... ... @@ -77,4 +77,12 @@ public interface BusQueueService {
* @return List<BusQueue>
*/
List<BusQueue> validateBusQueue(BusQueue busQueue);
/**
* 仅,查询队列列表
*
* @param busQueue {@link BusQueue}
* @return
*/
List<BusQueue> getQueueList(BusQueue busQueue);
}
... ...
... ... @@ -78,4 +78,12 @@ public interface RoutingKeyService {
* @return List<RoutingKey>
*/
List<RoutingKey> validateRoutingKey(RoutingKey routingKey);
/**
* 仅,查询路由键列表
*
* @param routingKey 路由键 {@link RoutingKey}
* @return List<RoutingKey>
*/
List<RoutingKey> getRoutingKeyList(RoutingKey routingKey);
}
... ...
... ... @@ -82,7 +82,8 @@ public interface VirtualHostService {
/**
* 查询虚拟主机列表
*
* @param virtualHost {@link VirtualHost}
* @return 虚拟主机列表
*/
List<VirtualHost> getVirtualHostList();
List<VirtualHost> getVirtualHostList(VirtualHost virtualHost);
}
... ...
... ... @@ -94,8 +94,8 @@ public class BusExchangeServiceImpl implements BusExchangeService {
}
@Override
public List<BusExchange> getExchangeList() {
return busExchangeMapper.getExchangeList();
public List<BusExchange> getExchangeList(BusExchange busExchange) {
return busExchangeMapper.getExchangeList(busExchange);
}
}
... ...
... ... @@ -94,4 +94,9 @@ public class BusQueueServiceImpl implements BusQueueService {
return busQueueMapper.validateBusQueue(busQueue);
}
@Override
public List<BusQueue> getQueueList(BusQueue busQueue) {
return busQueueMapper.getQueueList(busQueue);
}
}
... ...
... ... @@ -94,4 +94,9 @@ public class RoutingKeyServiceImpl implements RoutingKeyService {
return routingKeyMapper.validateRoutingKey(routingKey);
}
@Override
public List<RoutingKey> getRoutingKeyList(RoutingKey routingKey) {
return routingKeyMapper.getRoutingKeyList(routingKey);
}
}
... ...
... ... @@ -96,8 +96,8 @@ public class VirtualHostServiceImpl implements VirtualHostService {
}
@Override
public List<VirtualHost> getVirtualHostList() {
return virtualHostMapper.getVirtualHostList();
public List<VirtualHost> getVirtualHostList(VirtualHost virtualHost) {
return virtualHostMapper.getVirtualHostList(virtualHost);
}
}
... ...
package com.sunyo.wlpt.message.bus.service.vo;
import com.sunyo.wlpt.message.bus.service.domain.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author 子诚
* Description:UserMessageBinding的一个继承类,进行聚合
* 时间:2020/7/14 17:33
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserMessageBindingVO extends UserMessageBinding implements Serializable {
private static final long serialVersionUID = 5417123427960404665L;
/**
* 一条配置记录,对应一个服务器
*/
private BusServer busServer;
/**
* 一条配置记录,对应一个虚拟主机
*/
private VirtualHost virtualHost;
/**
* 一条配置记录,对应一个交换机
*/
private BusExchange busExchange;
/**
* 一条配置记录,对应一个队列
*/
private BusQueue busQueue;
/**
* 一条配置记录,对应一个路由键
*/
private RoutingKey routingKey;
}
... ...
... ... @@ -77,6 +77,12 @@
select
<include refid="Base_Column_List"/>
from bus_exchange
<where>
<!-- 所属虚拟主机ID -->
<if test="virtualHostId != null and virtualHostId !=''">
virtual_host_id = #{virtualHostId,jdbcType=VARCHAR}
</if>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
... ...
... ... @@ -67,6 +67,20 @@
</if>
</where>
</select>
<!-- 仅,查询队列列表 -->
<select id="getQueueList" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusQueue"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from bus_queue
<where>
<!-- 所属虚拟主机Id -->
<if test="virtualHostId != null and virtualHostId !=''">
virtual_host_id = #{virtualHostId,jdbcType=VARCHAR}
</if>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
<!--@mbg.generated-->
delete from bus_queue
... ...
... ... @@ -66,6 +66,19 @@
</where>
</select>
<select id="getRoutingKeyList" parameterType="com.sunyo.wlpt.message.bus.service.domain.RoutingKey"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from routing_key
<where>
<!-- 所属交换机ID -->
<if test="exchangeId != null and exchangeId !=''">
exchange_id = #{exchangeId,jdbcType=VARCHAR}
</if>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
<!--@mbg.generated-->
delete from routing_key
... ...
... ... @@ -88,6 +88,12 @@
select
<include refid="Base_Column_List"/>
from virtual_host
<where>
<!-- 所属服务器ID -->
<if test="serverId != null and serverId !=''">
server_id = #{serverId,jdbcType=VARCHAR}
</if>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
... ...