package com.product.data.center.controller;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import com.product.core.controller.support.AbstractBaseController;
|
import com.product.core.entity.FieldSetEntity;
|
import com.product.core.exception.BaseException;
|
import com.product.data.center.config.ErrorCode;
|
import com.product.data.center.service.NetWorkMonitorService;
|
import com.product.module.sys.version.ApiVersion;
|
import com.product.util.BaseUtil;
|
|
|
/**
|
* 网络监测
|
* @author 86151
|
*
|
*/
|
@RequestMapping("/api/netWork")
|
@RestController
|
public class NetWorkMonitorController extends AbstractBaseController{
|
|
@Autowired
|
NetWorkMonitorService netWorkMonitorService;
|
|
/**
|
* 监测IP列表(左侧树)
|
* @param request
|
* @return
|
*/
|
@PostMapping("/list/{version}")
|
@ApiVersion(1)
|
public String listNetWork(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
return OK_List(netWorkMonitorService.listNetWork());
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.NETWORK_OPERATE_FAIL+e.getMessage());
|
}
|
}
|
|
/**
|
* 监测IP视图(右侧模块)
|
* @param request
|
* @return
|
*/
|
@PostMapping("/view/{version}")
|
@ApiVersion(1)
|
public String viewNetWork(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
return BaseUtil.success(netWorkMonitorService.monitorIp(fse));
|
}catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.NETWORK_OPERATE_FAIL+e.getMessage());
|
}
|
}
|
|
/**
|
* 监测IP新增
|
* @param request
|
* @return
|
*/
|
@PostMapping("/add/{version}")
|
@ApiVersion(1)
|
public String addNetWork(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
return OK_Add(netWorkMonitorService.addNetWork(fse));
|
}catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.NETWORK_OPERATE_FAIL+e.getMessage());
|
}
|
}
|
|
/**
|
* 监测IP删除
|
* @param request
|
* @return
|
*/
|
@PostMapping("/delete/{version}")
|
@ApiVersion(1)
|
public String deleteNetWork(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
|
boolean succ=netWorkMonitorService.deleteNetWork(fse.getString("ip_address"));
|
if (succ) {
|
return OK();
|
}
|
return error(ErrorCode.NETWORK_DELETE_FAIL.getValue(), ErrorCode.NETWORK_DELETE_FAIL.getText());
|
}catch (BaseException e) {
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(ErrorCode.NETWORK_OPERATE_FAIL+e.getMessage());
|
}
|
}
|
}
|