作者 王勇

init commit

@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 <modelVersion>4.0.0</modelVersion> 4 <modelVersion>4.0.0</modelVersion>
5 <groupId>com.sunyo.wlpt.message.bus.service</groupId> 5 <groupId>com.sunyo.wlpt.message.bus.service</groupId>
6 <artifactId>message_bus_service</artifactId> 6 <artifactId>message_bus_service</artifactId>
7 - <version>0.0.1-SNAPSHOT</version> 7 + <version>1.0.0</version>
8 <name>message_bus_service</name> 8 <name>message_bus_service</name>
9 <description>消息总线服务</description> 9 <description>消息总线服务</description>
10 10
1 package com.sunyo.wlpt.message.bus.service.controller; 1 package com.sunyo.wlpt.message.bus.service.controller;
2 2
3 3
  4 +import com.sunyo.wlpt.message.bus.service.domain.BusExchange;
4 import com.sunyo.wlpt.message.bus.service.domain.BusServer; 5 import com.sunyo.wlpt.message.bus.service.domain.BusServer;
5 import com.sunyo.wlpt.message.bus.service.domain.VirtualHost; 6 import com.sunyo.wlpt.message.bus.service.domain.VirtualHost;
6 import com.sunyo.wlpt.message.bus.service.response.ResultJson; 7 import com.sunyo.wlpt.message.bus.service.response.ResultJson;
  8 +import com.sunyo.wlpt.message.bus.service.service.BusExchangeService;
7 import com.sunyo.wlpt.message.bus.service.service.BusServerService; 9 import com.sunyo.wlpt.message.bus.service.service.BusServerService;
8 import com.sunyo.wlpt.message.bus.service.service.VirtualHostService; 10 import com.sunyo.wlpt.message.bus.service.service.VirtualHostService;
9 import org.springframework.web.bind.annotation.*; 11 import org.springframework.web.bind.annotation.*;
@@ -26,16 +28,19 @@ public class CascadeController { @@ -26,16 +28,19 @@ public class CascadeController {
26 @Resource 28 @Resource
27 private VirtualHostService virtualHostService; 29 private VirtualHostService virtualHostService;
28 30
  31 + @Resource
  32 + private BusExchangeService busExchangeService;
  33 +
29 /** 34 /**
30 * 仅,查询服务器列表 35 * 仅,查询服务器列表
31 * 36 *
32 * @return {@link ResultJson} 37 * @return {@link ResultJson}
33 */ 38 */
34 @GetMapping("/server") 39 @GetMapping("/server")
35 - public ResultJson selectServerList() { 40 + public ResultJson getServerList() {
36 41
37 ResultJson result = new ResultJson(); 42 ResultJson result = new ResultJson();
38 - List<BusServer> busServers = busServerService.selectAll(); 43 + List<BusServer> busServers = busServerService.getServerList();
39 int num = busServers.size(); 44 int num = busServers.size();
40 if (num > 0) { 45 if (num > 0) {
41 result.setCode("200"); 46 result.setCode("200");
@@ -54,9 +59,9 @@ public class CascadeController { @@ -54,9 +59,9 @@ public class CascadeController {
54 * @return {@link ResultJson} 59 * @return {@link ResultJson}
55 */ 60 */
56 @GetMapping("/host") 61 @GetMapping("/host")
57 - public ResultJson selectVirtualHostList() { 62 + public ResultJson getVirtualHostList() {
58 ResultJson result = new ResultJson(); 63 ResultJson result = new ResultJson();
59 - List<VirtualHost> virtualHosts = virtualHostService.selectAll(); 64 + List<VirtualHost> virtualHosts = virtualHostService.getVirtualHostList();
60 int num = virtualHosts.size(); 65 int num = virtualHosts.size();
61 if (num > 0) { 66 if (num > 0) {
62 result.setCode("200"); 67 result.setCode("200");
@@ -69,6 +74,17 @@ public class CascadeController { @@ -69,6 +74,17 @@ public class CascadeController {
69 return result; 74 return result;
70 } 75 }
71 76
  77 + @GetMapping("/exchange")
  78 + public ResultJson getExchangeList() {
  79 + List<BusExchange> busExchanges = busExchangeService.getExchangeList();
  80 + int num = busExchanges.size();
  81 + if (num > 0) {
  82 + return new ResultJson("200", "查询交换机列表,成功", busExchanges);
  83 + } else {
  84 + return new ResultJson("500", "查询交换机列表,失败");
  85 + }
  86 + }
  87 +
72 /** 88 /**
73 * 服务器与虚拟主机是1:n的关系 89 * 服务器与虚拟主机是1:n的关系
74 * 查询,服务器列表(包含虚拟机) 90 * 查询,服务器列表(包含虚拟机)
@@ -76,14 +92,33 @@ public class CascadeController { @@ -76,14 +92,33 @@ public class CascadeController {
76 * @return {@link ResultJson} 92 * @return {@link ResultJson}
77 */ 93 */
78 @GetMapping("/server_host") 94 @GetMapping("/server_host")
79 - public ResultJson selectServerAndHostList(){ 95 + public ResultJson getServerAndHostList() {
  96 + ResultJson result = new ResultJson();
  97 + List<BusServer> servers = busServerService.getServerAndHostList();
  98 + int num = servers.size();
  99 + if (num > 0) {
  100 + return new ResultJson("200", "查询服务器与虚拟主机信息,成功", servers);
  101 + } else {
  102 + return new ResultJson("500", "查询服务器与虚拟主机信息,失败");
  103 + }
  104 + }
  105 +
  106 + /**
  107 + * 服务器与虚拟主机是1:n的关系
  108 + * 虚拟主机与交换机是1: n的关系
  109 + * 查询,服务器列表(包含虚拟机、交换机)
  110 + *
  111 + * @return {@link ResultJson}
  112 + */
  113 + @GetMapping("/server_host_exchange")
  114 + public ResultJson getServerAndHostAndExchangeList() {
80 ResultJson result = new ResultJson(); 115 ResultJson result = new ResultJson();
81 - List<BusServer> servers = busServerService.selectServerAndHostList(); 116 + List<BusServer> servers = busServerService.getServerAndHostAndExchangeList();
82 int num = servers.size(); 117 int num = servers.size();
83 if (num > 0) { 118 if (num > 0) {
84 - return new ResultJson("200","查询服务器列表,成功",servers); 119 + return new ResultJson("200", "查询服务器与虚拟主机信息,成功", servers);
85 } else { 120 } else {
86 - return new ResultJson("500","查询服务器列表,失败"); 121 + return new ResultJson("500", "查询服务器与虚拟主机信息,失败");
87 } 122 }
88 } 123 }
89 } 124 }
@@ -2,6 +2,7 @@ package com.sunyo.wlpt.message.bus.service.domain; @@ -2,6 +2,7 @@ package com.sunyo.wlpt.message.bus.service.domain;
2 2
3 import java.io.Serializable; 3 import java.io.Serializable;
4 import java.util.Date; 4 import java.util.Date;
  5 +import java.util.List;
5 6
6 import com.fasterxml.jackson.annotation.JsonFormat; 7 import com.fasterxml.jackson.annotation.JsonFormat;
7 import lombok.AllArgsConstructor; 8 import lombok.AllArgsConstructor;
@@ -58,6 +59,11 @@ public class VirtualHost implements Serializable { @@ -58,6 +59,11 @@ public class VirtualHost implements Serializable {
58 private BusServer busServer; 59 private BusServer busServer;
59 60
60 /** 61 /**
  62 + * 一个虚拟主机对应多个交换机
  63 + */
  64 + private List<BusExchange> busExchanges;
  65 +
  66 + /**
61 * 虚拟主机名称的别名 67 * 虚拟主机名称的别名
62 */ 68 */
63 private String aliasName; 69 private String aliasName;
@@ -76,4 +76,11 @@ public interface BusExchangeMapper { @@ -76,4 +76,11 @@ public interface BusExchangeMapper {
76 * @return List<BusExchange> 76 * @return List<BusExchange>
77 */ 77 */
78 List<BusExchange> validateBusExchange(BusExchange busExchange); 78 List<BusExchange> validateBusExchange(BusExchange busExchange);
  79 +
  80 + /**
  81 + * 仅,查询交换机列表
  82 + *
  83 + * @return List<BusExchange>
  84 + */
  85 + List<BusExchange> getExchangeList();
79 } 86 }
@@ -82,12 +82,21 @@ public interface BusServerMapper { @@ -82,12 +82,21 @@ public interface BusServerMapper {
82 * 82 *
83 * @return 服务器列表 83 * @return 服务器列表
84 */ 84 */
85 - List<BusServer> selectAll(); 85 + List<BusServer> getServerList();
86 86
87 /** 87 /**
88 * 查询,服务器(1:n虚拟主机)的基本信息 88 * 查询,服务器(1:n虚拟主机)的基本信息
89 * 89 *
90 * @return List<BusServer> 90 * @return List<BusServer>
91 */ 91 */
92 - List<BusServer> selectServerAndHostList(); 92 + List<BusServer> getServerAndHostList();
  93 +
  94 + /**
  95 + * 服务器与虚拟主机是1:n的关系
  96 + * 虚拟主机与交换机是1: n的关系
  97 + * 查询,服务器列表(包含虚拟机、交换机)
  98 + *
  99 + * @return List<BusServer>
  100 + */
  101 + List<BusServer> getServerAndHostAndExchangeList();
93 } 102 }
@@ -82,5 +82,5 @@ public interface VirtualHostMapper { @@ -82,5 +82,5 @@ public interface VirtualHostMapper {
82 * 82 *
83 * @return 虚拟主机列表 83 * @return 虚拟主机列表
84 */ 84 */
85 - List<VirtualHost> selectAll(); 85 + List<VirtualHost> getVirtualHostList();
86 } 86 }
@@ -79,4 +79,11 @@ public interface BusExchangeService { @@ -79,4 +79,11 @@ public interface BusExchangeService {
79 * @return List<BusExchange> 79 * @return List<BusExchange>
80 */ 80 */
81 List<BusExchange> validateBusExchange(BusExchange busExchange); 81 List<BusExchange> validateBusExchange(BusExchange busExchange);
  82 +
  83 + /**
  84 + * 仅,查询交换机列表
  85 + *
  86 + * @return List<BusExchange>
  87 + */
  88 + List<BusExchange> getExchangeList();
82 } 89 }
@@ -83,12 +83,21 @@ public interface BusServerService { @@ -83,12 +83,21 @@ public interface BusServerService {
83 * 83 *
84 * @return 服务器列表 84 * @return 服务器列表
85 */ 85 */
86 - List<BusServer> selectAll(); 86 + List<BusServer> getServerList();
87 87
88 /** 88 /**
89 * 查询,服务器(1:n虚拟主机)的基本信息 89 * 查询,服务器(1:n虚拟主机)的基本信息
90 * 90 *
91 * @return List<BusServer> 91 * @return List<BusServer>
92 */ 92 */
93 - List<BusServer> selectServerAndHostList(); 93 + List<BusServer> getServerAndHostList();
  94 +
  95 + /**
  96 + * 服务器与虚拟主机是1:n的关系
  97 + * 虚拟主机与交换机是1: n的关系
  98 + * 查询,服务器列表(包含虚拟机、交换机)
  99 + *
  100 + * @return List<BusServer>
  101 + */
  102 + List<BusServer> getServerAndHostAndExchangeList();
94 } 103 }
@@ -84,5 +84,5 @@ public interface VirtualHostService { @@ -84,5 +84,5 @@ public interface VirtualHostService {
84 * 84 *
85 * @return 虚拟主机列表 85 * @return 虚拟主机列表
86 */ 86 */
87 - List<VirtualHost> selectAll(); 87 + List<VirtualHost> getVirtualHostList();
88 } 88 }
@@ -93,4 +93,9 @@ public class BusExchangeServiceImpl implements BusExchangeService { @@ -93,4 +93,9 @@ public class BusExchangeServiceImpl implements BusExchangeService {
93 return busExchangeMapper.validateBusExchange(busExchange); 93 return busExchangeMapper.validateBusExchange(busExchange);
94 } 94 }
95 95
  96 + @Override
  97 + public List<BusExchange> getExchangeList() {
  98 + return busExchangeMapper.getExchangeList();
  99 + }
  100 +
96 } 101 }
@@ -95,12 +95,17 @@ public class BusServerServiceImpl implements BusServerService { @@ -95,12 +95,17 @@ public class BusServerServiceImpl implements BusServerService {
95 } 95 }
96 96
97 @Override 97 @Override
98 - public List<BusServer> selectAll() {  
99 - return busServerMapper.selectAll(); 98 + public List<BusServer> getServerList() {
  99 + return busServerMapper.getServerList();
100 } 100 }
101 101
102 @Override 102 @Override
103 - public List<BusServer> selectServerAndHostList() {  
104 - return busServerMapper.selectServerAndHostList(); 103 + public List<BusServer> getServerAndHostList() {
  104 + return busServerMapper.getServerAndHostList();
  105 + }
  106 +
  107 + @Override
  108 + public List<BusServer> getServerAndHostAndExchangeList() {
  109 + return busServerMapper.getServerAndHostAndExchangeList();
105 } 110 }
106 } 111 }
@@ -96,8 +96,8 @@ public class VirtualHostServiceImpl implements VirtualHostService { @@ -96,8 +96,8 @@ public class VirtualHostServiceImpl implements VirtualHostService {
96 } 96 }
97 97
98 @Override 98 @Override
99 - public List<VirtualHost> selectAll() {  
100 - return virtualHostMapper.selectAll(); 99 + public List<VirtualHost> getVirtualHostList() {
  100 + return virtualHostMapper.getVirtualHostList();
101 } 101 }
102 102
103 } 103 }
@@ -72,6 +72,12 @@ @@ -72,6 +72,12 @@
72 </if> 72 </if>
73 </where> 73 </where>
74 </select> 74 </select>
  75 + <!-- 仅,查询交换机列表 -->
  76 + <select id="getExchangeList" resultMap="BaseResultMap">
  77 + select
  78 + <include refid="Base_Column_List"/>
  79 + from bus_exchange
  80 + </select>
75 81
76 <delete id="deleteByPrimaryKey" parameterType="java.lang.String"> 82 <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
77 <!--@mbg.generated--> 83 <!--@mbg.generated-->
@@ -16,13 +16,26 @@ @@ -16,13 +16,26 @@
16 <!-- 该Mapper映射关系的作用,是服务器与虚拟主机的1:n的关系映射 --> 16 <!-- 该Mapper映射关系的作用,是服务器与虚拟主机的1:n的关系映射 -->
17 <resultMap id="ServerAndVirtualHostMap" type="com.sunyo.wlpt.message.bus.service.domain.BusServer" 17 <resultMap id="ServerAndVirtualHostMap" type="com.sunyo.wlpt.message.bus.service.domain.BusServer"
18 extends="BaseResultMap"> 18 extends="BaseResultMap">
19 -  
20 <collection property="virtualHosts" ofType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost"> 19 <collection property="virtualHosts" ofType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost">
21 <id column="vid" jdbcType="VARCHAR" property="id"/> 20 <id column="vid" jdbcType="VARCHAR" property="id"/>
22 <result column="virtual_host_name" jdbcType="VARCHAR" property="virtualHostName"/> 21 <result column="virtual_host_name" jdbcType="VARCHAR" property="virtualHostName"/>
23 <result column="virtual_host_name" jdbcType="VARCHAR" property="aliasName"/> 22 <result column="virtual_host_name" jdbcType="VARCHAR" property="aliasName"/>
24 </collection> 23 </collection>
25 </resultMap> 24 </resultMap>
  25 + <!-- 该Mapper映射关系的作用,服务器:虚拟主机—>1:n ; 虚拟主机:交换机—>1:n 的关系映射 -->
  26 + <resultMap id="ServerAndHostAndExchangeMap" type="com.sunyo.wlpt.message.bus.service.domain.BusServer"
  27 + extends="BaseResultMap">
  28 + <collection property="virtualHosts" ofType="com.sunyo.wlpt.message.bus.service.domain.VirtualHost">
  29 + <id column="vid" jdbcType="VARCHAR" property="id"/>
  30 + <result column="virtual_host_name" jdbcType="VARCHAR" property="virtualHostName"/>
  31 + <result column="virtual_host_name" jdbcType="VARCHAR" property="aliasName"/>
  32 + <collection property="busExchanges" ofType="com.sunyo.wlpt.message.bus.service.domain.BusExchange">
  33 + <id column="eid" jdbcType="VARCHAR" property="id"/>
  34 + <result column="exchange_name" jdbcType="VARCHAR" property="exchangeName"/>
  35 + <result column="exchange_name" jdbcType="VARCHAR" property="aliasName"/>
  36 + </collection>
  37 + </collection>
  38 + </resultMap>
26 39
27 40
28 <sql id="Base_Column_List"> 41 <sql id="Base_Column_List">
@@ -39,19 +52,28 @@ @@ -39,19 +52,28 @@
39 </select> 52 </select>
40 53
41 <!-- 获取服务器列表,可能要级联或者懒加载 --> 54 <!-- 获取服务器列表,可能要级联或者懒加载 -->
42 - <select id="selectAll" resultMap="BaseResultMap"> 55 + <select id="getServerList" resultMap="BaseResultMap">
43 select 56 select
44 <include refid="Base_Column_List"/> 57 <include refid="Base_Column_List"/>
45 from bus_server 58 from bus_server
46 </select> 59 </select>
47 60
48 <!-- 查询服务器和虚拟主机基本信息(id,名称) --> 61 <!-- 查询服务器和虚拟主机基本信息(id,名称) -->
49 - <select id="selectServerAndHostList" resultMap="ServerAndVirtualHostMap"> 62 + <select id="getServerAndHostList" resultMap="ServerAndVirtualHostMap">
50 select 63 select
51 s.id,s.server_name,v.id as vid,v.virtual_host_name 64 s.id,s.server_name,v.id as vid,v.virtual_host_name
52 from bus_server as s, virtual_host as v 65 from bus_server as s, virtual_host as v
53 where s.id = v.server_id 66 where s.id = v.server_id
54 </select> 67 </select>
  68 +
  69 + <!-- 查询服务器和虚拟主机以及虚拟机基本信息(id,名称) -->
  70 + <select id="getServerAndHostAndExchangeList" resultMap="ServerAndHostAndExchangeMap">
  71 + select
  72 + s.id,s.server_name,v.id as vid,v.virtual_host_name,e.id as eid,e.exchange_name
  73 + from bus_server as s, virtual_host as v,bus_exchange as e
  74 + where s.id = v.server_id
  75 + and vid = e.virtual_host_id
  76 + </select>
55 <!-- 获取服务器列表,分页 --> 77 <!-- 获取服务器列表,分页 -->
56 <select id="selectBusServerList" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer" 78 <select id="selectBusServerList" parameterType="com.sunyo.wlpt.message.bus.service.domain.BusServer"
57 resultMap="BaseResultMap"> 79 resultMap="BaseResultMap">
@@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
36 36
37 <!-- 查询路由键列表 --> 37 <!-- 查询路由键列表 -->
38 <select id="selectRoutingKeyList" parameterType="com.sunyo.wlpt.message.bus.service.domain.RoutingKey" 38 <select id="selectRoutingKeyList" parameterType="com.sunyo.wlpt.message.bus.service.domain.RoutingKey"
39 - resultMap="BaseResultMap"> 39 + resultMap="RoutingKeyAndExchangeMap">
40 select 40 select
41 r.id, r.routing_key_name, r.exchange_id, r.description, r.gmt_create, r.gmt_modified, e.exchange_name 41 r.id, r.routing_key_name, r.exchange_id, r.description, r.gmt_create, r.gmt_modified, e.exchange_name
42 from routing_key as r,bus_exchange as e 42 from routing_key as r,bus_exchange as e
@@ -84,7 +84,7 @@ @@ -84,7 +84,7 @@
84 </where> 84 </where>
85 </select> 85 </select>
86 <!-- 查询全部虚拟主机列表 --> 86 <!-- 查询全部虚拟主机列表 -->
87 - <select id="selectAll" resultMap="BaseResultMap"> 87 + <select id="getVirtualHostList" resultMap="BaseResultMap">
88 select 88 select
89 <include refid="Base_Column_List"/> 89 <include refid="Base_Column_List"/>
90 from virtual_host 90 from virtual_host