...
|
...
|
@@ -8,7 +8,9 @@ import com.sunyo.wlpt.message.bus.service.utils.IdUtils; |
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeoutException;
|
|
|
|
|
|
import static com.sunyo.wlpt.message.bus.service.common.Constant.EXIST_ROUTINGKEY_INFO;
|
|
|
|
...
|
...
|
@@ -39,7 +41,8 @@ public class RoutingKeyController { |
|
|
@RequestParam(value = "routingKeyName", required = false) String routingKeyName,
|
|
|
@RequestParam(value = "exchangeId", required = false) String exchangeId,
|
|
|
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
|
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
|
|
|
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize)
|
|
|
{
|
|
|
// 获取查询参数
|
|
|
RoutingKey routingKey = RoutingKey.builder().routingKeyName(routingKeyName).exchangeId(exchangeId).build();
|
|
|
// 分页查询
|
...
|
...
|
@@ -56,8 +59,8 @@ public class RoutingKeyController { |
|
|
* @return {@link ResultJson}
|
|
|
*/
|
|
|
@DeleteMapping("/delete")
|
|
|
public ResultJson deleteRoutingKey(@RequestBody RoutingKey routingKey) {
|
|
|
|
|
|
public ResultJson deleteRoutingKey(@RequestBody RoutingKey routingKey) throws IOException, TimeoutException
|
|
|
{
|
|
|
return routingKeyService.deleteByPrimaryKey(routingKey.getId()) > 0
|
|
|
? new ResultJson<>("200", "删除路由键,成功")
|
|
|
: new ResultJson<>("500", "删除路由键,失败");
|
...
|
...
|
@@ -70,8 +73,8 @@ public class RoutingKeyController { |
|
|
* @return {@link ResultJson}
|
|
|
*/
|
|
|
@GetMapping("/batchRemove")
|
|
|
public ResultJson batchRemoveRoutingKey(String ids) {
|
|
|
|
|
|
public ResultJson batchRemoveRoutingKey(String ids) throws IOException, TimeoutException
|
|
|
{
|
|
|
return routingKeyService.deleteByPrimaryKey(ids) > 0
|
|
|
? new ResultJson<>("200", "删除路由键,成功")
|
|
|
: new ResultJson<>("500", "删除路由键,失败");
|
...
|
...
|
@@ -84,7 +87,8 @@ public class RoutingKeyController { |
|
|
* @return {@link ResultJson}
|
|
|
*/
|
|
|
@PutMapping("/update")
|
|
|
public ResultJson updateRoutingKey(@RequestBody RoutingKey routingKey) {
|
|
|
public ResultJson updateRoutingKey(@RequestBody RoutingKey routingKey)
|
|
|
{
|
|
|
|
|
|
//先验证,修改好的核心信息(路由键名称)是否已存在
|
|
|
String message = validateRoutingKey(routingKey);
|
...
|
...
|
@@ -102,7 +106,8 @@ public class RoutingKeyController { |
|
|
* @return {@link ResultJson}
|
|
|
*/
|
|
|
@PostMapping("/insert")
|
|
|
public ResultJson insertRoutingKey(@RequestBody RoutingKey routingKey) {
|
|
|
public ResultJson insertRoutingKey(@RequestBody RoutingKey routingKey)
|
|
|
{
|
|
|
|
|
|
//先验证,增加的服务器的核心信息(ip和port,同时存在)是否已存在
|
|
|
String message = validateRoutingKey(routingKey);
|
...
|
...
|
@@ -122,7 +127,8 @@ public class RoutingKeyController { |
|
|
* @param routingKey {@link RoutingKey}
|
|
|
* @return 通过,无返回消息
|
|
|
*/
|
|
|
private String validateRoutingKey(RoutingKey routingKey) {
|
|
|
private String validateRoutingKey(RoutingKey routingKey)
|
|
|
{
|
|
|
if ("".equals(routingKey.getRoutingKeyName()) || routingKey.getRoutingKeyName() == null) {
|
|
|
return "该路由键信息中,没有路由键名称";
|
|
|
}
|
...
|
...
|
|