正在显示
5 个修改的文件
包含
77 行增加
和
91 行删除
@@ -7,4 +7,8 @@ package com.sunyo.wlpt.message.bus.service.common; | @@ -7,4 +7,8 @@ package com.sunyo.wlpt.message.bus.service.common; | ||
7 | */ | 7 | */ |
8 | public class Constant { | 8 | public class Constant { |
9 | public static final String EXIST_SERVERNAME = "MQ服务器名称已存在"; | 9 | public static final String EXIST_SERVERNAME = "MQ服务器名称已存在"; |
10 | + public static final String EXIST_SERVER_INFO = "该-MQ服务器(ServerIp以及ServerPort)-信息已存在,请谨慎输入"; | ||
11 | + | ||
12 | + public static final String EXIST_HOST_INFO = "该-虚拟主机(虚拟主机名称)-信息已存在,请谨慎输入"; | ||
13 | + | ||
10 | } | 14 | } |
@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*; | @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*; | ||
10 | import javax.annotation.Resource; | 10 | import javax.annotation.Resource; |
11 | import java.util.List; | 11 | import java.util.List; |
12 | 12 | ||
13 | +import static com.sunyo.wlpt.message.bus.service.common.Constant.EXIST_SERVER_INFO; | ||
13 | import static com.sunyo.wlpt.message.bus.service.common.Constant.EXIST_SERVERNAME; | 14 | import static com.sunyo.wlpt.message.bus.service.common.Constant.EXIST_SERVERNAME; |
14 | 15 | ||
15 | /** | 16 | /** |
@@ -38,12 +39,11 @@ public class BusServerController { | @@ -38,12 +39,11 @@ public class BusServerController { | ||
38 | @RequestParam(value = "serverName", required = false) String serverName, | 39 | @RequestParam(value = "serverName", required = false) String serverName, |
39 | @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, | 40 | @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, |
40 | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { | 41 | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { |
41 | - BusServer busServer = new BusServer(); | ||
42 | - // 获取参数,服务器名称 | ||
43 | - busServer.setServerName(serverName); | ||
44 | // 分页查询 | 42 | // 分页查询 |
45 | - PageInfo pageInfo = busServerService.selectBusServerList(busServer, pageNum, pageSize); | ||
46 | - return pageInfo.getTotal() > 0 ? new ResultJson<>("200", "查询MQ服务器列表,成功!", pageInfo) : new ResultJson<>("500", "查询MQ服务器列表,失败!"); | 43 | + PageInfo pageInfo = busServerService.selectBusServerList(new BusServer(serverName), pageNum, pageSize); |
44 | + return pageInfo.getTotal() > 0 | ||
45 | + ? new ResultJson<>("200", "查询MQ服务器列表,成功!", pageInfo) | ||
46 | + : new ResultJson<>("500", "查询MQ服务器列表,失败!"); | ||
47 | } | 47 | } |
48 | 48 | ||
49 | /** | 49 | /** |
@@ -54,8 +54,9 @@ public class BusServerController { | @@ -54,8 +54,9 @@ public class BusServerController { | ||
54 | */ | 54 | */ |
55 | @DeleteMapping("/delete") | 55 | @DeleteMapping("/delete") |
56 | public ResultJson deleteBusServer(@RequestBody BusServer busServer) { | 56 | public ResultJson deleteBusServer(@RequestBody BusServer busServer) { |
57 | - int num = busServerService.deleteByPrimaryKey(busServer.getId()); | ||
58 | - return num > 0 ? new ResultJson<>("200", "删除MQ服务器,成功") : new ResultJson<>("500", "删除MQ服务器,失败"); | 57 | + return busServerService.deleteByPrimaryKey(busServer.getId()) > 0 |
58 | + ? new ResultJson<>("200", "删除MQ服务器,成功") | ||
59 | + : new ResultJson<>("500", "删除MQ服务器,失败"); | ||
59 | } | 60 | } |
60 | 61 | ||
61 | /** | 62 | /** |
@@ -66,8 +67,9 @@ public class BusServerController { | @@ -66,8 +67,9 @@ public class BusServerController { | ||
66 | */ | 67 | */ |
67 | @GetMapping("/batchRemove") | 68 | @GetMapping("/batchRemove") |
68 | public ResultJson batchRemoveBusServer(String ids) { | 69 | public ResultJson batchRemoveBusServer(String ids) { |
69 | - int num = busServerService.deleteByPrimaryKey(ids); | ||
70 | - return num > 0 ? new ResultJson<>("200", "批量删除服务器,成功") : new ResultJson<>("500", "批量删除服务器,失败"); | 70 | + return busServerService.deleteByPrimaryKey(ids) > 0 |
71 | + ? new ResultJson<>("200", "批量删除服务器,成功") | ||
72 | + : new ResultJson<>("500", "批量删除服务器,失败"); | ||
71 | } | 73 | } |
72 | 74 | ||
73 | /** | 75 | /** |
@@ -85,8 +87,9 @@ public class BusServerController { | @@ -85,8 +87,9 @@ public class BusServerController { | ||
85 | } | 87 | } |
86 | //验证通过 | 88 | //验证通过 |
87 | if (message == null) { | 89 | if (message == null) { |
88 | - int num = busServerService.updateByPrimaryKeySelective(busServer); | ||
89 | - return num > 0 ? new ResultJson<>("200", "修改服务器信息,成功") : new ResultJson<>("500", "修改服务器信息,失败"); | 90 | + return busServerService.updateByPrimaryKeySelective(busServer) > 0 |
91 | + ? new ResultJson<>("200", "修改服务器信息,成功") | ||
92 | + : new ResultJson<>("500", "修改服务器信息,失败"); | ||
90 | } | 93 | } |
91 | return new ResultJson<>("400", message); | 94 | return new ResultJson<>("400", message); |
92 | } | 95 | } |
@@ -108,8 +111,9 @@ public class BusServerController { | @@ -108,8 +111,9 @@ public class BusServerController { | ||
108 | if (message == null) { | 111 | if (message == null) { |
109 | // 设置id | 112 | // 设置id |
110 | busServer.setId(IdUtils.generateId()); | 113 | busServer.setId(IdUtils.generateId()); |
111 | - int num = busServerService.insertSelective(busServer); | ||
112 | - return num > 0 ? new ResultJson<>("200", "添加服务器信息,成功") : new ResultJson<>("500", "添加服务器信息,失败"); | 114 | + return busServerService.insertSelective(busServer) > 0 |
115 | + ? new ResultJson<>("200", "添加服务器信息,成功") | ||
116 | + : new ResultJson<>("500", "添加服务器信息,失败"); | ||
113 | } | 117 | } |
114 | return new ResultJson<>("400", message); | 118 | return new ResultJson<>("400", message); |
115 | } | 119 | } |
@@ -158,7 +162,7 @@ public class BusServerController { | @@ -158,7 +162,7 @@ public class BusServerController { | ||
158 | List<BusServer> info = busServerService.validateBusServer(busServer); | 162 | List<BusServer> info = busServerService.validateBusServer(busServer); |
159 | // 多于0个,则代表已存在;等于0个,校验通过 | 163 | // 多于0个,则代表已存在;等于0个,校验通过 |
160 | if (info.size() > 0) { | 164 | if (info.size() > 0) { |
161 | - return "该-MQ服务器(ServerIp以及ServerPort)-信息已存在,请谨慎输入"; | 165 | + return EXIST_SERVER_INFO; |
162 | } | 166 | } |
163 | return null; | 167 | return null; |
164 | } | 168 | } |
@@ -176,7 +180,7 @@ public class BusServerController { | @@ -176,7 +180,7 @@ public class BusServerController { | ||
176 | List<BusServer> info = busServerService.validateBusServer(busServer); | 180 | List<BusServer> info = busServerService.validateBusServer(busServer); |
177 | // 多于0个,则代表已存在;否则则是,校验通过 | 181 | // 多于0个,则代表已存在;否则则是,校验通过 |
178 | if (info.size() > 0) { | 182 | if (info.size() > 0) { |
179 | - return "该-MQ服务器(ServerIp以及ServerPort)-信息已存在,请谨慎输入"; | 183 | + return EXIST_SERVER_INFO; |
180 | } | 184 | } |
181 | return null; | 185 | return null; |
182 | } | 186 | } |
1 | package com.sunyo.wlpt.message.bus.service.controller; | 1 | package com.sunyo.wlpt.message.bus.service.controller; |
2 | 2 | ||
3 | import com.github.pagehelper.PageInfo; | 3 | import com.github.pagehelper.PageInfo; |
4 | -import com.sunyo.wlpt.message.bus.service.domain.BusQueue; | ||
5 | import com.sunyo.wlpt.message.bus.service.domain.VirtualHost; | 4 | import com.sunyo.wlpt.message.bus.service.domain.VirtualHost; |
6 | import com.sunyo.wlpt.message.bus.service.response.ResultJson; | 5 | import com.sunyo.wlpt.message.bus.service.response.ResultJson; |
7 | import com.sunyo.wlpt.message.bus.service.service.VirtualHostService; | 6 | import com.sunyo.wlpt.message.bus.service.service.VirtualHostService; |
@@ -11,6 +10,8 @@ import org.springframework.web.bind.annotation.*; | @@ -11,6 +10,8 @@ import org.springframework.web.bind.annotation.*; | ||
11 | import javax.annotation.Resource; | 10 | import javax.annotation.Resource; |
12 | import java.util.List; | 11 | import java.util.List; |
13 | 12 | ||
13 | +import static com.sunyo.wlpt.message.bus.service.common.Constant.EXIST_HOST_INFO; | ||
14 | + | ||
14 | /** | 15 | /** |
15 | * @author 子诚 | 16 | * @author 子诚 |
16 | * Description:关于MQ虚拟主机信息的控制器 | 17 | * Description:关于MQ虚拟主机信息的控制器 |
@@ -34,28 +35,16 @@ public class VirtualHostController { | @@ -34,28 +35,16 @@ public class VirtualHostController { | ||
34 | * @return 成功返回,虚拟主机列表 | 35 | * @return 成功返回,虚拟主机列表 |
35 | */ | 36 | */ |
36 | @GetMapping("/list") | 37 | @GetMapping("/list") |
37 | - public ResultJson<PageInfo> selectVirtualHostList( | ||
38 | - @RequestParam(value = "serverId", required = false) String serverId, | 38 | + public ResultJson selectVirtualHostList( |
39 | @RequestParam(value = "virtualHostName", required = false) String virtualHostName, | 39 | @RequestParam(value = "virtualHostName", required = false) String virtualHostName, |
40 | + @RequestParam(value = "serverId", required = false) String serverId, | ||
40 | @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, | 41 | @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, |
41 | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { | 42 | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { |
42 | - ResultJson<PageInfo> result = new ResultJson<>(); | ||
43 | - VirtualHost virtualHost = new VirtualHost(); | ||
44 | - // 获取参数,所属服务器ID | ||
45 | - virtualHost.setServerId(serverId); | ||
46 | - // 获取参数,虚拟主机名称 | ||
47 | - virtualHost.setVirtualHostName(virtualHostName); | ||
48 | // 分页查询 | 43 | // 分页查询 |
49 | - PageInfo pageInfo = virtualHostService.selectVirtualHostList(virtualHost, pageNum, pageSize); | ||
50 | - if (pageInfo.getTotal() > 0) { | ||
51 | - result.setCode("200"); | ||
52 | - result.setData(pageInfo); | ||
53 | - result.setMsg("查询虚拟主机列表,成功!"); | ||
54 | - } else { | ||
55 | - result.setCode("500"); | ||
56 | - result.setMsg("查询虚拟主机列表,失败!"); | ||
57 | - } | ||
58 | - return result; | 44 | + PageInfo pageInfo = virtualHostService.selectVirtualHostList(new VirtualHost(virtualHostName, serverId), pageNum, pageSize); |
45 | + return pageInfo.getTotal() > 0 | ||
46 | + ? new ResultJson<>("200", "查询虚拟主机列表,成功!", pageInfo) | ||
47 | + : new ResultJson<>("500", "查询虚拟主机列表,失败!"); | ||
59 | } | 48 | } |
60 | 49 | ||
61 | /** | 50 | /** |
@@ -66,17 +55,9 @@ public class VirtualHostController { | @@ -66,17 +55,9 @@ public class VirtualHostController { | ||
66 | */ | 55 | */ |
67 | @DeleteMapping("/delete") | 56 | @DeleteMapping("/delete") |
68 | public ResultJson deleteVirtualHost(@RequestBody VirtualHost virtualHost) { | 57 | public ResultJson deleteVirtualHost(@RequestBody VirtualHost virtualHost) { |
69 | - | ||
70 | - ResultJson result = new ResultJson<>(); | ||
71 | - int num = virtualHostService.deleteByPrimaryKey(virtualHost.getId()); | ||
72 | - if (num > 0) { | ||
73 | - result.setCode("200"); | ||
74 | - result.setMsg("删除虚拟主机信息,成功"); | ||
75 | - } else { | ||
76 | - result.setCode("500"); | ||
77 | - result.setMsg("删除虚拟主机信息,失败"); | ||
78 | - } | ||
79 | - return result; | 58 | + return virtualHostService.deleteByPrimaryKey(virtualHost.getId()) > 0 |
59 | + ? new ResultJson<>("200", "删除虚拟主机信息,成功") | ||
60 | + : new ResultJson<>("500", "删除虚拟主机信息,失败"); | ||
80 | } | 61 | } |
81 | 62 | ||
82 | /** | 63 | /** |
@@ -87,16 +68,9 @@ public class VirtualHostController { | @@ -87,16 +68,9 @@ public class VirtualHostController { | ||
87 | */ | 68 | */ |
88 | @GetMapping("/batchRemove") | 69 | @GetMapping("/batchRemove") |
89 | public ResultJson batchRemoveVirtualHost(String ids) { | 70 | public ResultJson batchRemoveVirtualHost(String ids) { |
90 | - ResultJson result = new ResultJson<>(); | ||
91 | - int num = virtualHostService.deleteByPrimaryKey(ids); | ||
92 | - if (num > 0) { | ||
93 | - result.setCode("200"); | ||
94 | - result.setMsg("批量删除虚拟主机,成功!"); | ||
95 | - } else { | ||
96 | - result.setCode("500"); | ||
97 | - result.setMsg("批量删除虚拟主机,失败!"); | ||
98 | - } | ||
99 | - return result; | 71 | + return virtualHostService.deleteByPrimaryKey(ids) > 0 |
72 | + ? new ResultJson<>("200", "批量删除虚拟主机,成功") | ||
73 | + : new ResultJson<>("500", "批量删除虚拟主机,失败"); | ||
100 | } | 74 | } |
101 | 75 | ||
102 | /** | 76 | /** |
@@ -107,23 +81,13 @@ public class VirtualHostController { | @@ -107,23 +81,13 @@ public class VirtualHostController { | ||
107 | */ | 81 | */ |
108 | @PutMapping("/update") | 82 | @PutMapping("/update") |
109 | public ResultJson updateVirtualHost(@RequestBody VirtualHost virtualHost) { | 83 | public ResultJson updateVirtualHost(@RequestBody VirtualHost virtualHost) { |
110 | - | ||
111 | //先验证,修改好的核心信息(虚拟主机名称)是否已存在 | 84 | //先验证,修改好的核心信息(虚拟主机名称)是否已存在 |
112 | String message = validateVirtualHost(virtualHost); | 85 | String message = validateVirtualHost(virtualHost); |
113 | - //验证通过 | ||
114 | - if (message == null) { | ||
115 | - ResultJson result = new ResultJson<>(); | ||
116 | - int num = virtualHostService.updateByPrimaryKeySelective(virtualHost); | ||
117 | - if (num > 0) { | ||
118 | - result.setCode("200"); | ||
119 | - result.setMsg("修改虚拟主机信息,成功"); | ||
120 | - } else { | ||
121 | - result.setCode("500"); | ||
122 | - result.setMsg("修改虚拟主机信息,失败"); | ||
123 | - } | ||
124 | - return result; | ||
125 | - } | ||
126 | - return new ResultJson("400", message != null ? message : "修改虚拟主机信息,失败!"); | 86 | + return message == null |
87 | + ? virtualHostService.updateByPrimaryKeySelective(virtualHost) > 0 | ||
88 | + ? new ResultJson<>("200", "修改虚拟主机信息,成功") | ||
89 | + : new ResultJson<>("500", "修改虚拟主机信息,失败") | ||
90 | + : new ResultJson<>("400", message); | ||
127 | } | 91 | } |
128 | 92 | ||
129 | /** | 93 | /** |
@@ -138,20 +102,13 @@ public class VirtualHostController { | @@ -138,20 +102,13 @@ public class VirtualHostController { | ||
138 | String message = validateVirtualHost(virtualHost); | 102 | String message = validateVirtualHost(virtualHost); |
139 | //验证通过 | 103 | //验证通过 |
140 | if (message == null) { | 104 | if (message == null) { |
141 | - ResultJson result = new ResultJson<>(); | ||
142 | // 设置id | 105 | // 设置id |
143 | virtualHost.setId(IdUtils.generateId()); | 106 | virtualHost.setId(IdUtils.generateId()); |
144 | - int num = virtualHostService.insertSelective(virtualHost); | ||
145 | - if (num > 0) { | ||
146 | - result.setCode("200"); | ||
147 | - result.setMsg("添加虚拟主机信息,成功!"); | ||
148 | - } else { | ||
149 | - result.setCode("500"); | ||
150 | - result.setMsg("添加虚拟主机信息,失败!"); | ||
151 | - } | ||
152 | - return result; | 107 | + return virtualHostService.insertSelective(virtualHost) > 0 |
108 | + ? new ResultJson<>("200", "添加虚拟主机信息,成功") | ||
109 | + : new ResultJson<>("500", "添加虚拟主机信息,失败"); | ||
153 | } | 110 | } |
154 | - return new ResultJson("400", message != null ? message : "添加虚拟主机信息,失败!"); | 111 | + return new ResultJson<>("400", message); |
155 | } | 112 | } |
156 | 113 | ||
157 | /** | 114 | /** |
@@ -175,7 +132,7 @@ public class VirtualHostController { | @@ -175,7 +132,7 @@ public class VirtualHostController { | ||
175 | List<VirtualHost> info = virtualHostService.validateVirtualHost(virtualHost); | 132 | List<VirtualHost> info = virtualHostService.validateVirtualHost(virtualHost); |
176 | // 多于0个,则代表已存在;否则则是,校验通过 | 133 | // 多于0个,则代表已存在;否则则是,校验通过 |
177 | if (info.size() > 0) { | 134 | if (info.size() > 0) { |
178 | - return "该-虚拟主机(虚拟主机名称)-信息已存在,请谨慎输入"; | 135 | + return EXIST_HOST_INFO; |
179 | } | 136 | } |
180 | return null; | 137 | return null; |
181 | } | 138 | } |
@@ -188,7 +145,7 @@ public class VirtualHostController { | @@ -188,7 +145,7 @@ public class VirtualHostController { | ||
188 | List<VirtualHost> info = virtualHostService.validateVirtualHost(virtualHost); | 145 | List<VirtualHost> info = virtualHostService.validateVirtualHost(virtualHost); |
189 | // 多于0个,则代表已存在;否则则是,校验通过 | 146 | // 多于0个,则代表已存在;否则则是,校验通过 |
190 | if (info.size() > 0) { | 147 | if (info.size() > 0) { |
191 | - return "该-虚拟主机(虚拟主机名称)-信息已存在,请谨慎输入"; | 148 | + return EXIST_HOST_INFO; |
192 | } | 149 | } |
193 | return null; | 150 | return null; |
194 | } | 151 | } |
1 | package com.sunyo.wlpt.message.bus.service.domain; | 1 | package com.sunyo.wlpt.message.bus.service.domain; |
2 | 2 | ||
3 | -import java.io.Serializable; | ||
4 | -import java.util.Date; | ||
5 | -import java.util.List; | ||
6 | - | ||
7 | import com.fasterxml.jackson.annotation.JsonFormat; | 3 | import com.fasterxml.jackson.annotation.JsonFormat; |
8 | import lombok.AllArgsConstructor; | 4 | import lombok.AllArgsConstructor; |
9 | import lombok.Data; | 5 | import lombok.Data; |
10 | import lombok.NoArgsConstructor; | 6 | import lombok.NoArgsConstructor; |
11 | 7 | ||
8 | +import java.io.Serializable; | ||
9 | +import java.util.Date; | ||
10 | +import java.util.List; | ||
11 | + | ||
12 | /** | 12 | /** |
13 | * @author 子诚 | 13 | * @author 子诚 |
14 | * Description:MQ服务器静态信息表 | 14 | * Description:MQ服务器静态信息表 |
@@ -72,4 +72,14 @@ public class BusServer implements Serializable { | @@ -72,4 +72,14 @@ public class BusServer implements Serializable { | ||
72 | * 服务器名称的别名 | 72 | * 服务器名称的别名 |
73 | */ | 73 | */ |
74 | private String aliasName; | 74 | private String aliasName; |
75 | + | ||
76 | + /** | ||
77 | + * 定义有参构造器 | ||
78 | + * 封装 BusController 的查询参数 | ||
79 | + * | ||
80 | + * @param serverName 服务器名称 | ||
81 | + */ | ||
82 | + public BusServer(String serverName) { | ||
83 | + this.serverName = serverName; | ||
84 | + } | ||
75 | } | 85 | } |
1 | package com.sunyo.wlpt.message.bus.service.domain; | 1 | package com.sunyo.wlpt.message.bus.service.domain; |
2 | 2 | ||
3 | -import java.io.Serializable; | ||
4 | -import java.util.Date; | ||
5 | -import java.util.List; | ||
6 | - | ||
7 | import com.fasterxml.jackson.annotation.JsonFormat; | 3 | import com.fasterxml.jackson.annotation.JsonFormat; |
8 | import lombok.AllArgsConstructor; | 4 | import lombok.AllArgsConstructor; |
9 | import lombok.Data; | 5 | import lombok.Data; |
10 | import lombok.NoArgsConstructor; | 6 | import lombok.NoArgsConstructor; |
11 | 7 | ||
8 | +import java.io.Serializable; | ||
9 | +import java.util.Date; | ||
10 | +import java.util.List; | ||
11 | + | ||
12 | /** | 12 | /** |
13 | * @author 子诚 | 13 | * @author 子诚 |
14 | * Description:MQ虚拟主机名称表 | 14 | * Description:MQ虚拟主机名称表 |
@@ -73,4 +73,15 @@ public class VirtualHost implements Serializable { | @@ -73,4 +73,15 @@ public class VirtualHost implements Serializable { | ||
73 | */ | 73 | */ |
74 | private List<BusExchange> aliasList; | 74 | private List<BusExchange> aliasList; |
75 | 75 | ||
76 | + /** | ||
77 | + * 定义有参构造器 | ||
78 | + * 封装 VirtualHostController 的查询参数 | ||
79 | + * | ||
80 | + * @param serverId 所属服务器ID | ||
81 | + * @param virtualHostName 虚拟机名称 | ||
82 | + */ | ||
83 | + public VirtualHost(String virtualHostName, String serverId) { | ||
84 | + this.virtualHostName = virtualHostName; | ||
85 | + this.serverId = serverId; | ||
86 | + } | ||
76 | } | 87 | } |
-
请 注册 或 登录 后发表评论