作者 王勇

init commit

... ... @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.sunyo.wlpt.message.bus.service</groupId>
<artifactId>message_bus_service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.0.0</version>
<name>message_bus_service</name>
<description>消息总线服务</description>
... ...
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.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 org.springframework.web.bind.annotation.*;
... ... @@ -26,16 +28,19 @@ public class CascadeController {
@Resource
private VirtualHostService virtualHostService;
@Resource
private BusExchangeService busExchangeService;
/**
* 仅,查询服务器列表
*
* @return {@link ResultJson}
*/
@GetMapping("/server")
public ResultJson selectServerList() {
public ResultJson getServerList() {
ResultJson result = new ResultJson();
List<BusServer> busServers = busServerService.selectAll();
List<BusServer> busServers = busServerService.getServerList();
int num = busServers.size();
if (num > 0) {
result.setCode("200");
... ... @@ -54,9 +59,9 @@ public class CascadeController {
* @return {@link ResultJson}
*/
@GetMapping("/host")
public ResultJson selectVirtualHostList() {
public ResultJson getVirtualHostList() {
ResultJson result = new ResultJson();
List<VirtualHost> virtualHosts = virtualHostService.selectAll();
List<VirtualHost> virtualHosts = virtualHostService.getVirtualHostList();
int num = virtualHosts.size();
if (num > 0) {
result.setCode("200");
... ... @@ -69,6 +74,17 @@ public class CascadeController {
return result;
}
@GetMapping("/exchange")
public ResultJson getExchangeList() {
List<BusExchange> busExchanges = busExchangeService.getExchangeList();
int num = busExchanges.size();
if (num > 0) {
return new ResultJson("200", "查询交换机列表,成功", busExchanges);
} else {
return new ResultJson("500", "查询交换机列表,失败");
}
}
/**
* 服务器与虚拟主机是1:n的关系
* 查询,服务器列表(包含虚拟机)
... ... @@ -76,14 +92,33 @@ public class CascadeController {
* @return {@link ResultJson}
*/
@GetMapping("/server_host")
public ResultJson selectServerAndHostList(){
public ResultJson getServerAndHostList() {
ResultJson result = new ResultJson();
List<BusServer> servers = busServerService.getServerAndHostList();
int num = servers.size();
if (num > 0) {
return new ResultJson("200", "查询服务器与虚拟主机信息,成功", servers);
} else {
return new ResultJson("500", "查询服务器与虚拟主机信息,失败");
}
}
/**
* 服务器与虚拟主机是1:n的关系
* 虚拟主机与交换机是1: n的关系
* 查询,服务器列表(包含虚拟机、交换机)
*
* @return {@link ResultJson}
*/
@GetMapping("/server_host_exchange")
public ResultJson getServerAndHostAndExchangeList() {
ResultJson result = new ResultJson();
List<BusServer> servers = busServerService.selectServerAndHostList();
List<BusServer> servers = busServerService.getServerAndHostAndExchangeList();
int num = servers.size();
if (num > 0) {
return new ResultJson("200","查询服务器列表,成功",servers);
return new ResultJson("200", "查询服务器与虚拟主机信息,成功", servers);
} else {
return new ResultJson("500","查询服务器列表,失败");
return new ResultJson("500", "查询服务器与虚拟主机信息,失败");
}
}
}
... ...
... ... @@ -2,6 +2,7 @@ package com.sunyo.wlpt.message.bus.service.domain;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
... ... @@ -58,6 +59,11 @@ public class VirtualHost implements Serializable {
private BusServer busServer;
/**
* 一个虚拟主机对应多个交换机
*/
private List<BusExchange> busExchanges;
/**
* 虚拟主机名称的别名
*/
private String aliasName;
... ...
... ... @@ -76,4 +76,11 @@ public interface BusExchangeMapper {
* @return List<BusExchange>
*/
List<BusExchange> validateBusExchange(BusExchange busExchange);
/**
* 仅,查询交换机列表
*
* @return List<BusExchange>
*/
List<BusExchange> getExchangeList();
}
... ...
... ... @@ -82,12 +82,21 @@ public interface BusServerMapper {
*
* @return 服务器列表
*/
List<BusServer> selectAll();
List<BusServer> getServerList();
/**
* 查询,服务器(1:n虚拟主机)的基本信息
*
* @return List<BusServer>
*/
List<BusServer> selectServerAndHostList();
List<BusServer> getServerAndHostList();
/**
* 服务器与虚拟主机是1:n的关系
* 虚拟主机与交换机是1: n的关系
* 查询,服务器列表(包含虚拟机、交换机)
*
* @return List<BusServer>
*/
List<BusServer> getServerAndHostAndExchangeList();
}
... ...
... ... @@ -82,5 +82,5 @@ public interface VirtualHostMapper {
*
* @return 虚拟主机列表
*/
List<VirtualHost> selectAll();
List<VirtualHost> getVirtualHostList();
}
... ...
... ... @@ -79,4 +79,11 @@ public interface BusExchangeService {
* @return List<BusExchange>
*/
List<BusExchange> validateBusExchange(BusExchange busExchange);
/**
* 仅,查询交换机列表
*
* @return List<BusExchange>
*/
List<BusExchange> getExchangeList();
}
... ...
... ... @@ -83,12 +83,21 @@ public interface BusServerService {
*
* @return 服务器列表
*/
List<BusServer> selectAll();
List<BusServer> getServerList();
/**
* 查询,服务器(1:n虚拟主机)的基本信息
*
* @return List<BusServer>
*/
List<BusServer> selectServerAndHostList();
List<BusServer> getServerAndHostList();
/**
* 服务器与虚拟主机是1:n的关系
* 虚拟主机与交换机是1: n的关系
* 查询,服务器列表(包含虚拟机、交换机)
*
* @return List<BusServer>
*/
List<BusServer> getServerAndHostAndExchangeList();
}
... ...
... ... @@ -84,5 +84,5 @@ public interface VirtualHostService {
*
* @return 虚拟主机列表
*/
List<VirtualHost> selectAll();
List<VirtualHost> getVirtualHostList();
}
... ...
... ... @@ -93,4 +93,9 @@ public class BusExchangeServiceImpl implements BusExchangeService {
return busExchangeMapper.validateBusExchange(busExchange);
}
@Override
public List<BusExchange> getExchangeList() {
return busExchangeMapper.getExchangeList();
}
}
... ...
... ... @@ -95,12 +95,17 @@ public class BusServerServiceImpl implements BusServerService {
}
@Override
public List<BusServer> selectAll() {
return busServerMapper.selectAll();
public List<BusServer> getServerList() {
return busServerMapper.getServerList();
}
@Override
public List<BusServer> selectServerAndHostList() {
return busServerMapper.selectServerAndHostList();
public List<BusServer> getServerAndHostList() {
return busServerMapper.getServerAndHostList();
}
@Override
public List<BusServer> getServerAndHostAndExchangeList() {
return busServerMapper.getServerAndHostAndExchangeList();
}
}
... ...
... ... @@ -96,8 +96,8 @@ public class VirtualHostServiceImpl implements VirtualHostService {
}
@Override
public List<VirtualHost> selectAll() {
return virtualHostMapper.selectAll();
public List<VirtualHost> getVirtualHostList() {
return virtualHostMapper.getVirtualHostList();
}
}
... ...
... ... @@ -72,6 +72,12 @@
</if>
</where>
</select>
<!-- 仅,查询交换机列表 -->
<select id="getExchangeList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from bus_exchange
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
<!--@mbg.generated-->
... ...
... ... @@ -16,13 +16,26 @@
<!-- 该Mapper映射关系的作用,是服务器与虚拟主机的1:n的关系映射 -->
<resultMap id="ServerAndVirtualHostMap" type="com.sunyo.wlpt.message.bus.service.domain.BusServer"
extends="BaseResultMap">
<collection property="virtualHosts" ofType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost">
<id column="vid" jdbcType="VARCHAR" property="id"/>
<result column="virtual_host_name" jdbcType="VARCHAR" property="virtualHostName"/>
<result column="virtual_host_name" jdbcType="VARCHAR" property="aliasName"/>
</collection>
</resultMap>
<!-- 该Mapper映射关系的作用,服务器:虚拟主机—>1:n ; 虚拟主机:交换机—>1:n 的关系映射 -->
<resultMap id="ServerAndHostAndExchangeMap" type="com.sunyo.wlpt.message.bus.service.domain.BusServer"
extends="BaseResultMap">
<collection property="virtualHosts" ofType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost">
<id column="vid" jdbcType="VARCHAR" property="id"/>
<result column="virtual_host_name" jdbcType="VARCHAR" property="virtualHostName"/>
<result column="virtual_host_name" jdbcType="VARCHAR" property="aliasName"/>
<collection property="busExchanges" ofType="com.sunyo.wlpt.message.bus.service.domain.BusExchange">
<id column="eid" jdbcType="VARCHAR" property="id"/>
<result column="exchange_name" jdbcType="VARCHAR" property="exchangeName"/>
<result column="exchange_name" jdbcType="VARCHAR" property="aliasName"/>
</collection>
</collection>
</resultMap>
<sql id="Base_Column_List">
... ... @@ -39,19 +52,28 @@
</select>
<!-- 获取服务器列表,可能要级联或者懒加载 -->
<select id="selectAll" resultMap="BaseResultMap">
<select id="getServerList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from bus_server
</select>
<!-- 查询服务器和虚拟主机基本信息(id,名称) -->
<select id="selectServerAndHostList" resultMap="ServerAndVirtualHostMap">
<select id="getServerAndHostList" resultMap="ServerAndVirtualHostMap">
select
s.id,s.server_name,v.id as vid,v.virtual_host_name
from bus_server as s, virtual_host as v
where s.id = v.server_id
</select>
<!-- 查询服务器和虚拟主机以及虚拟机基本信息(id,名称) -->
<select id="getServerAndHostAndExchangeList" resultMap="ServerAndHostAndExchangeMap">
select
s.id,s.server_name,v.id as vid,v.virtual_host_name,e.id as eid,e.exchange_name
from bus_server as s, virtual_host as v,bus_exchange as e
where s.id = v.server_id
and vid = e.virtual_host_id
</select>
<!-- 获取服务器列表,分页 -->
<select id="selectBusServerList" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer"
resultMap="BaseResultMap">
... ...
... ... @@ -36,7 +36,7 @@
<!-- 查询路由键列表 -->
<select id="selectRoutingKeyList" parameterType="com.sunyo.wlpt.message.bus.service.domain.RoutingKey"
resultMap="BaseResultMap">
resultMap="RoutingKeyAndExchangeMap">
select
r.id, r.routing_key_name, r.exchange_id, r.description, r.gmt_create, r.gmt_modified, e.exchange_name
from routing_key as r,bus_exchange as e
... ...
... ... @@ -84,7 +84,7 @@
</where>
</select>
<!-- 查询全部虚拟主机列表 -->
<select id="selectAll" resultMap="BaseResultMap">
<select id="getVirtualHostList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from virtual_host
... ...