2018-07-24 18:45:27 +08:00
|
|
|
|
package com.nis.web.controller.configuration;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
|
|
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.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
|
|
|
|
|
|
import com.nis.domain.Page;
|
|
|
|
|
|
import com.nis.domain.configuration.AppPolicyCfg;
|
|
|
|
|
|
import com.nis.domain.configuration.IpPortCfg;
|
2018-08-22 15:20:14 +08:00
|
|
|
|
import com.nis.domain.configuration.NtcSubscribeIdCfg;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
import com.nis.domain.specific.SpecificServiceCfg;
|
2018-08-22 15:20:14 +08:00
|
|
|
|
import com.nis.exceptions.CallExternalProceduresException;
|
2018-07-24 18:45:27 +08:00
|
|
|
|
import com.nis.exceptions.MaatConvertException;
|
|
|
|
|
|
import com.nis.util.Constants;
|
|
|
|
|
|
import com.nis.web.controller.BaseController;
|
|
|
|
|
|
import com.nis.web.security.UserUtils;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 基础协议控制类
|
|
|
|
|
|
* @author wx
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Controller
|
|
|
|
|
|
@RequestMapping("${adminPath}/basicprotocol")
|
|
|
|
|
|
public class BasicProtocolController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
|
|
|
* app策略列表
|
|
|
|
|
|
* @param model
|
|
|
|
|
|
* @param cfg
|
|
|
|
|
|
* @param request
|
|
|
|
|
|
* @param response
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"list"})
|
|
|
|
|
|
public String policyCfgList(Model model,@ModelAttribute("cfg")AppPolicyCfg cfg,HttpServletRequest request,HttpServletResponse response) {
|
|
|
|
|
|
Page<AppPolicyCfg> searchPage=new Page<AppPolicyCfg>(request,response,"r");
|
|
|
|
|
|
Page<AppPolicyCfg> page = appCfgService.findAppPolicyList(searchPage, cfg);
|
|
|
|
|
|
for(AppPolicyCfg entity:page.getList()){
|
|
|
|
|
|
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
|
|
|
|
|
|
entity.setAppName(app.getSpecServiceName());
|
|
|
|
|
|
}
|
|
|
|
|
|
model.addAttribute("page", page);
|
|
|
|
|
|
initPageCondition(model,cfg);
|
|
|
|
|
|
return "/cfg/basicprotocol/list";
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询APP策略IP子配置
|
|
|
|
|
|
* @param model
|
|
|
|
|
|
* @param cfgId
|
|
|
|
|
|
* @param index
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"ajaxIpList"})
|
|
|
|
|
|
public String ajaxSslSubList(Model model,Long cfgId,Integer index) {
|
|
|
|
|
|
AppPolicyCfg cfg = appCfgService.getAppPolicyCfg(cfgId);
|
|
|
|
|
|
List<String[]> tabList = new ArrayList();
|
|
|
|
|
|
if(cfg.getIpPortList()!=null){
|
|
|
|
|
|
String cfgType = null;
|
|
|
|
|
|
for(IpPortCfg ip:cfg.getIpPortList()){
|
|
|
|
|
|
if(!ip.getCfgType().equals(cfgType)){
|
|
|
|
|
|
tabList.add(new String[]{"1",ip.getCfgType()});
|
|
|
|
|
|
cfgType = ip.getCfgType();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-08-22 15:20:14 +08:00
|
|
|
|
if(cfg.getNtcSubscribeIdCfgList()!=null){
|
|
|
|
|
|
String cfgType = null;
|
|
|
|
|
|
for(NtcSubscribeIdCfg ntc:cfg.getNtcSubscribeIdCfgList()){
|
|
|
|
|
|
if(!ntc.getCfgType().equals(cfgType)){
|
|
|
|
|
|
tabList.add(new String[]{"2",ntc.getCfgType()});
|
|
|
|
|
|
cfgType = ntc.getCfgType();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
model.addAttribute("_cfg", cfg);
|
2018-07-24 18:45:27 +08:00
|
|
|
|
model.addAttribute("index", index);
|
|
|
|
|
|
model.addAttribute("tabList", tabList);
|
|
|
|
|
|
return "/cfg/basicprotocol/ipList";
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 策略配置表单
|
|
|
|
|
|
* @param model
|
|
|
|
|
|
* @param ids
|
|
|
|
|
|
* @param entity
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"form"})
|
|
|
|
|
|
@RequiresPermissions(value={"basicprotocol:config"})
|
|
|
|
|
|
public String policyCfgForm(Model model,String ids,AppPolicyCfg entity) {
|
|
|
|
|
|
if(StringUtils.isNotBlank(ids)){
|
|
|
|
|
|
entity = appCfgService.getAppPolicyCfg(Long.parseLong(ids));
|
|
|
|
|
|
initUpdateFormCondition(model,entity);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
initFormCondition(model,entity);
|
|
|
|
|
|
}
|
|
|
|
|
|
model.addAttribute("_cfg", entity);
|
|
|
|
|
|
return "/cfg/basicprotocol/form";
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 策略配置新增修改
|
|
|
|
|
|
* @param model
|
|
|
|
|
|
* @param request
|
|
|
|
|
|
* @param response
|
|
|
|
|
|
* @param entity
|
|
|
|
|
|
* @param redirectAttributes
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"save"})
|
|
|
|
|
|
@RequiresPermissions(value={"basicprotocol:config"})
|
|
|
|
|
|
public String saveAppPolicyCfg(Model model,HttpServletRequest request,HttpServletResponse response,
|
|
|
|
|
|
AppPolicyCfg entity,RedirectAttributes redirectAttributes) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
SpecificServiceCfg specificService = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
|
|
|
|
|
|
if(specificService!=null){
|
|
|
|
|
|
entity.setAppCode(specificService.getSpecServiceCode());
|
|
|
|
|
|
}
|
|
|
|
|
|
appCfgService.saveOrUpdateAppPolicyCfg(entity);
|
2018-08-22 15:20:14 +08:00
|
|
|
|
addMessage(redirectAttributes,"save_success");
|
2018-07-24 18:45:27 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
2018-08-22 15:20:14 +08:00
|
|
|
|
logger.error("基础协议信息保存失败",e);
|
|
|
|
|
|
if(e instanceof MaatConvertException||e instanceof CallExternalProceduresException) {
|
|
|
|
|
|
// addMessage(redirectAttributes,e.getMessage());
|
|
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
|
|
|
|
|
}else {
|
|
|
|
|
|
addMessage(redirectAttributes,"save_failed");
|
|
|
|
|
|
}
|
2018-07-24 18:45:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return "redirect:" + adminPath +"/basicprotocol/list?functionId="+entity.getFunctionId();
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 策略配置审核
|
|
|
|
|
|
* @param isAudit
|
|
|
|
|
|
* @param isValid
|
|
|
|
|
|
* @param ids
|
|
|
|
|
|
* @param functionId
|
|
|
|
|
|
* @param redirectAttributes
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"audit"})
|
|
|
|
|
|
@RequiresPermissions(value={"basicprotocol:confirm"})
|
|
|
|
|
|
public String auditAppPolicyCfg(Integer isAudit,Integer isValid,String ids,Integer functionId, RedirectAttributes redirectAttributes) {
|
|
|
|
|
|
AppPolicyCfg entity = new AppPolicyCfg();
|
|
|
|
|
|
String[] idArray = ids.split(",");
|
|
|
|
|
|
for(String id :idArray){
|
|
|
|
|
|
entity = appCfgService.getAppPolicyCfg(Long.parseLong(id));
|
|
|
|
|
|
entity.setIsAudit(isAudit);
|
|
|
|
|
|
entity.setIsValid(isValid);
|
|
|
|
|
|
entity.setAuditorId(UserUtils.getUser().getId());
|
|
|
|
|
|
entity.setAuditTime(new Date());
|
|
|
|
|
|
entity.setFunctionId(functionId);
|
|
|
|
|
|
entity.setConfigType(Constants.SPECIFIC_SERVICE_CFG_TYPE_BASIC_PROTOCOL);
|
|
|
|
|
|
try {
|
|
|
|
|
|
appCfgService.auditAppPolicyCfg(entity,isAudit);
|
2018-08-22 15:20:14 +08:00
|
|
|
|
addMessage(redirectAttributes,"audit_success");
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
if(e instanceof MaatConvertException) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger.info("app策略配置下发失败:"+e.getMessage());;
|
|
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
|
|
|
|
|
}else {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger.error("auditAvAudioSignSample failed",e);
|
|
|
|
|
|
addMessage(redirectAttributes,"audit_failed");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-24 18:45:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return "redirect:" + adminPath +"/basicprotocol/list?functionId="+functionId;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 策略配置删除
|
|
|
|
|
|
* @param isValid
|
|
|
|
|
|
* @param ids
|
|
|
|
|
|
* @param functionId
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@RequestMapping(value = {"updateValid"})
|
|
|
|
|
|
@RequiresPermissions(value={"basicprotocol:config"})
|
2018-08-22 15:20:14 +08:00
|
|
|
|
public String updateAppPolicyCfgValid(Integer isValid,String ids,Integer functionId,RedirectAttributes redirectAttributes) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
appCfgService.updateAppPolicyCfgValid(isValid,ids,functionId);
|
|
|
|
|
|
addMessage(redirectAttributes,"delete_success");
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error("基础协议信息保存失败",e);
|
|
|
|
|
|
if(e instanceof MaatConvertException||e instanceof CallExternalProceduresException) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
|
|
|
|
|
}else {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
addMessage(redirectAttributes,"delete_failed");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-24 18:45:27 +08:00
|
|
|
|
return "redirect:" + adminPath +"/basicprotocol/list?functionId="+functionId;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|