|
...
|
...
|
@@ -2,13 +2,16 @@ package com.crossoverjie.netty.action.zk.controller; |
|
|
|
|
|
|
|
import com.crossoverjie.netty.action.common.enums.StatusEnum;
|
|
|
|
import com.crossoverjie.netty.action.common.res.BaseResponse;
|
|
|
|
import com.crossoverjie.netty.action.common.res.NULLBody;
|
|
|
|
import com.crossoverjie.netty.action.zk.cache.ServerCache;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function:
|
|
|
|
*
|
|
...
|
...
|
@@ -21,19 +24,42 @@ import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
public class IndexController {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private ServerCache serverCache ;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取所有路由节点
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@ApiOperation("获取所有路由节点")
|
|
|
|
@RequestMapping(value = "getAllRoute",method = RequestMethod.POST)
|
|
|
|
@ResponseBody()
|
|
|
|
public BaseResponse<List<String>> getAllRoute(){
|
|
|
|
BaseResponse<List<String>> res = new BaseResponse();
|
|
|
|
List<String> all = serverCache.getAll();
|
|
|
|
res.setDataBody(all);
|
|
|
|
res.setCode(StatusEnum.SUCCESS.getCode()) ;
|
|
|
|
res.setMessage(StatusEnum.SUCCESS.getMessage()) ;
|
|
|
|
return res ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取所有路由节点
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@ApiOperation("获取所有路由节点")
|
|
|
|
@RequestMapping(value = "getRoute",method = RequestMethod.POST)
|
|
|
|
@RequestMapping(value = "getOneOfRoute",method = RequestMethod.POST)
|
|
|
|
@ResponseBody()
|
|
|
|
public BaseResponse<NULLBody> getRoute(){
|
|
|
|
BaseResponse<NULLBody> res = new BaseResponse();
|
|
|
|
public BaseResponse<String> getOneOfRoute(){
|
|
|
|
BaseResponse<String> res = new BaseResponse();
|
|
|
|
String server = serverCache.selectServer();
|
|
|
|
res.setDataBody(server);
|
|
|
|
res.setCode(StatusEnum.SUCCESS.getCode()) ;
|
|
|
|
res.setMessage("127.0.0.1:8080") ;
|
|
|
|
res.setMessage(StatusEnum.SUCCESS.getMessage()) ;
|
|
|
|
return res ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|