2018-01-09 16:50:39 +08:00
|
|
|
|
package com.nis.web.controller.configuration;
|
|
|
|
|
|
|
2018-03-29 17:24:21 +08:00
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2018-06-22 18:46:01 +08:00
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
import org.springframework.stereotype.Controller;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
2018-04-08 17:19:43 +08:00
|
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
|
|
|
|
|
|
import com.nis.domain.Page;
|
2018-06-22 18:46:01 +08:00
|
|
|
|
import com.nis.domain.configuration.AppPolicyCfg;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
import com.nis.domain.specific.SpecificServiceCfg;
|
2018-06-22 18:46:01 +08:00
|
|
|
|
import com.nis.exceptions.MaatConvertException;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
import com.nis.web.controller.BaseController;
|
2018-06-22 18:46:01 +08:00
|
|
|
|
import com.nis.web.security.UserUtils;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 特定协议相关配置控制类
|
2018-03-29 17:24:21 +08:00
|
|
|
|
* @author zhangwei
|
2018-01-09 16:50:39 +08:00
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Controller
|
2018-06-22 18:46:01 +08:00
|
|
|
|
@RequestMapping("${adminPath}/app")
|
2018-03-29 17:24:21 +08:00
|
|
|
|
public class AppCfgController extends BaseController {
|
|
|
|
|
|
/**
|
2018-06-22 18:46:01 +08:00
|
|
|
|
* app策略列表
|
|
|
|
|
|
* @param model
|
|
|
|
|
|
* @param cfg
|
|
|
|
|
|
* @param request
|
|
|
|
|
|
* @param response
|
|
|
|
|
|
* @return
|
2018-03-29 17:24:21 +08:00
|
|
|
|
*/
|
2018-06-22 18:46:01 +08:00
|
|
|
|
@RequestMapping(value = {"policyList"})
|
|
|
|
|
|
public String policyList(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/app/appPolicyCfgList";
|
|
|
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = {"policyForm"})
|
|
|
|
|
|
@RequiresPermissions(value={"app:policy:config"})
|
|
|
|
|
|
public String policyForm(Model model,String ids,AppPolicyCfg entity) {
|
|
|
|
|
|
if(StringUtils.isNotBlank(ids)){
|
|
|
|
|
|
entity = appCfgService.getAppPolicyCfg(Long.parseLong(ids));
|
|
|
|
|
|
initUpdateFormCondition(model,entity);
|
2018-03-29 17:24:21 +08:00
|
|
|
|
}else{
|
2018-06-22 18:46:01 +08:00
|
|
|
|
initFormCondition(model,entity);
|
2018-03-29 17:24:21 +08:00
|
|
|
|
}
|
2018-06-22 18:46:01 +08:00
|
|
|
|
model.addAttribute("_cfg", entity);
|
|
|
|
|
|
return "/cfg/app/appPolicyCfgForm";
|
2018-03-29 17:24:21 +08:00
|
|
|
|
}
|
2018-06-22 18:46:01 +08:00
|
|
|
|
@RequestMapping(value = {"saveAppPolicyCfg"})
|
|
|
|
|
|
@RequiresPermissions(value={"app:policy:config"})
|
|
|
|
|
|
public String saveAppPolicyCfg(Model model,HttpServletRequest request,HttpServletResponse response,
|
|
|
|
|
|
AppPolicyCfg entity,RedirectAttributes redirectAttributes) {
|
2018-04-08 17:19:43 +08:00
|
|
|
|
try {
|
2018-06-22 18:46:01 +08:00
|
|
|
|
appCfgService.saveOrUpdateAppPolicyCfg(entity);
|
2018-04-08 17:19:43 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
2018-06-22 18:46:01 +08:00
|
|
|
|
addMessage(redirectAttributes, e.getMessage());
|
2018-03-29 17:24:21 +08:00
|
|
|
|
}
|
2018-06-22 18:46:01 +08:00
|
|
|
|
|
|
|
|
|
|
return "redirect:" + adminPath +"/app/policyList?function="+entity.getFunctionId();
|
2018-03-29 17:24:21 +08:00
|
|
|
|
}
|
2018-06-22 18:46:01 +08:00
|
|
|
|
@RequestMapping(value = {"auditAppPolicyCfg"})
|
|
|
|
|
|
@RequiresPermissions(value={"app:policy:audit"})
|
|
|
|
|
|
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);
|
|
|
|
|
|
try {
|
|
|
|
|
|
appCfgService.auditAppPolicyCfg(entity,isAudit);
|
|
|
|
|
|
} catch (MaatConvertException e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger.info("app策略配置下发失败:"+e.getMessage());
|
|
|
|
|
|
addMessage(redirectAttributes, e.getMessage());
|
|
|
|
|
|
}
|
2018-03-29 17:24:21 +08:00
|
|
|
|
}
|
2018-06-22 18:46:01 +08:00
|
|
|
|
return "redirect:" + adminPath +"/app/policyList?functionId="+functionId;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
}
|
2018-06-22 18:46:01 +08:00
|
|
|
|
@RequestMapping(value = {"updateAppPolicyCfgValid"})
|
|
|
|
|
|
@RequiresPermissions(value={"app:policy:config"})
|
|
|
|
|
|
public String updateAppPolicyCfgValid(Integer isValid,String ids,Integer functionId) {
|
|
|
|
|
|
appCfgService.updateAppPolicyCfgValid(isValid,ids,functionId);
|
|
|
|
|
|
return "redirect:" + adminPath +"/app/policyList?functionId="+functionId;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
}
|
2018-01-09 16:50:39 +08:00
|
|
|
|
}
|