2018-01-09 16:50:39 +08:00
|
|
|
|
package com.nis.web.controller.configuration;
|
|
|
|
|
|
|
2018-02-23 09:54:28 +08:00
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
import org.springframework.stereotype.Controller;
|
2018-02-23 09:54:28 +08:00
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
2018-02-02 17:58:32 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
2018-02-23 09:54:28 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
|
|
|
|
|
|
|
import com.nis.domain.Page;
|
|
|
|
|
|
import com.nis.domain.ServiceConfigInfo;
|
|
|
|
|
|
import com.nis.domain.configuration.BaseIpCfg;
|
|
|
|
|
|
import com.nis.web.controller.BaseController;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* IP相关配置控制类
|
|
|
|
|
|
* @author dell
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Controller
|
2018-02-02 17:58:32 +08:00
|
|
|
|
@RequestMapping("${adminPath}/cfg/ip")
|
2018-02-23 09:54:28 +08:00
|
|
|
|
public class IpCfgController extends BaseController{
|
|
|
|
|
|
// @Autowired
|
|
|
|
|
|
// protected IpCfgService ipCfgService;
|
2018-02-02 17:58:32 +08:00
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = {"ipWhiteList"})
|
|
|
|
|
|
public String ipWhiteList() {
|
|
|
|
|
|
return "/cfg/ipWhiteList";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-09 16:50:39 +08:00
|
|
|
|
|
2018-02-02 17:58:32 +08:00
|
|
|
|
@RequestMapping(value = {"ipWhiteForm"})
|
|
|
|
|
|
public String ipWhiteForm() {
|
|
|
|
|
|
return "/cfg/ipWhiteForm";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = {"ipBlockList"})
|
2018-02-23 09:54:28 +08:00
|
|
|
|
public String ipBlockList(Model model,BaseIpCfg baseIpCfg,HttpServletRequest request,HttpServletResponse response) {
|
|
|
|
|
|
if(baseIpCfg!=null){
|
|
|
|
|
|
Integer serviceId=baseIpCfg.getServiceId();
|
|
|
|
|
|
logger.info("sercice id is "+serviceId);
|
|
|
|
|
|
if(serviceId!=null){
|
|
|
|
|
|
ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId);
|
|
|
|
|
|
if(serviceConfigInfo!=null){
|
|
|
|
|
|
String tableName=serviceConfigInfo.getTableName();
|
|
|
|
|
|
if(!StringUtils.isBlank(tableName)){
|
|
|
|
|
|
logger.info("table name is "+tableName);
|
|
|
|
|
|
baseIpCfg.setTableName(tableName);
|
|
|
|
|
|
Page<BaseIpCfg> page = ipCfgService.findPage(new Page<BaseIpCfg>(request, response, 1), baseIpCfg);
|
|
|
|
|
|
model.addAttribute("page", page);
|
|
|
|
|
|
model.addAttribute("serviceId", serviceId);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-02-02 17:58:32 +08:00
|
|
|
|
return "/cfg/ipBlockList";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = {"ipBlockForm"})
|
2018-02-23 09:54:28 +08:00
|
|
|
|
public String ipBlockForm(Integer serviceId,Model model,HttpServletRequest request,HttpServletResponse response) {
|
|
|
|
|
|
logger.info("sercice id is "+serviceId);
|
|
|
|
|
|
System.out.println("ipBlockForm loaded");
|
|
|
|
|
|
if(serviceId!=null){
|
|
|
|
|
|
ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId);
|
|
|
|
|
|
if(serviceConfigInfo!=null){
|
|
|
|
|
|
String tableName=serviceConfigInfo.getTableName();
|
|
|
|
|
|
if(!StringUtils.isBlank(tableName)){
|
|
|
|
|
|
logger.info("table name is "+tableName);
|
|
|
|
|
|
String className=ipCfgService.getClassName(tableName);
|
|
|
|
|
|
logger.info("class name is "+className);
|
|
|
|
|
|
String packageName=BaseIpCfg.class.getPackage().getName();
|
|
|
|
|
|
try {
|
|
|
|
|
|
//通过反射获得BaseIpCfg的子类的实例,并调用子类的initDefaultValue初始化默认值
|
|
|
|
|
|
Class clazz=Class.forName(packageName+"."+className);
|
|
|
|
|
|
BaseIpCfg ipcfg=(BaseIpCfg)clazz.newInstance();
|
|
|
|
|
|
ipcfg.setTableName(tableName);
|
|
|
|
|
|
ipcfg.initDefaultValue();
|
|
|
|
|
|
model.addAttribute("_ipCfg", ipcfg);
|
|
|
|
|
|
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
|
logger.error("打开新增IP窗口失败",e);
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return "/cfg/ipBlockForm";
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* addIpPortCfg(新增IP配置)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*String
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(method=RequestMethod.POST,value = {"addIpCfg"})
|
|
|
|
|
|
public String addIpCfg(@ModelAttribute("ipCfg") BaseIpCfg ipCfg) {
|
|
|
|
|
|
if(ipCfg!=null&&!StringUtils.isBlank(ipCfg.getTableName())){
|
|
|
|
|
|
int result=ipCfgService.addIpCfg(ipCfg);
|
|
|
|
|
|
}
|
2018-02-02 17:58:32 +08:00
|
|
|
|
return "/cfg/ipBlockForm";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-09 16:50:39 +08:00
|
|
|
|
}
|