IP类Dao,Service,Controller提交,后续会调整
This commit is contained in:
@@ -1,7 +1,19 @@
|
||||
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;
|
||||
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相关配置控制类
|
||||
@@ -10,8 +22,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/cfg/ip")
|
||||
public class IpCfgController {
|
||||
|
||||
public class IpCfgController extends BaseController{
|
||||
// @Autowired
|
||||
// protected IpCfgService ipCfgService;
|
||||
|
||||
@RequestMapping(value = {"ipWhiteList"})
|
||||
public String ipWhiteList() {
|
||||
@@ -24,15 +37,75 @@ public class IpCfgController {
|
||||
return "/cfg/ipWhiteForm";
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = {"ipBlockList"})
|
||||
public String 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "/cfg/ipBlockList";
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = {"ipBlockForm"})
|
||||
public String 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);
|
||||
}
|
||||
return "/cfg/ipBlockForm";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user