This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
k18-ntcs-web-ntc/src/main/java/com/nis/web/controller/configuration/IpCfgController.java

113 lines
3.7 KiB
Java
Raw Normal View History

package com.nis.web.controller.configuration;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
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;
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;
/**
* IP相关配置控制类
* @author dell
*
*/
@Controller
2018-02-02 17:58:32 +08:00
@RequestMapping("${adminPath}/cfg/ip")
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-02-02 17:58:32 +08:00
@RequestMapping(value = {"ipWhiteForm"})
public String ipWhiteForm() {
return "/cfg/ipWhiteForm";
}
@RequestMapping(value = {"ipBlockList"})
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"})
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";
}
}